Created
February 16, 2017 18:29
-
-
Save siscia/86c776015326eb2deff2270258abdf76 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exp IF exp ELSE exp { | |
if ($3.expression_type == IMMEDIATE){ | |
if ($3.value) { | |
$$ = $1; | |
} else { | |
$$ = $5; | |
} | |
} else { | |
t_axe_label* exit = newLabel(program); | |
t_axe_label* else_branch = newLabel(program); | |
gen_andb_instruction(program, $3.value, $3.value, $3.value, CG_DIRECT_ALL); | |
gen_beq_instruction(program, else_branch, 0); | |
$$ = $1; | |
gen_bt_instruction(program, exit, 0); | |
assignLabel(program, else_branch); | |
$$ = $5; | |
assignLabel(program, exit); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int b; | |
int a = 33; | |
int c = 44; | |
b = 3 if a > 0 else 0; | |
write(b); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment