Serenity Operating System
at master 50 lines 1.9 kB view raw
1/* 2 * Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#include "Token.h" 8 9namespace CMake { 10 11Optional<ControlKeywordType> control_keyword_from_string(StringView value) 12{ 13 if (value.equals_ignoring_ascii_case("if"sv)) 14 return ControlKeywordType::If; 15 if (value.equals_ignoring_ascii_case("elseif"sv)) 16 return ControlKeywordType::ElseIf; 17 if (value.equals_ignoring_ascii_case("else"sv)) 18 return ControlKeywordType::Else; 19 if (value.equals_ignoring_ascii_case("endif"sv)) 20 return ControlKeywordType::EndIf; 21 if (value.equals_ignoring_ascii_case("foreach"sv)) 22 return ControlKeywordType::ForEach; 23 if (value.equals_ignoring_ascii_case("endforeach"sv)) 24 return ControlKeywordType::EndForEach; 25 if (value.equals_ignoring_ascii_case("while"sv)) 26 return ControlKeywordType::While; 27 if (value.equals_ignoring_ascii_case("endwhile"sv)) 28 return ControlKeywordType::EndWhile; 29 if (value.equals_ignoring_ascii_case("break"sv)) 30 return ControlKeywordType::Break; 31 if (value.equals_ignoring_ascii_case("continue"sv)) 32 return ControlKeywordType::Continue; 33 if (value.equals_ignoring_ascii_case("return"sv)) 34 return ControlKeywordType::Return; 35 if (value.equals_ignoring_ascii_case("macro"sv)) 36 return ControlKeywordType::Macro; 37 if (value.equals_ignoring_ascii_case("endmacro"sv)) 38 return ControlKeywordType::EndMacro; 39 if (value.equals_ignoring_ascii_case("function"sv)) 40 return ControlKeywordType::Function; 41 if (value.equals_ignoring_ascii_case("endfunction"sv)) 42 return ControlKeywordType::EndFunction; 43 if (value.equals_ignoring_ascii_case("block"sv)) 44 return ControlKeywordType::Block; 45 if (value.equals_ignoring_ascii_case("endblock"sv)) 46 return ControlKeywordType::EndBlock; 47 return {}; 48} 49 50}