| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 12756 | I2P(II)2020_Yang_Mini_Project_1 |
|
| 12766 | I2P(II)2020_Yang_Mini_Project_1_Bonus |
|
Description
You need to implement a calculator which prints assembly code.
The input is a list of expressions consisting of:
- Integers
- Operators (+, -, *, /, =, &, |, ^, ++, --)
- Three built-in variables x, y, z (exist in the beginning)
- Some new local variables
The output is a list of assembly code.
You should merge all your header files and code into a single file to submit.
You should parse the input according to the grammar below:
expr := term expr_tail
expr_tail := ADDSUB_LOGICAL term expr_tail | NiL
term := factor term_tail
term_tail := MULDIV factor term_tail | NiL
factor := INT | ADDSUB INT |
ID | ADDSUB ID |
INCDEC ID | ID ASSIGN expr |
LPAREN expr RPAREN |
ADDSUB LPAREN expr RPAREN
Input
The input contains mutiple expressions. Each expression is separated by a newline character ('\n').
The initial value of x, y, and z are stored in memory [0], [4], and [8] respectively.
If a new variable first appear in the left hand side of an assign (=) , it is valid and can be use in the future.
If a new variable first appear in the right hand side of an assign (=) , it is invalid and the output should be EXIT 1
Some test cases contains syntax errors, make sure you handle them properly.
Output
You should output a list of assembly code according to the input.
After printing the assembly code, make sure you have stored the answer of the variables x, y, z in registers r0, r1, and r2 respectively.
If the expression is legal, remember to print "EXIT 0" on the last line.
If the expression is illegal, your final output should be "EXIT 1". That is, if the expression is illegal, you don't have to store the value of x, y, z into the registers.
There must be a newline character ('\n') at the end of your output.
Note: This time we use special judge, and your answer doesn't need to be as same as the sample output. You just need to ensure the final values which are stored in registers r0, r1, and r2 (the value of variables x, y, and z) are correct.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
This is the bonus problem.
Please make sure that the code which you submit here is identical to the code you submit to the problem "12756 - I2P(II)2020_Yang_Mini_Project_1"
You need to implement a calculator which prints assembly code.
The input is a list of expressions consisting of:
- Integers
- Operators (+, -, *, /, =, &, |, ^, ++, --)
- Three built-in variables x, y, z (exist in the beginning)
- Some new local variables
The output is a list of assembly code.
You should merge all your header files and code into a single file to submit.
You should parse the input according to the grammar below:
expr := term expr_tail
expr_tail := ADDSUB_LOGICAL term expr_tail | NiL
term := factor term_tail
term_tail := MULDIV factor term_tail | NiL
factor := INT | ADDSUB INT |
ID | ADDSUB ID |
INCDEC ID | ID ASSIGN expr |
LPAREN expr RPAREN |
ADDSUB LPAREN expr RPAREN
Input
The input contains mutiple expressions. Each expression is separated by a newline character ('\n').
The initial value of x, y, and z are stored in memory [0], [4], and [8] respectively.
If a new variable first appear in the left hand side of an assign (=) , it is valid and can be use in the future.
If a new variable first appear in the right hand side of an assign (=) , it is invalid and the output should be EXIT 1
Some test cases contains syntax errors, make sure you handle them properly.
Output
You should output a list of assembly code according to the input.
After printing the assembly code, make sure you have stored the answer of the variables x, y, z in registers r0, r1, and r2 respectively.
If the expression is legal, remember to print "EXIT 0" on the last line.
If the expression is illegal, your final output should be "EXIT 1". That is, if the expression is illegal, you don't have to store the value of x, y, z into the registers.
There must be a newline character ('\n') at the end of your output.
Note: This time we use special judge, and your answer doesn't need to be as same as the sample output. You just need to ensure the final values which are stored in registers r0, r1, and r2 (the value of variables x, y, and z) are correct.