[antlr-interest] convert an old ANTLR v2 grammar to ANTLR v3:-

Johannes Luber jaluber at gmx.de
Thu Aug 7 03:44:14 PDT 2008


faraz ahmed schrieb:
> I'm struggling to convert an old ANTLR v2 grammar to ANTLR v3.  I'm 
> a newbie .ANTLR reports errors:-
> could any body help me to fix those errors:-
> ANTLR Parser Generator  Version 3.1b1 (May 20, 2008)  1989-2008
> error(100): ANTLRSyntax100.g:3:1: syntax error: antlr: 
> ANTLRSyntax100.g:3:1: unexpected token:
>   import java.io.*;
>   import antlr.*;
>   import uk.ac.sheffield.dcs.dfa.*;
>   import uk.ac.sheffield.dcs.dfa.spec.*;
> warning(149): ANTLRSyntax100.g:0:0: rewrite syntax or operator with no 
> output option; setting output=AST
> error(150):  grammar file ANTLRSyntax100.g has no rules
> error(100): ANTLRSyntax100.g:0:0: syntax error: assign.types: <AST>:0:0: 
> unexpected end of subtree
> error(100): ANTLRSyntax100.g:0:0: syntax error: define: <AST>:0:0: 
> unexpected end of subtree
>  
> I can't understand what ANTLR doesn't like.  The grammar is  
> attached.  Any help appreciated!
> faraz

ANTLR requires now to mark certain sections with keywords, unlike its 
predecessor (also they have to come in a specific order). Please refer 
to the wiki documentation or the ANTLR book regarding the specifics. 
Reading the book is a good idea if you are unfamiliar with compilers and 
compiler generators in general. I've also added a tokenVocab option, 
which you have to adapt to the used lexer grammar (e.g. lexer grammar is 
MyLexer.g, then tokenVocab=MyLexer;). Otherwise ANTLR will complain 
about missing rules.

Johannes
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ANTLRSyntax100.g
Url: http://www.antlr.org/pipermail/antlr-interest/attachments/20080807/a112ba94/attachment.pl 


More information about the antlr-interest mailing list