-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSchema.g4
76 lines (55 loc) · 1.07 KB
/
Schema.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
71
72
73
74
75
76
grammar Schema;
/**
* Parser Rule
*/
schema: struct+ EOF;
// @PATH "TEST" struct NAME { TYPES } or struct NAME { TYPES }
struct: pathCommand? 'struct' NAME CURVED_BRACKET_OPEN type+ CURVED_BRACKET_CLOSE;
pathCommand: AT 'PATH' STRING;
// int test; or int test[2];
type: primitiveType+ NAME array? SEMICOLON
| userType NAME array? SEMICOLON
;
// [NUMBER][NUMBER][NUMBER]
array: dimension+;
// [NUMBER]
dimension: BRACKET_OPEN NUMBER BRACKET_CLOSE;
primitiveType:
'char'
| 'char16_t'
| 'char32_t'
| 'wchar_t'
| 'unsigned'
| 'signed'
| 'short'
| 'int'
| 'long'
| 'int8_t'
| 'int16_t'
| 'int32_t'
| 'int64_t'
| 'uint8_t'
| 'uint16_t'
| 'uint32_t'
| 'uint64_t'
| 'float'
| 'double'
| 'bool';
userType: NAME;
/**
* Lexer Rule
*/
SEMICOLON: ';';
CURVED_BRACKET_OPEN: '{';
CURVED_BRACKET_CLOSE: '}';
BRACKET_OPEN: '[';
BRACKET_CLOSE: ']';
DELIMITER: '\'' | '"' ;
AT: '@';
STRING: DELIMITER .*? DELIMITER;
// A word can be letters [A-Za-z]+
NAME: [A-Za-z]+;
// A number can only be between 0-9+
NUMBER: [0-9]+;
NEWLINE: [\r\n]+ -> skip;
WHITESPACE: ' ' -> skip;