[il-antlr-interest: 28824] [antlr-interest] gunit syntax for tree walker with a flat list of nodes
Here's a simple gunit test for a portion of my grammar which generates a flat list of nodes: objectOption walks objectOption: one:value - (one value) In the above, I purposefully left out the caret (i.e. ^(one value)) since it's a flat list of nodes and not a tree. Another option which seems intuitive is to leave off the parenthesis, like this: objectOption walks objectOption: one:value - one value In the first case the parenthesis cause an error 1 failures found: test2 (objectOption walks objectOption, line17) - expected: (one \value\) actual: one \value\ And in the second case I get an exception: line 17:20 no viable alternative at input 'one' line 17:24 missing ':' at 'value' line 0:-1 no viable alternative at input 'EOF' java.lang.NullPointerException at org.antlr.gunit.OutputTest.getExpected(OutputTest.java:65) at org.antlr.gunit.gUnitExecutor.executeTests(gUnitExecutor.java:245) ... What is the correct way to match a flat tree? Thanks. -- Kaleb Pederson Blog - http://kalebpederson.com Twitter - http://twitter.com/kalebpederson List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups il-antlr-interest group. To post to this group, send email to il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
[il-antlr-interest: 28825] [antlr-interest] throws on rule declaration being ignored
I have a tree parser that's doing semantic analysis on the AST generated by my parser. It has a rule declared as follows: transitionDefinition throws WorkflowStateNotFoundException: /* ... */ This compiles just fine and matches the rule syntax at http://www.antlr.org/wiki/display/ANTLR3/Grammars but my exception is never declared so the Java compiler complains. ./tool/src/main/antlr3/org/antlr/grammar/v3/ANTLRv3.g shows that it's building a tree (but I'm not actually positive if it's the v2 or v3 grammar that ANTLR 3.2 is using): throwsSpec : 'throws' id ( ',' id )* - ^('throws' id+) ; I know I can make it a runtime exception, but I'd like to use my exception hierarchy. Am I doing something wrong or should that syntax work? Thanks. -- Kaleb Pederson Blog - http://kalebpederson.com Twitter - http://twitter.com/kalebpederson List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups il-antlr-interest group. To post to this group, send email to il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
[il-antlr-interest: 28785] [antlr-interest] GUnit testsuite Run / Debug Configuration for Eclipse
Does anybody know of an easy way to run gunit tests within Eclipse, hopefully in a way that will allow them to be picked up as tests? Last I checked, there is no JUnit code generator option for the maven-gunit- plugin, and I believe it's still using JUnit 3. I'm running the ANTLR IDE Eclipse plugin (thanks Edgar!), but to my knowledge it doesn't add any options in this area. Thanks for any suggestions. -- Kaleb Pederson Blog - http://kalebpederson.com Twitter - http://twitter.com/kalebpederson List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups il-antlr-interest group. To post to this group, send email to il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
[il-antlr-interest: 28569] Re: [antlr-interest] Another JUnit testing framework
Alan, Overall your code looks very clean. Do you have any samples that demonstrate usage? (I looked around but your README and docs directories are basically empty :). Thanks. -- Kaleb Pederson Blog - http://kalebpederson.com Twitter - http://twitter.com/kalebpederson On Thursday 22 April 2010 05:43:25 am Alan D. Cabrera wrote: Hello, I started working on another JUnit testing framework for ANTLR. Mainly as a mechanism to learn how to write a JUnit testing and, secondarily, to test my grammars in a way that I was comfortable with. It's a great mix of Jeremy D. Frens' assert code from the antlr- testing.sourceforge.net project and the configuration bits from PAX Exam, http://wiki.ops4j.org/display/paxexam/Pax+Exam. I'm new to all this, both JUnit writing and ANTLR testing, so I would love any comments you may have. You can find my project at: http://github.com/maguro/aunit Regards, Alan List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups il-antlr-interest group. To post to this group, send email to il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
[il-antlr-interest: 28327] Re: [antlr-interest] sematic analysis ?
On Fri, Mar 19, 2010 at 10:37 AM, Kaleb Pederson kaleb.peder...@gmail.com wrote: Venkat, One way to do what you've mentioned is to create a tree walker which walks the AST. Then, within the AST, you'll need to do a couple of things. First, you need to populate a symbol table. That symbol table will store the different objects/variables that are declared. In your example, it would store a and b, their values, if known, and their types. Second, you need to do an analysis of the structure while using the symbol table. Here's a fragment from one of my tree walking grammars: plusMinusExpression returns [Type type] : ^(PLUS lhs=baseExpression rhs=baseExpression) { typeChecker.assertIsNumericType($lhs.type); typeChecker.assertIsNumericType($rhs.type); typeChecker.assertEqualTypes($lhs.type, $rhs.type); $type = $lhs.type; } /* ... */ ; I realized that doesn't fully explain everything. In the various expressions, I resolve any necessary symbols and then resolve their types by: * using the symbol table if it's a variable, OR * using the type of the literal I then return the type of the expression so I can verify that the types match throughout the entire expression. -- Kaleb Pederson http://kalebpederson.com http://twitter.com/kalebpederson List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups il-antlr-interest group. To post to this group, send email to il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
[il-antlr-interest: 28290] Re: [antlr-interest] Using the results
On Tue, Mar 16, 2010 at 4:26 PM, Nikolas Everett nik9...@gmail.com wrote: Its been a long time since I last used antlr and I'm now getting the chance to use it again. I happened on a rather conspicuous gap in my knowledge: I have no idea what the right way take actions based on parsed results. At least you recognize that :). Should I parse my input to an AST and then walk the AST? This seems like it'd be a pain to maintain. Should I call actions directly from antlr? This simpler but in practice is really cumbersome and makes using antlrworks much more difficult. Which one of the above you'll want will be largely dependent on what your needs are and how complicated everything becomes. If you're dealing with something simple, then putting the actions directly in ANTLR's action code is a perfectly reasonable solution and may result in the least amount of code and the code that's easiest to understand (for those not versed in the ANTLR tree-walking process). If you end up needing something more complicated and need information from various parts in your processing, such as you might if you support mutually recursive types, then using a tree walker and deferring as much of the processing and validation as possible until later. There's likely a continuum between the two. For example, I've found that I can often create builder classes which I call within the actions of my parser. These builder classes provide a consistent interface that I can use to test without dealing directly with the parser, and provide an easy interface that the parser can use. When used with a good set of ANTLR features, such as scopes and actions on non-terminal fragments, this can make for a very clean structure. If you want specifics it would be helpful if you could provide more concrete details. HTH. -- Kaleb Pederson Blog - http://kalebpederson.com Twitter - http://twitter.com/kalebpederson List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups il-antlr-interest group. To post to this group, send email to il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
[il-antlr-interest: 27636] Re: [antlr-interest] gunit problem
On Thu, Jan 21, 2010 at 2:22 AM, Ian Moor i...@doc.ic.ac.uk wrote: I am using the gunit which is provided with antlr 3.2 and I am trying to test parts of an tree, for example statement walks statements: x=1 - ok I expect an error message saying the code produced to System.out is not ok, but gunit prints no output, ans stops with a non zero return value. Although it takes some work, you can debug gunit. You'll need to grab the source and then set appropriate breakpoints as one normally would in working with a debugger, but it's possible. Is there a way finding what is happening, or a later gunit ? A patched version of gunit is available that includes better support for custom ASTs: http://www.antlr.org/wiki/pages/viewpageattachments.action?pageId=3244061metadataLink=true I know I found source for it somewhere and was able to debug another problem, so hopefully you can do the same. -- Kaleb Pederson Blog - http://kalebpederson.com Twitter - http://twitter.com/kalebpederson List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups il-antlr-interest group. To post to this group, send email to il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.