-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAtestat.g4
39 lines (39 loc) · 1016 Bytes
/
Atestat.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
grammar Atestat;
ID: [a-zA-Z_][a-zA-Z0-9_]* ;
LPARAN : '(' ;
RPARAN : ')' ;
LSQBRACK : '[' ;
RSQBRACK : ']' ;
COMMA : ',' ;
MATHFSTART : 'f"' ;
DBLQUOTE : '"' ;
PLUS : '+' ;
MINUS : '-' ;
TIMES : '*' ;
DIV : '/' ;
POW : '^' ;
MOD : '%' ;
Number : IntLiteral | FloatLiteral ;
StringLiteral : (DBLQUOTE|MATHFSTART) ~('\r' | '\n' | '"')* DBLQUOTE ;
IntLiteral : MINUS? [0-9]+ ;
FloatLiteral : MINUS? [0-9]+ '.' [0-9]+ ;
instructions : fncall+ EOF;
fncall : LPARAN ID arg* RPARAN ;
arg : fncall
| literal
| ID ;
literal : StringLiteral
| Number
| arrayLiteral ;
arrayLiteral : LSQBRACK (arg COMMA)* arg? RSQBRACK ;
mathFunctionLiteral : MATHFSTART mathExpr DBLQUOTE ;
mathExpr : mathExpr POW mathExpr
| mathExpr (TIMES | DIV) mathExpr
| mathExpr MOD mathExpr
| mathExpr (PLUS | MINUS) mathExpr
| LPARAN mathExpr RPARAN
| mathFunction
| Number
| ID;
mathFunction : ID LPARAN mathExpr RPARAN ;
WS : (' ' | '\n' | '\t' | '\r')+ -> skip;