On 27 July 2010 21:17, Lukas Renggli <renggli(a)gmail.com> wrote:
[...]
#/ is an ordered choice, see the method comment of #/ and the class
comment of PPChoiceParser.
To summarize: #/ tries the first choice (the receiver): if that works
it returns the result without trying any other choice; if that doesn't
work, it backtracks and tries the next choice, and so on ...
I see. That's why it is important to write a good grammar:
Otherwise you would backtrack too often.
So, is it
correct that I have to put always the longest option in this cases?
Are there other approaches?
Not necessarily, you put first what has the highest priority.
You are right. I should rephrase my question in:
Is it correct to put always the longest option when the others
are a subset of it? :)
Note that the ordered choice #/ is similar, but not
exactly the same as the
unordered choice #| in traditional LR/LALR grammars.
This was probably my problem: I didn't get it.
Now it seems pretty clear. Thank you!
Ciao,
Alberto