[antlr-interest] Runtime errors (I guess the hardest to fix)

John B. Brodie jbb at acm.org
Wed Jul 26 12:55:03 PDT 2006


herumor at fastwebnet.it asked:
>Hello everyone,
>I'm having the following errors on runtime.
>
>
>C:\Documents and
>Settings\spotted\Documenti\grammatica\codice_generato>java Easy
>Java
>Progetto realizzato da Davide Pugliese
>
>Inserire nome del file: test.txt
>
>line 1:1: unexpected token: public
>line 1:14: expecting IDENTIFIER, found 'pippo'
>line 1:22: expecting LCBRACK, found 'null'
>
>Esecuzione Terminata.
>
>Here you can find the grammar and the contents of the file what with I
>made the test:
>http://www.rafb.net/paste/results/gyyR5u38.html
>
>Thank you very much for help.

I think maybe the definitions for tokens is not in-sync between your parser
and your lexer.

You seem to be using separate files for each. Which is fine for v2.  But
---and my memory of this is hazy--- when you do that you should exportVocab
from the parser and then importVocab into the lexer *AND* ensure that you
build the parser before building the lexer.

or you could just use a single file containing both the parser and the
lexer and thereby avoid this problem...

also I note that on line 71 of the parser you refer to `Type` which is not
defined anywhere --- maybe it should be a reference to `type` ?

Hope this helps...
  --jbb


More information about the antlr-interest mailing list