![]() | Testrig tokens startRuleName option not working |
|
25 Sep 2012, 06:15
Luke Krasnoff (5 posts) |
Hi, I am trying to run the XML sample from the book (Cool Lexical Features p51). The “tokens” startRuleName option of the Testrig is looking for a XMLParser. Is there a bug with Testrig, or is the lexer grammar incorrect? I am using ANTLR Parser Generator Version 4.0b1. alias antlr4=’java -jar /usr/local/lib/antlr-4.0b1-complete.jar’ beetle:test luke$ antlr4 XML.g4 |
|
25 Sep 2012, 18:23
Terence Parr (33 posts) |
Sorry about that Luke. I saw that bug myself the other day. I will be posting b2 software soon. Can I email you a new jar? you can mail me directly at parrt@antlr.org |
|
26 Sep 2012, 00:26
Luke Krasnoff (5 posts) |
Hi Terence, Thanks for the reply. That would be great if you could send me the new jar. I am really enjoying reading “The Definitive Antlr 4 Reference”. I’ve read the previous version of this book (covering Antlr3) and the “Language Implementation Patterns”. Antlr4 is covering a traditionally difficult subject, in an easy and very digestible manner. To coin a phrase similar to Will Ferrell’s character Darren in Bewitched – “Make me 20 parsers and bring me the best one!”. Cheers, |
|
14 Dec 2012, 22:33
Oleksandr Kalentev (2 posts) |
Hi Terence, I use antlr-4.0b3 version and have the same issue: $ grun Hello r -tokens Exception in thread “main” java.lang.ClassNotFoundException: Hello at java.net.URLClassLoader$1.run(URLClassLoader.java:217) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:266) at org.antlr.v4.runtime.misc.TestRig.main(TestRig.java:148) |
|
15 Dec 2012, 09:40
Dmitry Maslennikov (3 posts) |
need to add ”.” in CLASSPATH |
|
15 Dec 2012, 22:42
Oleksandr Kalentev (2 posts) |
$ echo $CLASSPATH .:/usr/local/lib/antlr-4.0b3-complete.jar: |
|
03 May 2013, 16:13
Romeo Lupascu (3 posts) |
May I have the new build too? I’m encountering same issue with the default build from the site. I’ve tried to build from source but there are too many maven dependencies missing in my env. and have no time to debug the build. Thanks |
|
03 May 2013, 16:14
Romeo Lupascu (3 posts) |
One more detail, I’m on Ubuntu 10 LTS… |
|
07 May 2013, 19:52
Romeo Lupascu (3 posts) |
OK, no need for new build, the condition is to have ”.” in the CLASSPATH as the class loader needs to dynamically find the compiled lexer or parser (as Dimitry above pointed out). Also one needs to always provide the lexer/parser root name. This means that “grun” will throw an exception when called without any command line params. The confusion comes from this piece of code in the TestRig class: try {
lexerClass = cl.loadClass(lexerName).asSubclass(Lexer.class); Where because of the assumption that the “cl.loadClass(lexerName)” will throw a ClassNotFound exception, however when run, it in fact will throw a NullPointerException Exception in thread “main” java.lang.NullPointerException at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:351) at java.lang.ClassLoader.loadClass(ClassLoader.java:626) at org.antlr.v4.runtime.misc.TestRig.process(TestRig.java:157) at org.antlr.v4.runtime.misc.TestRig.main(TestRig.java:142) rendering the catch clause unusable and so skipping the intended error message. Checking the class loader (cl) and the loaded class for null should avoid this defect. |
| You must be logged in to comment |

