-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyLexer.g4
73 lines (54 loc) · 1.23 KB
/
MyLexer.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
// $antlr-format columnLimit 120, useTab false, minEmptyLines 0
// $antlr-format alignSemicolons none, alignColons trailing
// $antlr-format alignLexerCommands true, alignLabels true, alignTrailers true
lexer grammar MyLexer;
WHITESPACE: [ \t\r\n]+ -> skip;
COMMENT: '#' ~[\r\n]* -> skip;
PLUS : '+';
MINUS : '-';
MULTIPLY : '*';
DIVIDE : '/';
MAT_PLUS : '.+';
MAT_MINUS : '.-';
MAT_MULTIPLY : '.*';
MAT_DIVIDE : './';
MAT_TRANSPOSE_OP: '\'';
ASSIGN : '=';
ASSIGN_PLUS : '+=';
ASSIGN_MINUS : '-=';
ASSIGN_MULTIPLY : '*=';
ASSIGN_DIVIDE : '/=';
LT : '<';
GT : '>';
EQ : '==';
NEQ : '!=';
LEQ : '<=';
GEQ : '>=';
OPEN_BRACKET_ROUND : '(';
CLOSE_BRACKET_ROUND : ')';
OPEN_BRACKET_SQUARE : '[';
CLOSE_BRACKET_SQUARE : ']';
OPEN_BRACKET_CURLY : '{';
CLOSE_BRACKET_CURLY : '}';
RANGE_OP: ':';
COMMA : ',';
SEMICOLON : ';';
IF : 'if';
ELSE : 'else';
FOR : 'for';
WHILE : 'while';
BREAK : 'break';
CONTINUE : 'continue';
RETURN : 'return';
EYE : 'eye';
ZEROS : 'zeros';
ONES : 'ones';
PRINT: 'print';
ID: [a-zA-Z_][a-zA-Z_0-9]*;
INT: [0-9]+;
FLOAT:
[0-9]+ '.'
| [0-9]* '.' [0-9]+
| [0-9]* '.' [0-9]+ [eE] [+-]? [0-9]+
| [0-9]+ [eE] [+-]? [0-9]+;
STRING: '"' ~["]* '"';