xgrammar/parser/token_type.rs
1//! EBNF lexer token kinds.
2
3/// The kind of a lexical token produced by the EBNF lexer.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub enum TokenType {
6 /// The name of a rule definition (the identifier left of `::=`).
7 RuleName,
8 /// A reference to a rule or a macro name.
9 Identifier,
10 /// A `"..."` string literal.
11 StringLiteral,
12 /// `true` or `false`.
13 BooleanLiteral,
14 /// An integer literal.
15 IntegerLiteral,
16 /// `(`
17 LParen,
18 /// `)`
19 RParen,
20 /// `{`
21 LBrace,
22 /// `}`
23 RBrace,
24 /// `|`
25 Pipe,
26 /// `,`
27 Comma,
28 /// End of input.
29 EndOfFile,
30 /// `::=`
31 Assign,
32 /// `=`
33 Equal,
34 /// `*`
35 Star,
36 /// `+`
37 Plus,
38 /// `?`
39 Question,
40 /// `[`
41 LBracket,
42 /// `]`
43 RBracket,
44 /// `-`
45 Dash,
46 /// `^`
47 Caret,
48 /// A literal character inside a character class (possibly an escaped non-special char).
49 CharInCharClass,
50 /// A special escape inside a character class, e.g. `\S`, `\d`.
51 EscapeInCharClass,
52 /// `(=` — the start of a lookahead assertion.
53 LookaheadLParen,
54}