-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgrammar.txt
50 lines (45 loc) · 1.09 KB
/
grammar.txt
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
# grammar
Programa → Dcls Stmts fim
Dcls → Dcl Dcls | vazio
Dcl → floatdcl id | intdcl id
Stmts → Stmt Stmts | vazio
Stmt → id assign Expr
| while ( Expr ) do Stmt Stmts endwhile
| if ( Expr ) then Stmt Stmts StmtIf
| print Expr
StmtIf → endif | else Stmt Stmts endif
ExprLogica -> Expr Comparador Expr
Comparador -> maior | maiorIgual | menor | menorIgual | igual | diferente
Expr -> Termo Expr'
Expr'-> vazio
Expr'-> adicao Termo Expr'
Expr'-> subtracao Termo Expr'
Termo-> Fator Termo'
Termo'-> multiplicacao Fator Termo' | vazio
Termo'-> divisao Fator Termo'
Fator-> inum | id | fnum | ( Expr )
---
intdcl = crieUmInteiro
floatdcl = crieUmRacional
print = MostreNaTela
adicao = +
subtracao = -
multiplicacao = *
divisao = /
id = [a-z]+
inum = [0-9]+
fnum = [0-9]+.[0-9]+
assign = agoraEh
if = se
then = entao
endif = fimSe
else = senao
while = enquanto
do = faca
endwhile = fimEnquanto
maior = EhMaior
maiorIgual = EhMaiorIgual
menor = EhMenor
menorIgual = EhMenorIgual
igual = EhIgual
diferente = EhDiferente