1use oak_core::{ElementType, Parser, UniversalElementRole};
2#[cfg(feature = "serde")]
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
6#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
7#[repr(u16)]
8pub enum LuaElementType {
9 Root,
10 And,
12 Break,
13 Do,
14 Else,
15 Elseif,
16 End,
17 False,
18 For,
19 Function,
20 Goto,
21 If,
22 In,
23 Local,
24 Nil,
25 Not,
26 Or,
27 Repeat,
28 Return,
29 Then,
30 True,
31 Until,
32 While,
33
34 Identifier,
36 Number,
37 String,
38
39 Plus, Minus, Star, Slash, Percent, Caret, Hash, Ampersand, Tilde, Pipe, LtLt, GtGt, SlashSlash, EqEq, TildeEq, LtEq, GtEq, Lt, Gt, Eq, LeftParen, RightParen, LeftBrace, RightBrace, LeftBracket, RightBracket, ColonColon, Semicolon, Colon, Comma, Dot, DotDot, DotDotDot, Whitespace,
78 Newline,
79 Comment,
80
81 EndOfStream,
83 Error,
84
85 SourceFile,
87 FunctionDeclaration,
88 ParameterList,
89 Parameter,
90 BlockStatement,
91 LocalStatement,
92 AssignmentStatement,
93 ExpressionStatement,
94 IfStatement,
95 WhileStatement,
96 ForStatement,
97 RepeatStatement,
98 DoStatement,
99 BreakStatement,
100 ReturnStatement,
101 GotoStatement,
102 LabelStatement,
103 IdentifierExpression,
104 LiteralExpression,
105 BooleanLiteral,
106 NilLiteral,
107 ParenthesizedExpression,
108 BinaryExpression,
109 UnaryExpression,
110 CallExpression,
111 MemberExpression,
112 IndexExpression,
113 TableConstructorExpression,
114 FunctionExpression,
115 VarargExpression,
116 TableField,
117 FieldList,
118 ArgumentList,
119 VariableList,
120 ExpressionList,
121 NameList,
122 FunctionName,
123 FunctionBody,
124 ChunkStatement,
125 StatementList,
126}
127
128impl ElementType for LuaElementType {
129 type Role = UniversalElementRole;
130
131 fn role(&self) -> Self::Role {
132 match self {
133 _ => UniversalElementRole::None,
134 }
135 }
136}
137
138impl From<crate::lexer::token_type::LuaTokenType> for LuaElementType {
139 fn from(token: crate::lexer::token_type::LuaTokenType) -> Self {
140 unsafe { std::mem::transmute(token) }
141 }
142}