forked from Barro/compiler-warnings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTableGen.g4
70 lines (48 loc) · 1.27 KB
/
TableGen.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
grammar TableGen;
options
{
language = Python2;
}
expression : (ws | statementExpression)* EOF ;
statementExpression : switchDefinition ;
switchDefinition :
'def' (ws definitionName)? ws?
':'
diagnosticProperties
';' ;
diagnosticProperties :
ws? classDefinition ws? (',' ws? classDefinition ws?)*
;
definitionName : switchClass ;
classDefinition :
classDefinitionName ws?
'<' ws? switchName ws?
(',' ws? identifierList)?
ws? '>' ;
classDefinitionName : classname ;
switchName : emptySwitchName | ('"' switchText '"') ;
emptySwitchName : '""' ;
switchClass : classname ;
identifierList :
'['
ws? identifierReference ws?
(',' ws? identifierReference ws?)*
']' ;
identifierReference :
referencedName
// TODO clang 3.1 uses this syntax inside identifier lists.
// | classDefinition
;
referencedName :
switchClass
;
classname : IDENTIFIERTEXT ;
ws : (COMMENT | WHITESPACE)+ ;
IDENTIFIERTEXT : ('a'..'z' | 'A'..'Z' | '0'..'9')+;
WHITESPACE : (' '|'\t'|'\n')+;
START_COMMENT : '//' ;
COMMENT_CHARS : ~[\r\n] ;
END_COMMENT : '\n' ;
COMMENT : START_COMMENT COMMENT_CHARS* END_COMMENT ;
WHITESPACE_COMMENT : (WHITESPACE)+ ;
switchText : (~'"')+ ;