-
Notifications
You must be signed in to change notification settings - Fork 38
/
grammmars.txt
56 lines (45 loc) · 1.27 KB
/
grammmars.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
51
52
53
54
55
L_var
exp ::= Constant(int)
| Call(Name('input_int'),[])
| UnaryOp(USub(), exp)
| BinOp(exp, Add(), exp)
| BinOp(exp, Sub(), exp)
| Name(var)
stmt ::= Expr(Call(Name('print'), [exp]))
| Expr(exp)
| Assign([Name(var)], exp)
LVar ::= Module(stmt∗)
L_var^mon
atm ::= Constant(int)
| Name(var)
exp ::= atm
| Call(Name('input_int'),[])
| UnaryOp(USub(), atm)
| BinOp(atm, Add(), atm)
| BinOp(atm, Sub(), atm)
stmt ::= Expr(Call(Name('print'), [atm]))
| Expr(exp)
| Assign([Name(var)], exp)
LVar ::= Module(stmt∗)
X86_Var
reg ::= 'rsp' | 'rbp' | 'rax' | 'rbx' | 'rcx' | 'rdx' | 'rsi' | 'rdi'
| 'r8' | 'r9' | 'r10' | 'r11' | 'r12' | 'r13' | 'r14' | 'r15'
arg ::= Immediate(int)
| Reg(reg)
| Deref(reg,int)
| Variable(var)
instr ::= Instr('addq',[arg,arg])
| Instr('subq',[arg,arg])
| Instr('movq',[arg,arg])
| Instr('negq',[arg])
| Instr('pushq',[arg])
| Instr('popq',[arg])
| Callq(label,int)
| Instr('retq',[])
| Jump(label)
x86_Var ::= X86Program(instr∗)
X86_Int
Remove Variable(var) from arg.
arg ::= Immediate(int)
| Reg(reg)
| Deref(reg,int)