-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSynthtaxLexer.g4
More file actions
66 lines (34 loc) · 799 Bytes
/
Copy pathSynthtaxLexer.g4
File metadata and controls
66 lines (34 loc) · 799 Bytes
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
lexer grammar SynthtaxLexer;
HEADER : '@header' .*? '@end_header';
IF : 'if';
ELSE : 'else';
WHILE : 'while';
PRINT : 'print';
PRINTLN : 'println';
RETURN : 'return';
BOOL : 'true' | 'false';
COMMA : ',';
COLON : ':';
SEMICOLON : ';';
OPENPAREN : '(';
CLOSEPAREN : ')';
OPENBRACKET : '{';
CLOSEBRACKET : '}';
ASSIGN : '=';
EQUALITY : '==';
LESS : '<';
ADD : '+';
SUB : '-';
MUL : '*';
DIV : '/';
// env: envelop
TYPE : 'int' | 'float' | 'char' | 'string' | 'void' | 'osc' | 'env';
STRING : '"' [a-zA-Z_0-9.]* '"'; // no space
INT : [0-9]+; // can have leading 0s
FLOAT : [0-9]+ '.' [0-9]+;
CHAR : '\'' [a-zA-Z_.] '\'';
ID : [a-zA-Z_]+ ;
NEWLINE: ('\r' '\n'? | '\n') -> skip;
WS: [ \t]+ -> skip;
BLOCKCOMMENT : '/*'.*? '*/'->skip;
LINECOMMENT : '//' ~[\r\n]* -> skip;