[antlr-interest] new user adapting java.g from antlr 2.7 for antlr 3.0.1

Jim Idle jimi at temporal-wave.com
Tue Apr 15 14:11:40 PDT 2008


I guess you didn't get my meaning last time, but basically if you are using the output=AST option (which you will be if generating a tree of course) then you cannot mix the ! and ^ operators with rewrite rules in the same rule, so something  like:

 

xx:

 i+= ID COMMA! i+=ID   ->^(IDSET $i+)

;

 

Will give you an error like that unless you remove the !. If you start adding -> instead of !^, then you must do it completely.

 

Jim

 

From: Doucette, Charles [mailto:cdoucette at vaultus.com] 
Sent: Tuesday, April 15, 2008 2:06 PM
To: Jim Idle; antlr-interest at antlr.org
Subject: RE: [antlr-interest] new user adapting java.g from antlr 2.7 for antlr 3.0.1

 

Using the java.g for 1.5, I could generate the parser just fine without any errors.

After I commented out most of it, and added the following extra rules:

 

vscript :
  // Next we have a series of zero or more import statements
//  ( importDefinition )*

 

  vscriptDeclaration*
  EOF!
  ;
  
  
vscriptDeclaration :
    actionDeclaration
  | newDeclaration
  ;
  
actionDeclaration :
 (/*actionType=*/Identifier ACTION /*actionName=*/Identifier? (FOR qualifiedName)?) /*actionBlock=*/block actionEpilogue?
// -> ^(ACTION $actionType $actionBlock $actionName? ^(FOR qualifiedName)? actionEpilogue?)
 ;
 
actionEpilogue :
   asBlock ifBlock?
 | ifBlock asBlock?
 ;
 
asBlock :
 AS^ block
 ;

 

ifBlock :
 IF^ block
 ;
 
newDeclaration :
 NEW^ type Identifier formalParameters? block
 ;

 

I got the following errors again:

 

[17:03:08] error(10):  internal error: C:\software\trunk\vsw\workspaces\eclipse\com.vaultus.studio.vscript.parser\src\com\vaultus\studio\vscript\parser\vscript1_5.g : java.lang.IllegalArgumentException: Can't find template tokenRefBang.st
org.antlr.stringtemplate.StringTemplateGroup.lookupTemplate(StringTemplateGroup.java:485)
org.antlr.stringtemplate.StringTemplateGroup.getInstanceOf(StringTemplateGroup.java:372)
org.antlr.stringtemplate.StringTemplateGroup.getInstanceOf(StringTemplateGroup.java:384)
org.antlr.codegen.CodeGenTreeWalker.getTokenElementST(CodeGenTreeWalker.java:160)
org.antlr.codegen.CodeGenTreeWalker.atom(CodeGenTreeWalker.java:1965)
org.antlr.codegen.CodeGenTreeWalker.element(CodeGenTreeWalker.java:1641)
org.antlr.codegen.CodeGenTreeWalker.element(CodeGenTreeWalker.java:1490)
org.antlr.codegen.CodeGenTreeWalker.alternative(CodeGenTreeWalker.java:1252)
org.antlr.codegen.CodeGenTreeWalker.block(CodeGenTreeWalker.java:1037)
org.antlr.codegen.CodeGenTreeWalker.rule(CodeGenTreeWalker.java:753)
org.antlr.codegen.CodeGenTreeWalker.rules(CodeGenTreeWalker.java:544)
org.antlr.codegen.CodeGenTreeWalker.grammarSpec(CodeGenTreeWalker.java:486)
org.antlr.codegen.CodeGenTreeWalker.grammar(CodeGenTreeWalker.java:333)
org.antlr.codegen.CodeGenerator.genRecognizer(CodeGenerator.java:406)
org.antlr.Tool.processGrammar(Tool.java:347)
org.antlr.Tool.process(Tool.java:268)
org.antlr.works.generate.CodeGenerate.generate(Unknown Source)
org.antlr.works.generate.CodeGenerate.run(Unknown Source)
java.lang.Thread.run(Unknown Source)

 

 

  _____  

From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Jim Idle
Sent: Tuesday, April 15, 2008 2:51 PM
To: antlr-interest at antlr.org
Subject: Re: [antlr-interest] new user adapting java.g from antlr 2.7 for antlr 3.0.1

It means that somewhere you are trying to use both rewrite rules '->' and auto tree building directives such as ! or ^ in a rule. Looks like this is in your atom: rule somewhere. This is an error that will be cleaned up in a future release.

 

However, you should download the 3.0/3.1 examples grammars and use the Java grammar there as this has been recently updated to be 1.5 compatible. 

 

Your other errors may be getting in the way too, regarding the m and t elements. Perhaps you still have m:rule instead of m=rule somewhere?

 

As I said though, abandoning what you have and using the 'official' java grammar for 3.1 (visit the downloads page and download the examples zip/tar)  would seem to be a better bet. You might also find the book a reasonable investment for your company: http://www.pragprog.com/titles/tpantlr

 

 

Jim

 

 

 

 

