[antlr-interest] gunit tree testsuite can't find the group template file

Stanislas Rusinsky rusinskystanislas at yahoo.fr
Sat Jul 5 09:09:42 PDT 2008


Hello all, 

(I almost wrote "hello ANTLeRs"... happily babelfish saved me from my french ignorance of english subtleties)


The problem: I have a text grammar and a tree grammar. 

The tree grammar has its group template file loaded with these commands:
        FileReader groupFileR = new FileReader("treeKoRuGenClasses.stg"); 
        StringTemplateGroup templates = new StringTemplateGroup(groupFileR); 
        groupFileR.close(); 
        walker.setTemplateLib(templates); // where to find templates

Running the tree parser works like a charm with this code.

The gunit testsuite works fine with the text grammar, but the tree grammar gunit testsuite complains it can't "find template entity_modifiers.st; group hierarchy is [treeKoRuGenClassesTemplates]".
The path includes the directory containing the template group file.

I have tried renaming my .stg file to treeKoRuGenClassesTemplates.stg as suggested by the trace, changing also the first line to "group treeKoRuGenClassesTemplates;" but nothing helped, I still get the stacktrace (see below).

It seems the java class generated from the tree sets a default empty template group ( protected StringTemplateGroup templateLib = new StringTemplateGroup("treeKoRuGenClassesTemplates", AngleBracketTemplateLexer.class); ). Should I use a streamreader in my treeKoRuGenClasses.g to read the stg group file and set it with some sort of "this.setTemplateLib(myTemplateGroupFileStream)" ? 

Anyone could give me some advice, hint, or broaden my vision on this subject?

Thanks in advance,

Stanislas Herman Rusinsky.

test-tree:
     [java] java.lang.reflect.InvocationTargetException
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java]     at java.lang.reflect.Method.invoke(Method.java:585)
     [java]     at org.antlr.gunit.gUnitExecuter.runTreeParser(gUnitExecuter.java:392)
     [java]     at org.antlr.gunit.gUnitExecuter.runCorrectParser(gUnitExecuter.java:133)
     [java]     at org.antlr.gunit.gUnitExecuter.executeTests(gUnitExecuter.java:149)
     [java]     at org.antlr.gunit.gUnitExecuter.execTest(gUnitExecuter.java:92)
     [java]     at org.antlr.gunit.Interp.main(Interp.java:62)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java]     at java.lang.reflect.Method.invoke(Method.java:585)
     [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217)
     [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152)
     [java]     at org.apache.tools.ant.taskdefs.Java.run(Java.java:747)
     [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:201)
     [java]     at org.apache.tools.ant.taskdefs.Java.execute(Java.java:104)
     [java]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java]     at java.lang.reflect.Method.invoke(Method.java:585)
     [java]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
     [java]     at org.apache.tools.ant.Task.perform(Task.java:348)
     [java]     at org.apache.tools.ant.Target.execute(Target.java:357)
     [java]     at org.apache.tools.ant.Target.performTasks(Target.java:385)
     [java]     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
     [java]     at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
     [java]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
     [java]     at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
     [java]     at org.apache.tools.ant.Main.runBuild(Main.java:698)
     [java]     at org.apache.tools.ant.Main.startAnt(Main.java:199)
     [java]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
     [java]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
     [java] Caused by: java.lang.IllegalArgumentException: Can't find template entity_modifiers.st; group hierarchy is [treeKoRuGenClassesTemplates]
     [java]     at org.antlr.stringtemplate.StringTemplateGroup.lookupTemplate(StringTemplateGroup.java:507)
     [java]     at org.antlr.stringtemplate.StringTemplateGroup.getInstanceOf(StringTemplateGroup.java:392)
     [java]     at org.antlr.stringtemplate.StringTemplateGroup.getInstanceOf(StringTemplateGroup.java:404)
     [java]     at org.antlr.stringtemplate.StringTemplateGroup.getInstanceOf(StringTemplateGroup.java:412)
     [java]     at com.mindspark.koru.treeKoRuGenClasses.entity_modifiers(Unknown Source)
     [java]     at com.mindspark.koru.treeKoRuGenClasses.entity(Unknown Source)
     [java]     at com.mindspark.koru.treeKoRuGenClasses.koru(Unknown Source)
     [java]     ... 35 more
     [java] org.apache.tools.ant.ExitException: Permission (java.lang.RuntimePermission exitVM) was not granted.
     [java]     at org.apache.tools.ant.types.Permissions$MySM.checkExit(Permissions.java:174)
     [java]     at java.lang.Runtime.exit(Runtime.java:88)
     [java]     at java.lang.System.exit(System.java:869)
     [java]     at org.antlr.gunit.gUnitExecuter.runTreeParser(gUnitExecuter.java:460)
     [java]     at org.antlr.gunit.gUnitExecuter.runCorrectParser(gUnitExecuter.java:133)
     [java]     at org.antlr.gunit.gUnitExecuter.executeTests(gUnitExecuter.java:149)
     [java]     at org.antlr.gunit.gUnitExecuter.execTest(gUnitExecuter.java:92)
     [java]     at org.antlr.gunit.Interp.main(Interp.java:62)


      _____________________________________________________________________________ 
Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr



      _____________________________________________________________________________ 
Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr


More information about the antlr-interest mailing list