-
Notifications
You must be signed in to change notification settings - Fork 14
/
Scene.g4
57 lines (40 loc) · 1.19 KB
/
Scene.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
grammar Scene;
// Parser rules
file : (name NEWLINE (TAB elements+=action NEWLINE?)* ) EOF;
name : NAME ':';
action : DRAW size shape IN color AT position
| WRITE size STRING IN color AT position
;
size : SMALL | MEDIUM | BIG ;
shape : CIRCLE | SQUARE;
color : BLACK | BLUE | BROWN | GREEN | RED | ORANGE | PURPLE | YELLOW | WHITE ;
position : x=(LEFT | CENTER | RIGHT) ',' y=(TOP | CENTER | BOTTOM) ;
// Lexer rules
DRAW : 'draw' ;
WRITE : 'write' ;
IN : 'in' ;
AT : 'at';
CIRCLE : 'circle' ;
SQUARE : 'square' ;
SMALL : 'small' ;
MEDIUM : 'medium' ;
BIG : 'big' ;
LEFT : 'left' ;
RIGHT : 'right' ;
CENTER : 'center' ;
TOP : 'top' ;
BOTTOM : 'bottom' ;
STRING : '"' .*? '"' ;
BLACK : 'black' ;
BLUE : 'blue' ;
BROWN : 'brown' ;
GREEN : 'green' ;
RED : 'red' ;
ORANGE : 'orange' ;
PURPLE : 'purple' ;
YELLOW : 'yellow' ;
WHITE : 'white' ;
NAME : [a-zA-Z0-9\-_]+;
NEWLINE : ('\r'? '\n' | '\r')+ ;
TAB : ('\t' | ' ' | ' ' ) ;
WHITESPACE : ' ' -> skip ;