From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Doucette, Charles
Sent: Tuesday, April 15, 2008 11:29 AM
To: antlr-interest at antlr.org
Cc: Agranov, Gennady; George, Joseph
Subject: [antlr-interest] new user adapting java.g from antlr 2.7 for antlr 3.0.1

 

Our company's application development tool uses a scripting language which is very similar to Java (and ultimately generates Java).

I am writing a new editor for it - and the editor depends on a parser.

I am trying to use Antlr 3.0.1 to build a new parser for our language.

I was told to start with a Java 1.1 grammar - or perhaps 1.2, which I finally found in an old downloaded version of Antlr 2.7.

I manually performed the v2->v3 conversions necessary to get most of the grammar upgraded to v3.

Then I added a few of our language constructs. 

Anyhow, I am getting the following errors, and I'm not sure how to resolve them.

Could someone please help me resolve the errors?

 

Thanks,

Chuck

 

[13:59:17] error(114): C:\software\trunk\vsw\workspaces\eclipse\com.vaultus.studio.vscript.parser\src\com\vaultus\studio\vscript\parser\vscript.g:0:0: attribute is not a token, parameter, or return value: m
[13:59:17] error(117): C:\software\trunk\vsw\workspaces\eclipse\com.vaultus.studio.vscript.parser\src\com\vaultus\studio\vscript\parser\vscript.g:0:0: missing attribute access on rule scope: t
[13:59:17] error(10):  internal error: C:\software\trunk\vsw\workspaces\eclipse\com.vaultus.studio.vscript.parser\src\com\vaultus\studio\vscript\parser\vscript.g : java.lang.IllegalArgumentException: Can't find template tokenRefRuleRootTrack.st
org.antlr.stringtemplate.StringTemplateGroup.lookupTemplate(StringTemplateGroup.java:485)
org.antlr.stringtemplate.StringTemplateGroup.getInstanceOf(StringTemplateGroup.java:372)
org.antlr.stringtemplate.StringTemplateGroup.getInstanceOf(StringTemplateGroup.java:384)
org.antlr.stringtemplate.StringTemplateGroup.lookupTemplate(StringTemplateGroup.java:464)
org.antlr.stringtemplate.StringTemplateGroup.getInstanceOf(StringTemplateGroup.java:372)
org.antlr.stringtemplate.StringTemplateGroup.getInstanceOf(StringTemplateGroup.java:384)
org.antlr.codegen.CodeGenTreeWalker.getTokenElementST(CodeGenTreeWalker.java:160)
org.antlr.codegen.CodeGenTreeWalker.atom(CodeGenTreeWalker.java:1965)
org.antlr.codegen.CodeGenTreeWalker.element(CodeGenTreeWalker.java:1641)
org.antlr.codegen.CodeGenTreeWalker.element(CodeGenTreeWalker.java:1478)
org.antlr.codegen.CodeGenTreeWalker.element(CodeGenTreeWalker.java:1517)
org.antlr.codegen.CodeGenTreeWalker.alternative(CodeGenTreeWalker.java:1252)
org.antlr.codegen.CodeGenTreeWalker.block(CodeGenTreeWalker.java:1037)
org.antlr.codegen.CodeGenTreeWalker.ebnf(CodeGenTreeWalker.java:1804)
org.antlr.codegen.CodeGenTreeWalker.element(CodeGenTreeWalker.java:1637)
org.antlr.codegen.CodeGenTreeWalker.alternative(CodeGenTreeWalker.java:1252)
org.antlr.codegen.CodeGenTreeWalker.block(CodeGenTreeWalker.java:1037)
org.antlr.codegen.CodeGenTreeWalker.ebnf(CodeGenTreeWalker.java:1780)
org.antlr.codegen.CodeGenTreeWalker.element(CodeGenTreeWalker.java:1637)
org.antlr.codegen.CodeGenTreeWalker.alternative(CodeGenTreeWalker.java:1252)
org.antlr.codegen.CodeGenTreeWalker.block(CodeGenTreeWalker.java:1037)
org.antlr.codegen.CodeGenTreeWalker.rule(CodeGenTreeWalker.java:753)
org.antlr.codegen.CodeGenTreeWalker.rules(CodeGenTreeWalker.java:544)
org.antlr.codegen.CodeGenTreeWalker.grammarSpec(CodeGenTreeWalker.java:486)
org.antlr.codegen.CodeGenTreeWalker.grammar(CodeGenTreeWalker.java:333)
org.antlr.codegen.CodeGenerator.genRecognizer(CodeGenerator.java:406)
org.antlr.Tool.processGrammar(Tool.java:347)
org.antlr.Tool.process(Tool.java:268)
org.antlr.works.generate.CodeGenerate.generate(Unknown Source)
org.antlr.works.generate.CodeGenerate.run(Unknown Source)
java.lang.Thread.run(Unknown Source)

 


  _____  


Charles E. Doucette *  617-399-1122 *  Vaultus Mobile Technologies, 263 Summer St., Boston, MA 02210 *  http://www.vaultus.com <http://www.vaultus.com/>  

 



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080415/707d8729/attachment-0001.html 


More information about the antlr-interest mailing list