diff options
author | pacien | 2018-06-06 15:10:11 +0200 |
---|---|---|
committer | pacien | 2018-06-06 15:10:11 +0200 |
commit | c0feca77799b859a5331417595ac0190bb999e0d (patch) | |
tree | 3e7b45d90ae8608949e1c67c8269f1aaa19412f6 /src/tpc.y | |
parent | 84c850e3a264d8bb1694c64348c445009b83b007 (diff) | |
download | tpc-compiler-c0feca77799b859a5331417595ac0190bb999e0d.tar.gz |
extract while instr
Diffstat (limited to 'src/tpc.y')
-rw-r--r-- | src/tpc.y | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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 | ; |
143 | IfHandling: { gen_if_start($<num>$ = num_if++); }; | 143 | IfHandling: { gen_if_start($<num>$ = num_if++); }; |