mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:27:45 +00:00
LibCMake: Add a lexer for CMakeCache.txt
This is a totally different syntax than for regular CMake files, and also is undocumented and subject to change, but it's also nice and simple. :^)
This commit is contained in:
parent
515fca4f7a
commit
bb07d678ac
6 changed files with 324 additions and 5 deletions
55
Userland/Libraries/LibCMake/CMakeCache/Token.h
Normal file
55
Userland/Libraries/LibCMake/CMakeCache/Token.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibCMake/Position.h>
|
||||
|
||||
namespace CMake::Cache {
|
||||
|
||||
struct Token {
|
||||
enum class Type {
|
||||
Comment,
|
||||
HelpText,
|
||||
Key,
|
||||
Colon,
|
||||
Type,
|
||||
Equals,
|
||||
Value,
|
||||
Garbage,
|
||||
};
|
||||
Type type;
|
||||
StringView value;
|
||||
|
||||
Position start;
|
||||
Position end;
|
||||
};
|
||||
|
||||
static constexpr StringView to_string(Token::Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case Token::Type::Comment:
|
||||
return "Comment"sv;
|
||||
case Token::Type::HelpText:
|
||||
return "HelpText"sv;
|
||||
case Token::Type::Key:
|
||||
return "Key"sv;
|
||||
case Token::Type::Colon:
|
||||
return "Colon"sv;
|
||||
case Token::Type::Type:
|
||||
return "Type"sv;
|
||||
case Token::Type::Equals:
|
||||
return "Equals"sv;
|
||||
case Token::Type::Value:
|
||||
return "Value"sv;
|
||||
case Token::Type::Garbage:
|
||||
return "Garbage"sv;
|
||||
}
|
||||
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue