cfront_definition_keyword/
keyword.rs1#[derive(Debug, PartialEq, Eq, Clone, )]
2pub enum Keyword {
3 AlignAs,
4 AlignOf,
5 Auto,
6 Bool,
7 Break,
8 Case,
9 Char,
10 Const,
11 Constexpr,
12 Continue,
13 Default,
14 Do,
15 Double,
16 Else,
17 Enum,
18 Extern,
19 False,
20 Float,
21 For,
22 Goto,
23 If,
24 Inline,
25 Int,
26 Long,
27 Nullptr,
28 Register,
29 Restrict,
30 Return,
31 Short,
32 Signed,
33 Sizeof,
34 Static,
35 StaticAssert,
36 Struct,
37 Switch,
38 ThreadLocal,
39 True,
40 Typedef,
41 TypeOf,
42 TypeOfUnqual,
43 Union,
44 Unsigned,
45 Void,
46 Volatile,
47 While,
48 _AlignAs,
49 _AlignOf,
50 _Atomic,
51 _BigInt,
52 _Bool,
53 _Complex,
54 _Decimal128,
55 _Decimal32,
56 _Decimal64,
57 _Generic,
58 _Imaginary,
59 _Noreturn,
60 _StaticAssert,
61 _ThreadLocal,
62 Asm,
63 Fortran,
64}
65
66impl Keyword {
67 pub fn from_str_src(src: &str) -> Result<Keyword, ()> {
68 use Keyword::*;
69 let ans = match src {
70 "alignas" => AlignAs,
71 "alignof" => AlignOf,
72 "auto" => Auto,
73 "bool" => Bool,
74 "break" => Break,
75 "case" => Case,
76 "char" => Char,
77 "const" => Const,
78 "constexpr" => Constexpr,
79 "continue" => Continue,
80 "default" => Default,
81 "do" => Do,
82 "double" => Double,
83 "else" => Else,
84 "enum" => Enum,
85 "extern" => Extern,
86 "false" => False,
87 "float" => Float,
88 "for" => For,
89 "goto" => Goto,
90 "if" => If,
91 "inline" => Inline,
92 "int" => Int,
93 "long" => Long,
94 "nullptr" => Nullptr,
95 "register" => Register,
96 "restrict" => Restrict,
97 "return" => Return,
98 "short" => Short,
99 "signed" => Signed,
100 "sizeof" => Sizeof,
101 "static" => Static,
102 "static_assert" => StaticAssert,
103 "struct" => Struct,
104 "switch" => Switch,
105 "thread_local" => ThreadLocal,
106 "true" => True,
107 "typedef" => Typedef,
108 "typeof" => TypeOf,
109 "typeof_unqual" => TypeOfUnqual,
110 "union" => Union,
111 "unsigned" => Unsigned,
112 "void" => Void,
113 "volatile" => Volatile,
114 "while" => While,
115 "_Alignas" => _AlignAs,
116 "_Alignof" => _AlignOf,
117 "_Atomic" => _Atomic,
118 "_Bool" => _Bool,
119 "_Complex" => _Complex,
120 "_Decimal128" => _Decimal128,
121 "_Decimal32" => _Decimal32,
122 "_Decimal64" => _Decimal64,
123 "_Generic" => _Generic,
124 "_Imaginary" => _Imaginary,
125 "_Noreturn" => _Noreturn,
126 "_Static_assert" => _StaticAssert,
127 "_Thread_local" => _ThreadLocal,
128 "asm" => Asm,
129 _ => return Err(())
130 };
131 return Ok(ans);
132 }
133}
134