开发者

Implementation of ll(k) to ll(1) convertor !

is there any implementation开发者_如何转开发 of ll(k) to ll(1) convertor ?


IIRC; in general, no because some languages have ll(k) grammars but no ll(1) grammars. So unless I'm mistaken, not all ll(k) can be converted ll(1). However, that says nothing about the possibility of such a tool that will work the cases where it can be done.


the rule for left factoring is:

A := A B |
     A C |
     D |
     E ;

turns into:

A := (D | E) (B | C)*

or if you don't allow () groups and *:

A := D A'
     E A'

A' := B A' |
      C A' |
      nul ;

The trick becomes how to handle the translation of the action rules; if your language supports it, lambdas can be kinda handy there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