The ANTLRWorks debugger should work fine with your tree grammar. If I recall correctly, you need to use the ANTLR code generation tool with the "-debug" flag (I'm using the Java target), then, where you create your tree parser instance, use the debug constructor that takes a port as an argument. In my case, the default port didn't work, so I arbitrarily picked 35505 Fire up ANTLRWorks, open your tree grammar, click "Run"->"Debug Remote...", set the port to the same value used in the constructor for your tree parser, and you should be able to connect the debugger to your running application.
See the ANTLR 3 Debugging FAQ for details Update Assuming you're using the Java target (let us know if that's not the case), here's more detailed information on getting started: When you're testing your non-tree parser in ANTLRWorks, there's a behind-the-scenes process that generates Java code from your grammar file, then uses that code to parse your input. When you use your parser in your own application, you have to use ANTLR (specifically, the class org.antlr. Tool ) to generate Java code that you can then include in your application.
ANTLRWorks has a menu option for this, which should get you started. In my case, I have a target in my ant build file that generates the Java code from my grammars and puts those Java source files in a place where the rest of my application can find them. My ant target looks something like this: java classpath="${antlr.tool.
Classpath}" classname="org.antlr. Tool" failonerror="true"> Dir which in this example would be build/antlr/src ) As far as using the generated code in your application (i.e. , outside ANTLRWorks), you'll need to do something like: String sourceText = "a + be = foo"; ANTLRStringStream inStream = new ANTLRStringStream(sourceText); // your generated lexer class MyLexer lexer = new MyLexer(inStream); CommonTokenStream tokens = new CommonTokenStream(lexer); // your generated parser class MyParser parser = new MyParser(tokens); // run the toplevel rule (in this case, `program`) MyParser.
Program_return prog = parser.program(); // get the resulting AST (a CommonTree instance, in this case) CommonTree tree = (CommonTree) prog.getTree(); // run a tree parser rule on the AST MyTreeParser treeParser = new MyTreeParser(new CommonTreeNodeStream(tree)); treeParser.program() I strongly recommend getting a copy of The Definitive ANTLR Reference if you're going to be using ANTLR. All of this is covered pretty thoroughly, with plenty of examples to get you started.
The ANTLRWorks debugger should work fine with your tree grammar. If I recall correctly, you need to use the ANTLR code generation tool with the "-debug" flag (I'm using the Java target), then, where you create your tree parser instance, use the debug constructor that takes a port as an argument. In my case, the default port didn't work, so I arbitrarily picked 35505.
Fire up ANTLRWorks, open your tree grammar, click "Run"->"Debug Remote...", set the port to the same value used in the constructor for your tree parser, and you should be able to connect the debugger to your running application. See the ANTLR 3 Debugging FAQ for details. Update Assuming you're using the Java target (let us know if that's not the case), here's more detailed information on getting started: When you're testing your non-tree parser in ANTLRWorks, there's a behind-the-scenes process that generates Java code from your grammar file, then uses that code to parse your input.
When you use your parser in your own application, you have to use ANTLR (specifically, the class org.antlr. Tool) to generate Java code that you can then include in your application. ANTLRWorks has a menu option for this, which should get you started.In my case, I have a target in my ant build file that generates the Java code from my grammars and puts those Java source files in a place where the rest of my application can find them.
My ant target looks something like this: The property antlr.tool. Classpath needs to contain stringtemplate. Jar and antlr.
Jar, and antlr.out. Dir needs to point to the directory where you want the generated source code to go (e.g. , build/antlr/src/org/myorg/antlr/parser, if your parser grammars specify the package org.myorg.antlr. Parser).
Then, when you compile the rest of your application, you can use something like: Here, we compile our application sources (in src. Dir) along with the generated ANTLR code (in antlr.src. Dir, which in this example would be build/antlr/src).
As far as using the generated code in your application (i.e. , outside ANTLRWorks), you'll need to do something like: String sourceText = "a + be = foo"; ANTLRStringStream inStream = new ANTLRStringStream(sourceText); // your generated lexer class MyLexer lexer = new MyLexer(inStream); CommonTokenStream tokens = new CommonTokenStream(lexer); // your generated parser class MyParser parser = new MyParser(tokens); // run the toplevel rule (in this case, `program`) MyParser. Program_return prog = parser.program(); // get the resulting AST (a CommonTree instance, in this case) CommonTree tree = (CommonTree) prog.getTree(); // run a tree parser rule on the AST MyTreeParser treeParser = new MyTreeParser(new CommonTreeNodeStream(tree)); treeParser.program(); I strongly recommend getting a copy of The Definitive ANTLR Reference if you're going to be using ANTLR.
All of this is covered pretty thoroughly, with plenty of examples to get you started.
I thought I'd searched the FAQ pretty thoroughly, but had missed this page. I've read it now, and think I'm pretty close. Still not working though.
When you say "you need to use the ANTLR code generation tool with the "-debug" flag (I'm using the Java target), then, where you create your tree parser instance", I think that's where I'm getting lost. Are you using the command line ANTLR to generate code? I'm not really sure where I'm creating this code, and how the code for the non-tree parser is running.
– Mike Cargal Oct 25 '09 at 22:29.
If you're sure that the AST you're building is fine (with ANTLRWORKS debugger), the tree-walking testing is not different than testing any other app. If you're emitting Java Code for example, use Eclipse's debugger to test it, or plain log messages...
Yeah, I've moved on to using this method. ANTLRWorks is very convenient, so I was hoping to find a way to test my tree grammar without leaving ANTLRWorks. It's not a show stopper, but it would be nice to work out how to make it work.
– Mike Cargal Oct 25 '09 at 22:30.
The ANTLRWorks debugger should work fine with your tree grammar. If I recall correctly, you need to use the ANTLR code generation tool with the "-debug" flag (I'm using the Java target), then, where you create your tree parser instance, use the debug constructor that takes a port as an argument. In my case, the default port didn't work, so I arbitrarily picked 35505.
Fire up ANTLRWorks, open your tree grammar, click "Run"->"Debug Remote...", set the port to the same value used in the constructor for your tree parser, and you should be able to connect the debugger to your running application. See the ANTLR 3 Debugging FAQ for details. When you're testing your non-tree parser in ANTLRWorks, there's a behind-the-scenes process that generates Java code from your grammar file, then uses that code to parse your input.
When you use your parser in your own application, you have to use ANTLR (specifically, the class org.antlr. Tool) to generate Java code that you can then include in your application. ANTLRWorks has a menu option for this, which should get you started.
In my case, I have a target in my ant build file that generates the Java code from my grammars and puts those Java source files in a place where the rest of my application can find them. The property antlr.tool. Classpath needs to contain stringtemplate.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.