i feeling quite nostalgic i've decided write adventure game creator allows complex sentences entered user.
i have hand rolled lexer , parser uses visitor pattern , works quite well, until encountered left-recursion issue 1 of bnf rules:
object ::= {adjective} noun | object , {adjective} noun
after removing left-recursion by following wiki entry does right?
object ::= {adjective} noun object2 object2 :== , {adjective noun} | !empty
edited:
i hand rolling lexer , parser using c# following guide given here. not using parser generators exercise.
also, got bnf rules parser this website.
is there reason prefer left-recursion on right recursion in case? wouldn't simpler:
object ::= {adjective} noun | {adjective} noun , object
if want make solution work, need make object2
right-recursive:
object ::= {adjective} noun object2 object2 ::= , {adjective noun} object2 | !empty
Comments
Post a Comment