[antlr-interest] Fundamental question on lexer rule ordering

Martin d'Anjou martin.danjou at neterion.com
Tue Feb 27 14:54:14 PST 2007


On Tue, 27 Feb 2007, John B. Brodie wrote:
> Greetings!
>
>> I must be missing something fundamental on lexer rule ordering, because I
>> keep running into the same problem over and over: re-ordering rules
>> changes the lexer from "working" to "failing", and I don't understand why.
>
> Is your Lexer in a separate .g file from your Parser (I seem to
> remember seeing an importvocab in one of your earlier parser
> postings)?
>
> If so, are you sure you are re-building the Parser after each change
> to the Lexer. Re-ordering the Lexer rules will change the Token Types
> assigned by the Lexer and thus the Parser needs to be rebuilt in order
> to adapt to those new assignments.

That was the problem. My makefile did not re-build the parser when the 
lexer changes (I guess the dependency is on the token file changing). I 
added a dependency to my parser rule and it fixed the problem.

Thanks!
Martin


More information about the antlr-interest mailing list