> >>>> I do not understand why lemon waits for one more token when it has 
> >>>> enough information to reduce
...
> >>>>
> >>> I don't think you can.  Why do you want to?  Why not just go
> >>> ahead and send it the next token?
> >>>
> >> Most people find a way around this problem using white-space. This
> >> could be a solution but then my grammar will be filled with
> >> "white-space | nothing" rules and I thought Lemon could reduce when
> >> there is no other way out of the current stack as it is more elegant.
> >>
> >>
> LA(LR) is the answer - just drop Your's tokens as their arrive and give
> a chance for the parser to be LALR, not LR or SLR :)
>
> mak
>
Lookahead improves what we can do with a grammar, but when there is no
ambiguity, it should resolve without waiting for the next token. If
your grammar is so simple it's an SLR, why not treat it so and ease
the creation of grammars without needing to add "separator" tokens
just so there is a lookahead (most languages use ";" or white space
for that purpose).

My grammar works with all "whitespace or nothing" rules, but I have to
be careful to avoid conflicts. When I write it without the whitespace
stuff (eaten in the tokenizer), I have no conflict. Simple example:
main     ::= commands.
commands ::= .
commands ::= commands ws command.
command  ::= variable EQUAL value.
variable ::= ws IDENTIFIER ws.
value    ::= ws NUMBER ws.
ws       ::= .
ws       ::= WHITE.
> 2 parsing conflicts.

Whithout whitespace stuff:
main     ::= commands.
commands ::= .
commands ::= commands command.
command  ::= variable EQUAL value.
variable ::= IDENTIFIER.
value    ::= NUMBER.
> no conflicts, easier and cleaner.

I know how to fix the first grammar, but you have to think of the
actual succession to avoid two "ws" from coming next to the other,
this thinking is not really related to the grammar from my point of
view.

Gaspard

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to