Rick Mann wrote:
Hi. I'm trying to follow the instructions for building a code  
generation target here:

http://www.antlr.org/wiki/display/ANTLR3/How+to+build+an+ANTLR+code+generation+target

Mostly to experiment with ANTLR from a different perspective, and  
maybe to do something useful. However, one step isn't very clear:

"I recommend building the ANTLR tool 'in place'. Do not create a jar  
or compile/copy to a build directory. When you run it with 'java -cp  
path-to-src-dir ...' it will use the original *.stg file, which you'll  
edit a lot - so rebuilding the tool would be quite a PITA."

I'm not really sure what that means. I built ANTLR with "ant build",  
and when I try running as the step suggests, well, I can't get the  
classpath right, and I'm not sure how that ties into the .stg files.

$ java -cp build/classes:build/rtclasses/:lib/stringtemplate-3.2.jar  
org.antlr.Tool
Exception in thread "main" java.lang.NoClassDefFoundError: antlr/ 
TokenStream
	at org.antlr.tool.ErrorManager.setLocale(Unknown Source)
	at org.antlr.tool.ErrorManager.<clinit>(Unknown Source)
	at org.antlr.Tool.main(Unknown Source)

Would someone please clarify? Thanks!


  
This is outdated really. What it means is that Ter is recommending you just run the javac compiler against all the sources so that you get the .class file next to the .java file. Then you can run the ANTLR tool setting the cclasspath appropriately.

However, this whole process is now greatly aided by the Maven configuration as it builds a jar that includes all the dependencies and htat you can just run with:

java -jar ~/.m2/path/to/jar

When you change your template or codegen target java file, you just type:

mvn

And it rebuilds just what has changed in a second or two (depends on your machine speed of course).

All you need do is download and install Maven 2.0.9 on your system and make sure that the mvn command is in your path. Then download the source for ANTLR from the Fisheye system (just get the tar of the antlr tool directory) and cd to the directory containing pom.xml.

Type:

mvn -Dmaven.test.skip=true

And watch the output to see where it puts the jar-with-dependencies. Create your self a small script that invokes this jar and you are all set.

Personally I use Netbeans 6.5 and tell it to install the Maven plugin in. With that, you just open a project, navigate to the source directory and you will see that Netbeans then knows everything about the project and will build it, run regression tests and so on. I am pretty sure that Eclipse and Intellij can do the same.

Jim



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Reply via email to