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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u16)]
pub enum LuaSyntaxKind {
None,
// source
Chunk,
// block
Block,
// statements
EmptyStat,
LocalStat,
LocalFuncStat,
IfStat,
ElseIfClauseStat,
ElseClauseStat,
WhileStat,
DoStat,
ForStat,
ForRangeStat,
RepeatStat,
FuncStat,
LabelStat,
BreakStat,
ReturnStat,
GotoStat,
CallExprStat,
AssignStat,
GlobalStat,
UnknownStat,
// expressions
ParenExpr,
LiteralExpr,
ClosureExpr,
UnaryExpr,
BinaryExpr,
TableArrayExpr, // { a, b, c}
TableObjectExpr, // { a = 1, b = 2, c = 3}
TableEmptyExpr, // {}
CallExpr, // a()
RequireCallExpr, // require('a')
ErrorCallExpr, // error('a')
AssertCallExpr, // assert(a)
TypeCallExpr, // type(a)
SetmetatableCallExpr, // setmetatable(a, b)
IndexExpr,
NameExpr,
// other
LocalName,
ParamName,
ParamList,
CallArgList,
TableFieldAssign,
TableFieldValue,
Attribute,
// comment
Comment,
// doc tag
DocTagClass,
DocTagEnum,
DocTagInterface,
DocTagAlias,
DocTagField,
DocTagType,
DocTagParam,
DocTagReturn,
DocTagReturnOverload,
DocTagGeneric,
DocTagSee,
DocTagDeprecated,
DocTagCast,
DocTagOverload,
DocTagAsync,
DocTagVisibility,
DocTagMeta,
DocTagOther,
DocTagDiagnostic,
DocTagVersion,
DocTagAs,
DocTagNodiscard,
DocTagOperator,
DocTagModule,
DocTagMapping,
DocTagNamespace,
DocTagUsing,
DocTagSource,
DocTagReadonly,
DocTagReturnCast,
DocTagExport,
DocTagLanguage,
DocTagAttribute,
DocTagAttributeUse, // '@['
DocTagCallGeneric,
DocTagSchema,
// doc Type
TypeArray, // baseType []
TypeUnary, // keyof type
TypeBinary, // aType | bType, aType & bType, aType extends bType, aType in bType
TypeConditional, // <conditionType> and <trueType> or <falseType>
TypeFun, // fun(<paramList>): returnType
TypeGeneric, // name<typeList>
TypeTuple, // [typeList]
TypeObject, // { a: aType, b: bType } or { [1]: aType, [2]: bType } or { a: aType, b: bType, [number]: string }
TypeLiteral, // "string" or <integer> or true or false
TypeName, // name
TypeInfer, // infer T
TypeVariadic, // type...
TypeNullable, // <Type>?
TypeStringTemplate, // prefixName.`T`
TypeMultiLineUnion, // | simple type # description
TypeAttribute, // declare. attribute<(paramList)>
// follow donot support now
TypeMatch,
TypeIndexAccess, // type[keyType]
TypeMapped, // { [p in KeyType]+? : ValueType }
// doc other
DocObjectField,
DocContinueOrField,
// doc parameter
DocTypedParameter,
DocNamedReturnType,
DocGenericParameter,
DocGenericDeclareList,
DocDiagnosticNameList,
DocTypeList,
DocTypeFlag, // (partial, global, local, ...)
DocAttributeUse, // use. attribute in @[attribute1, attribute2, ...]
DocAttributeCallArgList, // use. argument list in @[attribute_name(arg1, arg2, ...)]
DocOpType, // +<type>, -<type>, +?
DocEnumFieldList, // ---| <EnumField>
DocMappedKey, // <+/-readonly> [Property in <keyof> KeyType]<+/-?>
DocEnumField, // <string> # description or <integer> # description or <name> # description
DocOneLineField, // <type> # description
DocDiagnosticCodeList, // unused-local, undefined-global ...
// start with '#' or '@'
DocDescription,
// [<|>] [<framework>] <version>, <version> can be '5.1', '5.2', '5.3', '5.4', 'JIT', <framework> can be 'openresty'
DocVersion,
}