mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:47:46 +00:00
LibCMake: Introduce a CMake lexer
This commit is contained in:
parent
ca4cc03269
commit
3d8cc2257f
8 changed files with 581 additions and 0 deletions
44
Userland/Libraries/LibCMake/Token.cpp
Normal file
44
Userland/Libraries/LibCMake/Token.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "Token.h"
|
||||
|
||||
namespace CMake {
|
||||
|
||||
Optional<ControlKeywordType> control_keyword_from_string(StringView value)
|
||||
{
|
||||
if (value.equals_ignoring_case("if"sv))
|
||||
return ControlKeywordType::If;
|
||||
if (value.equals_ignoring_case("elseif"sv))
|
||||
return ControlKeywordType::ElseIf;
|
||||
if (value.equals_ignoring_case("else"sv))
|
||||
return ControlKeywordType::Else;
|
||||
if (value.equals_ignoring_case("endif"sv))
|
||||
return ControlKeywordType::EndIf;
|
||||
if (value.equals_ignoring_case("foreach"sv))
|
||||
return ControlKeywordType::ForEach;
|
||||
if (value.equals_ignoring_case("endforeach"sv))
|
||||
return ControlKeywordType::EndForEach;
|
||||
if (value.equals_ignoring_case("while"sv))
|
||||
return ControlKeywordType::While;
|
||||
if (value.equals_ignoring_case("endwhile"sv))
|
||||
return ControlKeywordType::EndWhile;
|
||||
if (value.equals_ignoring_case("break"sv))
|
||||
return ControlKeywordType::Break;
|
||||
if (value.equals_ignoring_case("continue"sv))
|
||||
return ControlKeywordType::Continue;
|
||||
if (value.equals_ignoring_case("macro"sv))
|
||||
return ControlKeywordType::Macro;
|
||||
if (value.equals_ignoring_case("endmacro"sv))
|
||||
return ControlKeywordType::EndMacro;
|
||||
if (value.equals_ignoring_case("function"sv))
|
||||
return ControlKeywordType::Function;
|
||||
if (value.equals_ignoring_case("endfunction"sv))
|
||||
return ControlKeywordType::EndFunction;
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue