[antlr-interest] keywords

John B. Brodie jbb at acm.org
Fri Aug 4 08:20:51 PDT 2006


Abhijit :-

You wrote:
>Hi John,
>	I put all my keywords in the tokens section. Now its giving me
>this error:
>
>unexpected char: 'i'
>
>at position of if statement. I tried to debug in Antlr Studio, the
>control enters the assignmentstmnt instead of the ifstmnt and throws the
>error.

Hi!

I do not use Antlr Studio so I can't help you interpret what it is
trying to tell you.

Do you have your lexer and parser in separate files? if so, the token
numbers expected by the parser may not be what the lexer is generating
- this is a common problem with separated grammars. my memory of this
is fuzzy, but if you have separate lexer/parser then you should have
two *TokenTypes.txt files - 1 for the parser and 1 for the lexer - the
numbers in these should match. if this is your problem you should read
the docs about import/export vocab options.

Other than that, I can not really give any more advice about your
problem without more information.

Have you tried building and then running your grammar using the
antlr.Tool's -trace switch? -trace will give you copious output
regarding the sequencing of rule application.

If the -trace doesn't help you locate the problem, then please post
the smallest possible grammar that still has the problem and we'll try
to help get it fixed.

Hope this helps...
   -jbb


More information about the antlr-interest mailing list