Re: [徵求] 編譯程式設計達人...高手...神人...
看板C_and_CPP (C/C++)作者lisztbach (liszt & bach)時間18年前 (2007/01/10 09:09)推噓3(3推 0噓 9→)留言12則, 3人參與討論串1/1
※ 引述《mosquito520 (賣頻寬控制分享器)》之銘言:
: 4. 針對下面的文法建立其LR(1) Parsing Table
: 1. E -> E+T
: 2. E -> T
: 3. T -> T*F
: 4. T -> F
: 5. F -> (E)
: 6. F -> id
: 這個我同學說可能會寫到幹古....
我只會這一題
至於答案對不對
呵呵 您可能要檢查過一次...或兩次....^^"
E -> ‧E+T
E -> ‧T
T -> ‧T*F
T -> ‧F
F -> ‧(E)
F -> ‧id
State 0
E -> ‧E+T, {+};
E -> ‧T, {+};
T -> ‧T*F, {+*};
T -> ‧F, {+*};
F -> ‧(E), {+*};
F -> ‧id, {+*};
經由 E 到 State 1
經由 T 到 State 2
經由 F 到 State 3
經由 ( 到 State 4
經由 id 到 State 5
State 1
E -> E‧+T, {+};
經由 + 到 State 6
State 2
E -> T‧, {+};
T -> T‧*F, {+*};
經由 * 到 State 7
State 3
T -> F‧, {+*};
State 4
F -> (‧E), {+*};
E -> ‧E+T, {)+};
E -> ‧T, {)+};
T -> ‧T*F, {)+*};
T -> ‧F, {)+*};
F -> ‧(E), {)+*};
F -> ‧id, {)+*};
經由 E 到 State 8
經由 T 到 State 9
經由 F 到 State 10
經由 ( 到 State 11
經由 id 到 State 12
State 5
F -> id‧, {+*};
State 6
E -> E+‧T, {+};
T -> ‧T*F, {λ+*};
T -> ‧F, {λ+*};
F -> ‧(E), {λ+*};
F -> ‧id, {λ+*};
經由 T 到 State 13
經由 F 到 State 14
經由 ( 到 State 15
經由 id 到 State 16
State 7
T -> T*‧F, {+*};
F -> ‧(E), {+*};
F -> ‧id, {+*};
經由 F 到 State 17
經由 ( 到 State 4
經由 id 到 State 5
State 8
F -> (E‧), {+*};
E -> E‧+T, {)+};
經由 ) 到 State 18
經由 + 到 State 19
State 9
E -> T‧, {)+};
T -> T‧*F, {)+*};
經由 * 到 State 20
State 10
T -> F‧, {)+*};
State 11
F -> (‧E), {)+*};
E -> ‧E+T, {)+};
E -> ‧T, {)+};
T -> ‧T*F, {)+*};
T -> ‧F, {)+*};
F -> ‧(E), {)+*};
F -> ‧id, {)+*};
經由 E 到 State 21
經由 T 到 State 9
經由 F 到 State 10
經由 ( 到 State 11
經由 id 到 State 12
State 12
F -> id‧, {)+*};
State 13
E -> E+T‧, {+};
T -> T‧*F, {λ+*};
經由 * 到 State 22
State 14
T -> F‧, {λ+*};
State 15
F -> (‧E), {λ+*};
E -> ‧E+T, {)+};
E -> ‧T, {)+};
T -> ‧T*F, {)+*};
T -> ‧F, {)+*};
F -> ‧(E), {)+*};
F -> ‧id, {)+*};
經由 E 到 State 23
經由 T 到 State 9
經由 F 到 State 10
經由 ( 到 State 11
經由 id 到 State 12
State 16
F -> id‧, {λ+*};
State 17
T -> T*F‧, {+*};
State 18
F -> (E)‧, {+*};
State 19
E -> E+‧T, {)+};
T -> ‧T*F, {)+*};
T -> ‧F, {)+*};
F -> ‧(E), {)+*};
F -> ‧id, {)+*};
經由 T 到 State 24
經由 F 到 State 10
經由 ( 到 State 11
經由 id 到 State 12
State 20
T -> T*‧F, {)+*};
F -> ‧(E), {)+*};
F -> ‧id, {)+*};
經由 F 到 State 25
經由 ( 到 State 11
經由 id 到 State 12
State 21
F -> (E‧), {)+*};
E -> E‧+T, {)+};
經由 ) 到 State 26
經由 + 到 State 19
State 22
T -> T*‧F, {λ+*};
F -> ‧(E), {λ+*};
F -> ‧id, {λ+*};
經由 F 到 State 27
經由 ( 到 State 15
經由 id 到 State 16
State 23
F -> (E‧), {λ+*};
E -> E‧+T, {)+};
經由 ) 到 State 28
經由 + 到 State 19
State 24
E -> E+T‧, {)+};
T -> T‧*F, {)+*};
經由 * 到 State 20
State 25
T -> T*F‧, {)+*};
State 26
F -> (E)‧, {)+*};
State 27
T -> T*F‧, {λ+*};
State 28
F -> (E)‧, {λ+*};
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.62.97.25
推
01/10 12:14, , 1F
01/10 12:14, 1F
→
01/10 12:15, , 2F
01/10 12:15, 2F
→
01/10 12:16, , 3F
01/10 12:16, 3F
→
01/10 12:17, , 4F
01/10 12:17, 4F
→
01/10 12:17, , 5F
01/10 12:17, 5F
→
01/10 12:18, , 6F
01/10 12:18, 6F
→
01/10 12:18, , 7F
01/10 12:18, 7F
→
01/10 12:18, , 8F
01/10 12:18, 8F
推
01/10 15:50, , 9F
01/10 15:50, 9F
→
01/10 15:52, , 10F
01/10 15:52, 10F
推
01/11 08:48, , 11F
01/11 08:48, 11F
→
01/11 08:48, , 12F
01/11 08:48, 12F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章