/
lexer.ts
38 lines (34 loc) · 1 KB
/
lexer.ts
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
import { BaaMatchRule, BaaRule, BaaToken, Lexer, StateName } from "baa-lexer";
export type MustacheOpenType = "OPEN_UNESCAPED" | "OPEN";
export type MustacheCloseType = "CLOSE_UNESCAPED" | "CLOSE";
export type TokenType =
| "CONTENT"
| "COMMENT"
| "SPACE"
| "ID"
| "SQUARE_WRAPPED_ID"
| "ESCAPED_MUSTACHE"
| "STRIP"
| "DOT"
| "SLASH"
| "STRING_LITERAL_DOUBLE_QUOTE"
| "STRING_LITERAL_SINGLE_QUOTE"
| "NUMBER"
| "BOOLEAN"
| "OPEN_SUB_EXPRESSION"
| "CLOSE_SUB_EXPRESSION"
| MustacheOpenType
| MustacheCloseType
| "error";
export interface HbsLexerTypes {
tokenType: TokenType | "error";
stateName: "main" | "mustache" | "unescapedMustache";
}
export type HbsRule = BaaRule<HbsLexerTypes>;
export type HbsMatchRule = BaaMatchRule<HbsLexerTypes>;
export type Token = BaaToken<HbsLexerTypes>;
export type HbsLexer = Lexer<HbsLexerTypes>;
export type HbsLexerState = StateName<HbsLexerTypes>;
export interface TokenTypes extends Iterable<TokenType> {
has(token: TokenType): boolean;
}