作者itchy (Lucky we love you.)
看板Prob_Solve
標題[請益] 有 compiler 達人嗎? Orz
時間Fri Jun 27 19:18:55 2008
這個問題我一直想不透. 痛苦極了啊~~ Orz (抓頭)
問題如下:
Assume G is an LR(0) grammar.
Let F --> ε be a production that is not currently in G.
Assume F is a nonterminal that is already in G.
Let G* be the new grammar obtained from G by inserting the new production
F --> ε. Describe the possible impacts (in the areas of conflicts,
expressive power and parsing complexities) of adding this new production.
========= 痛苦分隔線 ===============
我怎麼想都覺得不會有影響啊 (哭)
舉例來說, 若原本的 grammar:
E' --> E
E --> E + T
T --> T * F
F --> (E) | id
加了 ε的 grammar: (舉例來說)
E' --> E
E --> E + T | ε
T --> T * F
F --> (E) | id
則最後的 LR(0) sets 也不會變啊.
有誰知道到底有什麼影響嗎? Orz
頭髮都快抓光了 (繼續抓頭.. Q_Q)
大感謝 Orz
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.160.33.61
1F:推 Eventis:我很好奇耶,如果E,T這兩條都沒ε 06/28 08:45
2F:→ Eventis:要怎麼parse出id@@? 06/28 08:45
3F:→ Eventis:i.e. E'就只是一個id,沒有什麼加減乘除 06/28 08:46
4F:→ Eventis:或者,把原來的T->T*F拿掉,F->(E)|id換成T->(E)|id 06/28 08:47
5F:→ Eventis:那個ε很讓人又愛又恨的啊0.0 06/28 08:48