blob: 7cc30ca071065f0db3e0cd28662a45fbaf7fcd11 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/*
* 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))
return ControlKeywordType::If;
if (value.equals_ignoring_ascii_case("elseif"sv))
return ControlKeywordType::ElseIf;
if (value.equals_ignoring_ascii_case("else"sv))
return ControlKeywordType::Else;
if (value.equals_ignoring_ascii_case("endif"sv))
return ControlKeywordType::EndIf;
if (value.equals_ignoring_ascii_case("foreach"sv))
return ControlKeywordType::ForEach;
if (value.equals_ignoring_ascii_case("endforeach"sv))
return ControlKeywordType::EndForEach;
if (value.equals_ignoring_ascii_case("while"sv))
return ControlKeywordType::While;
if (value.equals_ignoring_ascii_case("endwhile"sv))
return ControlKeywordType::EndWhile;
if (value.equals_ignoring_ascii_case("break"sv))
return ControlKeywordType::Break;
if (value.equals_ignoring_ascii_case("continue"sv))
return ControlKeywordType::Continue;
if (value.equals_ignoring_ascii_case("return"sv))
return ControlKeywordType::Return;
if (value.equals_ignoring_ascii_case("macro"sv))
return ControlKeywordType::Macro;
if (value.equals_ignoring_ascii_case("endmacro"sv))
return ControlKeywordType::EndMacro;
if (value.equals_ignoring_ascii_case("function"sv))
return ControlKeywordType::Function;
if (value.equals_ignoring_ascii_case("endfunction"sv))
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;
return {};
}
}
|