emmylua_parser/kind/lua_token_kind.rs
1use core::fmt;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
4#[repr(u16)]
5pub enum LuaTokenKind {
6    None,
7    // KeyWord
8    TkAnd,
9    TkBreak,
10    TkDo,
11    TkElse,
12    TkElseIf,
13    TkEnd,
14    TkFalse,
15    TkFor,
16    TkFunction,
17    TkGoto,
18    TkIf,
19    TkIn,
20    TkLocal,
21    TkNil,
22    TkNot,
23    TkOr,
24    TkRepeat,
25    TkReturn,
26    TkThen,
27    TkTrue,
28    TkUntil,
29    TkWhile,
30    TkGlobal, // global *
31
32    TkWhitespace,   // whitespace
33    TkEndOfLine,    // end of line
34    TkPlus,         // +
35    TkMinus,        // -
36    TkMul,          // *
37    TkDiv,          // /
38    TkIDiv,         // //
39    TkDot,          // .
40    TkConcat,       // ..
41    TkDots,         // ...
42    TkComma,        // ,
43    TkAssign,       // =
44    TkEq,           // ==
45    TkGe,           // >=
46    TkLe,           // <=
47    TkNe,           // ~=
48    TkShl,          // <<
49    TkShr,          // >>
50    TkLt,           // <
51    TkGt,           // >
52    TkMod,          // %
53    TkPow,          // ^
54    TkLen,          // #
55    TkBitAnd,       // &
56    TkBitOr,        // |
57    TkBitXor,       // ~
58    TkColon,        // :
59    TkDbColon,      // ::
60    TkSemicolon,    // ;
61    TkLeftBracket,  // [
62    TkRightBracket, // ]
63    TkLeftParen,    // (
64    TkRightParen,   // )
65    TkLeftBrace,    // {
66    TkRightBrace,   // }
67    TkComplex,      // complex
68    TkInt,          // int
69    TkFloat,        // float
70
71    TkName,         // name
72    TkString,       // string
73    TkLongString,   // long string
74    TkShortComment, // short comment
75    TkLongComment,  // long comment
76    TkShebang,      // shebang
77    TkEof,          // eof
78
79    TkUnknown, // unknown
80
81    // doc
82    TkNormalStart,      // -- or ---
83    TkLongCommentStart, // --[[
84    TkDocLongStart,     // --[[@
85    TkDocStart,         // ---@
86    TKDocTriviaStart,   // --------------
87    TkDocTrivia,        // other can not parsed
88    TkLongCommentEnd,   // ]] or ]===]
89
90    // tag
91    TkTagClass,     // class
92    TkTagEnum,      // enum
93    TkTagInterface, // interface
94    TkTagAlias,     // alias
95    TkTagModule,    // module
96
97    TkTagField,      // field
98    TkTagType,       // type
99    TkTagParam,      // param
100    TkTagReturn,     // return
101    TkTagOverload,   // overload
102    TkTagGeneric,    // generic
103    TkTagSee,        // see
104    TkTagDeprecated, // deprecated
105    TkTagAsync,      // async
106    TkTagCast,       // cast
107    TkTagOther,      // other
108    TkTagVisibility, // public private protected package
109    TkTagReadonly,   // readonly
110    TkTagDiagnostic, // diagnostic
111    TkTagMeta,       // meta
112    TkTagVersion,    // version
113    TkTagAs,         // as
114    TkTagNodiscard,  // nodiscard
115    TkTagOperator,   // operator
116    TkTagMapping,    // mapping
117    TkTagNamespace,  // namespace
118    TkTagUsing,      // using
119    TkTagSource,     // source
120    TkTagReturnCast, // return cast
121    TkTagExport,     // export
122
123    TkDocOr,              // |
124    TkDocAnd,             // &
125    TkDocKeyOf,           // keyof
126    TkDocExtends,         // extends
127    TkDocAs,              // as
128    TkDocIn,              // in
129    TkDocInfer,           // infer
130    TkDocContinue,        // ---
131    TkDocContinueOr,      // ---| or ---|+  or ---|>
132    TkDocDetail,          // a description
133    TkDocQuestion,        // '?'
134    TkDocVisibility,      // public private protected package
135    TkDocReadonly,        // readonly
136    TkAt,                 // '@', invalid lua token, but for postfix completion
137    TkDocVersionNumber,   // version number
138    TkStringTemplateType, // type template
139    TkDocMatch,           // =
140    TKDocPath,            // path
141    TkDocRegion,          // region
142    TkDocEndRegion,       // endregion
143    TkDocSeeContent,      // see content
144}
145
146impl fmt::Display for LuaTokenKind {
147    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
148        write!(f, "{:?}", self)
149    }
150}