-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgrammar_specification.ebnf
More file actions
75 lines (47 loc) · 1.39 KB
/
grammar_specification.ebnf
File metadata and controls
75 lines (47 loc) · 1.39 KB
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
prog = exp prog | exp;
(*
%left '+' '-'
%left '*' '/'
%left '<' '>' '<=' '>='
%left '&&' '||'
*)
exp = assignation |
if_expression |
print_expression |
while_expression |
operation ;
assignation = var ident assignToken intOp newLineToken;
intOp = ident |
intToken |
intToken plus intOp |
intToken minus intOp |
intToken multiply intOp |
intToken divide intOp ;
if_expression = if_body endIf newLineToken |
if_body else_expr ;
if_body = ifToken condition newLineToken if_bloq ;
else_expr = elseToken newLineToken if_bloq endIfToken newLineToken ;
if_bloq = bloq if_bloq |
bloq ;
bloq = assignation |
operation |
print_expression ;
condition = intOp conditionToken intOp ;
while_expression = whileToken condition newLineToken bloq_while endWhileToken newLineToken ;
bloq_while = bloq bloq_while |
bloq ;
operation = intOp newLineToken ;
print_expression = printToken intOp newLineToken ;
intToken = "[0-9]+" ;
ifToken = "if" ;
endIfToken = "endif" ;
whileToken = "while" ;
endWhileToken = "endwhile" ;
conditionToken = ['||' '&&' '<' '>' '<=' '>='] ;
printToken = "print" ;
newLineToken = '\n' ;
plus = '+' ;
minus = '-' ;
multiply = '*' ;
divide = '/' ;
ident = [a-z A-Z \ \_ \'];