ladybird/Userland/Libraries/LibCMake/Token.cpp

51 lines
1.9 KiB
C++
Raw Normal View History

2023-03-03 15:12:56 +03:00
/*
* 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_ascii_case("if"sv))
2023-03-03 15:12:56 +03:00
return ControlKeywordType::If;
if (value.equals_ignoring_ascii_case("elseif"sv))
2023-03-03 15:12:56 +03:00
return ControlKeywordType::ElseIf;
if (value.equals_ignoring_ascii_case("else"sv))
2023-03-03 15:12:56 +03:00
return ControlKeywordType::Else;
if (value.equals_ignoring_ascii_case("endif"sv))
2023-03-03 15:12:56 +03:00
return ControlKeywordType::EndIf;
if (value.equals_ignoring_ascii_case("foreach"sv))
2023-03-03 15:12:56 +03:00
return ControlKeywordType::ForEach;
if (value.equals_ignoring_ascii_case("endforeach"sv))
2023-03-03 15:12:56 +03:00
return ControlKeywordType::EndForEach;
if (value.equals_ignoring_ascii_case("while"sv))
2023-03-03 15:12:56 +03:00
return ControlKeywordType::While;
if (value.equals_ignoring_ascii_case("endwhile"sv))
2023-03-03 15:12:56 +03:00
return ControlKeywordType::EndWhile;
if (value.equals_ignoring_ascii_case("break"sv))
2023-03-03 15:12:56 +03:00
return ControlKeywordType::Break;
if (value.equals_ignoring_ascii_case("continue"sv))
2023-03-03 15:12:56 +03:00
return ControlKeywordType::Continue;
if (value.equals_ignoring_ascii_case("return"sv))
return ControlKeywordType::Return;
if (value.equals_ignoring_ascii_case("macro"sv))
2023-03-03 15:12:56 +03:00
return ControlKeywordType::Macro;
if (value.equals_ignoring_ascii_case("endmacro"sv))
2023-03-03 15:12:56 +03:00
return ControlKeywordType::EndMacro;
if (value.equals_ignoring_ascii_case("function"sv))
2023-03-03 15:12:56 +03:00
return ControlKeywordType::Function;
if (value.equals_ignoring_ascii_case("endfunction"sv))
2023-03-03 15:12:56 +03:00
return ControlKeywordType::EndFunction;
if (value.equals_ignoring_ascii_case("block"sv))
return ControlKeywordType::Block;
if (value.equals_ignoring_ascii_case("endblock"sv))
return ControlKeywordType::EndBlock;
2023-03-03 15:12:56 +03:00
return {};
}
}