aboutsummaryrefslogtreecommitdiff
path: root/src/tpc.y
diff options
context:
space:
mode:
authorpacien2018-06-06 15:10:11 +0200
committerpacien2018-06-06 15:10:11 +0200
commitc0feca77799b859a5331417595ac0190bb999e0d (patch)
tree3e7b45d90ae8608949e1c67c8269f1aaa19412f6 /src/tpc.y
parent84c850e3a264d8bb1694c64348c445009b83b007 (diff)
downloadtpc-compiler-c0feca77799b859a5331417595ac0190bb999e0d.tar.gz
extract while instr
Diffstat (limited to 'src/tpc.y')
-rw-r--r--src/tpc.y6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/tpc.y b/src/tpc.y
index 16dc5ad..1e6b6e2 100644
--- a/src/tpc.y
+++ b/src/tpc.y
@@ -135,9 +135,9 @@ Instr:
135| IF '(' Exp IfHandling')' Instr { gen_if_label($<num>4); } 135| IF '(' Exp IfHandling')' Instr { gen_if_label($<num>4); }
136| IF '(' Exp IfHandling')' Instr 136| IF '(' Exp IfHandling')' Instr
137 ELSE IfEndHandling Instr IfElseEndHandling 137 ELSE IfEndHandling Instr IfElseEndHandling
138| WHILE { fprintf(output,".upwhile%d:\n", num_while); } 138| WHILE { gen_while_start(num_while); }
139 '(' Exp { fprintf(output,"pop rax\ncmp rax,0\njz .downwhile%d\n", num_while); } 139 '(' Exp { gen_while_cond(num_while); }
140 ')' Instr { fprintf(output,"jmp .upwhile%d\n.downwhile%d:\n", num_while, num_while); num_while++; } 140 ')' Instr { gen_while_end(num_while++); }
141| '{' SuiteInstr '}' 141| '{' SuiteInstr '}'
142; 142;
143IfHandling: { gen_if_start($<num>$ = num_if++); }; 143IfHandling: { gen_if_start($<num>$ = num_if++); };