[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shift/reduce conflict



> As you can see from the above the #define statement ends optionally with
> an integer literal but the resource statement can start with an integer
> literal. So there is a shift/reduce conflict.
> 
> How do experienced parser creators solve that conflict? I have no idea
> what I can do here, as the only differencing item I can see is the new
> line character (which is an ignored token in my grammar).

Hi Mike,

I'm not an experienced parser creator, but I think you shouldn't add newline
characters to your ignored tokens. Instead, adjust your grammar to require
every line in the input to end with a newline character (or, alternatively,
require your complete input to constist of lines alternating with newline
characters).

-- 
Martijn Vermaat

Student Computer Science                            www.cs.vu.nl/~mvermaat
Vrije Universiteit, Amsterdam                            mvermaat@cs.vu.nl