P6
姓名:田昊东 学号:211275022
编译原理作业 p 6¶
5.4.3
^66c40d
- 取
g(x,y)=2*x+y
- 由此依据公式消除左递归
\[
B\to1\{R.i=1\}R\{B.val=R.s\}\\
R\to 1\{R1.i=g(R.i,1)\}R_1\{R.s=R_1.s\}\\
R\to 0\{R1.i=g(R.i,0)\}R_1\{R.s=R_1.s\}\\
R\to \varepsilon\{R.s=R.i\}
\]
6.1.2
^f11a36
6.2.2
^a55c5f
a = b[i] + c[j]
- 四元式:
op | arg1 | arg2 | result |
---|---|---|---|
=[] | b | i | t1 |
=[] | c | j | t2 |
+ | t1 | t2 | t3 |
= | t3 | a |
- 三元式:
op | arg1 | arg2 | |
---|---|---|---|
0: | =[] | b | i |
1: | =[] | c | j |
2: | + | (0) | (1) |
3: | = | a | (2) |
a[i] = b*c - b*d
- 四元式:
op | arg1 | arg2 | result |
---|---|---|---|
* | b | c | t1 |
* | b | d | t2 |
- | t1 | t2 | t3 |
[]= | a | i | t4 |
= | t3 | t4 |
- 三元式:
op | arg1 | arg2 | |
---|---|---|---|
0: | * | b | c |
1: | * | b | d |
2: | - | (0) | (1) |
3: | [] | a | i |
4: | = | (3) | (2) |