I am confused by the following quote from Wikipedia:
In other words, if a language was reasonable enough to allow an efficient one-pass parser, it could be described by an LR(k) grammar. And that grammar could always be mechanically transformed into an equivalent (but larger) LR(1) grammar. So an LR(1) parsing method was, in theory, powerful enough to handle any reasonable language. In practice, the natural grammars for many programming languages are close to being LR(1).[citation needed]
This means that a parser generator, like bison
, is very powerful (since it can handle LR(k)
grammars), if one is able to convert a LR(k)
grammar to a LR(1)
grammar. Do some examples of this exist, or a recipe on how to do this? I'd like to know this since I have a shift/reduce conflict in my grammar, but I think this is because it is a LR(2)
grammar and would like to convert it to a LR(1)
grammar. Side question: is C++
an unreasonable language, since I've read, that bison
-generated parsers cannot parse it.