[antlr-interest] Need Help - Not able to use Java1.5 grammaravailable on site with ANTLRv3

Amol Neurgaonkar amol.neurgaonkar at gmail.com
Fri Jun 22 10:24:37 PDT 2007


Another point I would like to bring out is that when I open the grammar file
in ANTLRWorks , it throws errors on a few words in the file code as follows
-

1.
enumConstant : annotations? Identifier (arguments)? (classBody)?
On this line, it throws error on word 'annotations' saying : undefined
reference "annotations"

2.
integerLiteral :
HexLiteral | OctalLiteral | DecimalLiteral ; booleanLiteral : 'true' |
'false' ;
On this line, it throws error on word 'HexLiteral' saying : undefined
reference "HexLiteral "

3.Similar error is thrown for word 'forControl'
These are all related to the new features of Java 1.5 I suppose.

Thanks,
Amol.


On 6/22/07, Amol Neurgaonkar <amol.neurgaonkar at gmail.com> wrote:
>
> Hi,
>
> I tried to save the grammar file on disk and then run the ANTLRWorks on
> the file,
>
> Following is the error msg I get when running the 'Check Grammar' feature
> now -
>
>
> [10:05:34] Checking Grammar...
> [10:05:34] error(100): Java.txt:50:12: syntax error: antlr: Java.txt:50:12:
> unexpected token: ?
> [10:05:34] error(100): Java.txt:50:32: syntax error: antlr: Java.txt:50:32:
> unexpected token: ?
> [10:05:34] error(100): Java.txt:50:51: syntax error: antlr: Java.txt:50:51:
> unexpected token: *
> [10:05:34] error(100): Java.txt:50:68: syntax error: antlr: Java.txt:50:68:
> unexpected token: *
> [10:05:34] error(100): Java.txt:114:18: syntax error: antlr: Java.txt:114:18:
> unexpected token: ?
> [10:05:34] error(100): Java.txt:129:8: syntax error: antlr: Java.txt:129:8:
> unexpected token: block
> [10:05:34] error(100): Java.txt:129:34: syntax error: antlr: Java.txt:129:34:
> unexpected token: *
> [10:05:34] error(100): Java.txt:147:1: syntax error: antlr: Java.txt:147:1:
> unexpected token: forInit
> [10:05:34] error(100): Java.txt:166:6: syntax error: antlr: Java.txt:166:6:
> unexpected token: a
> [10:05:34] error(100): Java.txt:166:12: syntax error: antlr: Java.txt:166:12:
> unexpected token: pred
> [10:05:34] error(100): Java.txt:166:20: syntax error: antlr: Java.txt:166:20:
> unexpected token: check
> [10:05:34] error(100): Java.txt:166:33: syntax error: antlr: Java.txt:166:33:
> unexpected token: on
> [10:05:34] error(100): Java.txt:166:42: syntax error: antlr: Java.txt:166:42:
> unexpected token: >
> [10:05:34] error(100): Java.txt:194:18: syntax error: antlr: Java.txt:194:18:
> unexpected token: ?
> [10:05:34] error(106): Java.txt:103:60: reference to undefined rule:
> annotation
> [10:05:34] error(106): Java.txt:132:13: reference to undefined rule: block
> [10:05:34] error(106): Java.txt:137:30: reference to undefined rule: block
> [10:05:34] error(106): Java.txt:135:35: reference to undefined rule: block
> [10:05:34] error(106): Java.txt:109:43: reference to undefined rule: block
> [10:05:34] error(106): Java.txt:61:38: reference to undefined rule:
> annotations
> [10:05:34] error(106): Java.txt:97:1: reference to undefined rule:
> annotation
> [10:05:34] error(106): Java.txt:67:40: reference to undefined rule: block
> [10:05:34] error(106): Java.txt:135:61: reference to undefined rule: block
> [10:05:34] error(106): Java.txt:140:64: reference to undefined rule: block
> [10:05:34] error(106): Java.txt:136:11: reference to undefined rule: block
> [10:05:34] error(106): Java.txt:117:1: reference to undefined rule:
> annotation
> [10:05:34] warning(105): Java.txt:112:1: no lexer rule corresponding to
> token: HexLiteral
> [10:05:34] warning(200): Java.txt:197:24: Decision can match input such as
> "'0'..'9'{'E', 'e'}{'+', '-'}'0'..'9'{'D', 'F', 'd', 'f'}" using multiple
> alternatives: 3, 4
> As a result, alternative(s) 4 were disabled for that input
> [10:05:34] error(10):  internal error: org.antlr.tool.Message.toString(Unknown
> Source): Assertion failed! Message ID 100 created but is not present in
> errorMsgIDs or warningMsgIDs.
>
> Here is the line no 49 : (Note, the line is commented after }. I am not
> sure if the word 'compilationUnit' should also be part of the comment or
> not)
>
> *= true; } // starting point for parsing a java file compilationUnit : *
>
> which is followed by line no 50 as below where the first error is thrown:
>
> *annotations? packageDeclaration? importDeclaration* typeDeclaration* ;
> *
>
>
>
> The Grammar is still the same  (
> http://www.antlr.org/grammar/1152141644268/Java.g) , just that now instead
> of showing the full grammar in one line(when I used to copy directly from
> browser), now it shows in 221 lines. However, it gives the above error now.
>
>
>
> Thanks,
>
> Amol.
>
>
>
>  On 6/22/07, Amol Neurgaonkar <amol.neurgaonkar at gmail.com> wrote:
> >
> > Your understanding is correct. When I paste the Java1.5 grammar from
> > site ( http://www.antlr.org/grammar/1152141644268/Java.g) , the whole
> > grammar is copied
> > as a single line in the ANTLRWorks dialogue box.
> > When I run the 'Check Grammar' , it succeeds, however when I run
> > 'Generate Code' it throws following error.
> >
> > [19:04:25] Java.g:1:16360: unexpected char: ' '
> >  at org.antlr.tool.ANTLRLexer.nextToken(Unknown Source)
> >  at antlr.TokenStreamRewriteEngine.nextToken (
> > TokenStreamRewriteEngine.java :161)
> >  at antlr.TokenBuffer.fill(TokenBuffer.java:69)
> >  at antlr.TokenBuffer.LA(TokenBuffer.java:80)
> >  at antlr.LLkParser.LA(LLkParser.java:52)
> >  at org.antlr.tool.ANTLRParser.actions (Unknown Source)
> >  at org.antlr.tool.ANTLRParser.grammar (Unknown Source)
> >  at org.antlr.tool.Grammar.setGrammarContent(Unknown Source)
> >  at org.antlr.tool.Grammar.setGrammarContent(Unknown Source)
> >  at org.antlr.works.grammar.EngineGrammar.createNewGrammar (Unknown
> > Source)
> >  at org.antlr.works.grammar.EngineGrammar.createCombinedGrammar(Unknown
> > Source)
> >  at org.antlr.works.grammar.EngineGrammar.createGrammars(Unknown Source)
> >  at org.antlr.works.grammar.EngineGrammar.analyze (Unknown Source)
> >  at org.antlr.works.grammar.CheckGrammar.run(Unknown Source)
> >  at java.lang.Thread.run(Unknown Source)
> >
> > [19:04:25] error(100): C:\antlr3.0\Java.g:2:1: syntax error: antlr:
> > C:\antlr3.0\Java.g:2:1: unexpected token: null
> > [19:04:25] error(150):  grammar file C:\antlr3.0\Java.g has no rules
> > I have tried using other grammars for Java 1.5 listed in the Grammars
> > section, but they do not seem to succeed even for 'Check Grammar' feature.
> >
> > Thanks,
> > Amol.
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070622/ec226f5d/attachment-0001.html 


More information about the antlr-interest mailing list