[antlr-interest] stuck on templates

Gavin Lambert antlr at mirality.co.nz
Mon Aug 27 13:17:42 PDT 2007


At 06:51 28/08/2007, Warner Onstine wrote:
 >error(100):
 >C:\java\projects\chama-antlr2\src\main\antlr\Model.g:19:1:
 >syntax error: antlr:
 >C:\java\projects\chama-antlr2\src\main\antlr\Model.g:19:1:
 >expecting COLON, found 'prog'

Well, it's right.  A snippet from your grammar file:

 >program
 >scope {
 >  List methods;
 >  List imports;
 >}
 >@init {
 >  $program::methods = new ArrayList();
 >  $program::imports = new ArrayList();
 >}
 >
 >prog	:	packageDecl importsDecl? model
 >	;

You're starting out declaring the 'program' rule but never finish 
it, then start declaring the 'prog' rule in the middle of it.

Either merge the two rules or convert 'program' into a global 
scope instead of a rule.



More information about the antlr-interest mailing list