forked from synesthesiam/jsgf2fst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJsgfLexer.g4
47 lines (38 loc) · 1.14 KB
/
JsgfLexer.g4
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
lexer grammar JsgfLexer;
// Keywords
PUBLIC : 'public' ;
JSGF : '#JSGF' ;
GRAMMAR : 'grammar' ;
VERSION : ('v' | 'V') Digit DOT Digit ;
// Separators
LPAREN : '(' ;
RPAREN : ')' ;
LBRACE : '{' ;
RBRACE : '}' ;
LBRACK : '[' ;
RBRACK : ']' ;
LANGLE : '<' ;
RANGLE : '>' ;
SEMI : ';' ;
DOT : '.' ;
HASH : '#' ;
// Operators
EQUALS : '=' ;
BAR : '|' ;
// Escape Sequences
ESCAPE_LBRACE : '\\{' ;
ESCAPE_RBRACE : '\\}' ;
// Whitespace and comments
WS : [ \t\r\n\u000C]+ -> channel(HIDDEN);
COMMENT : '/*' .*? '*/' -> channel(HIDDEN) ;
LINE_COMMENT : '//' ~[\r\n]* -> channel(HIDDEN) ;
TOKEN : ~(';' | '=' | '|' | '*' | '+' | '(' | ')'
| '<' | '>' | '{' | '}' | '[' | ']'
| ' ' | '\t' | '\r' | '\n' | '\u000C')+ ;
//IDENTIFIER : Letter LetterOrDigit* ;
//TOKEN : Letter LetterOrDigit* ;
fragment Digit : [0-9] ;
fragment LetterOrDigit : Letter | [0-9] ;
fragment Letter : [a-zA-Z$_] // letters below 0x7F
| ~[\u0000-\u007F\uD800-\uDBFF] // characters above 0x7F that aren't surrogate
| [\uD800-\uDBFF] [\uDC00-\uDFFF] ; // UTF-16 surrogate pair encodings for U+10000 to U+10FFF