如何删除以下语法中的左递归?
S -> “url” “(“ STRING “)” // basic services
| S “?” S // sequential execution
| S “|” S // concurrent execution
| “timeout” “(“ REAL “,” S “)” // timeout combinator
| “repeat” “(“ S “)” // repetition
| “stall” // nontermination
| “fail” // failure
答案 0 :(得分:0)
诀窍是创建一个正确递归的父作品。
T -> S
T -> S "?" T // sequential execution
T -> S "|" T // concurrent execution
S -> “url” “(“ STRING “)” // basic services
| “timeout” “(“ REAL “,” S “)” // timeout combinator
| “repeat” “(“ S “)” // repetition
| “stall” // nontermination
| “fail” // failure
这将识别同一组输入,但要注意T现在是右关联的,而不是左关联的。