[il-antlr-interest: 29747] [antlr-interest] question about deleteChild function

2010-08-08 Thread lu lu
Hi, everyone. I am doing a job about modifying AST of a SQL like language generated by ANTLR3.2 parser. However, when I use deleteChild function of Tree class, I can’t delete the first and last child of the tree, while the others can be deleted successfully. I was confused by this problem, Could s

[il-antlr-interest: 29746] Re: [antlr-interest] How does INTEGER+ '.' INTEGER+ match "2."?

2010-08-08 Thread John B. Brodie
On Sun, 2010-08-08 at 20:50 -0400, Kevin J. Cummings wrote: > On 08/08/2010 08:35 PM, Ken Klose wrote: > > Thanks for replying. > > > > 2. is not a valid PRICE. PRICE should have at least 1 digit following the > > '.'. In the context of the string that I am trying to match "2." doesn't > > have

[il-antlr-interest: 29745] Re: [antlr-interest] How does INTEGER+ '.' INTEGER+ match "2."?

2010-08-08 Thread Kevin J. Cummings
On 08/08/2010 08:35 PM, Ken Klose wrote: > Thanks for replying. > > 2. is not a valid PRICE. PRICE should have at least 1 digit following the > '.'. In the context of the string that I am trying to match "2." doesn't > have any particular significance, it is neither an INTEGER nor a PRICE. It >

[il-antlr-interest: 29744] Re: [antlr-interest] How does INTEGER+ '.' INTEGER+ match "2."?

2010-08-08 Thread Ken Klose
Thanks for replying. 2. is not a valid PRICE. PRICE should have at least 1 digit following the '.'. In the context of the string that I am trying to match "2." doesn't have any particular significance, it is neither an INTEGER nor a PRICE. It is simply an INTEGER following by an SYMBOL token.

[il-antlr-interest: 29743] Re: [antlr-interest] How does INTEGER+ '.' INTEGER+ match "2."?

2010-08-08 Thread Gerald Rosenberg
-- Original Message (Sunday, August 08, 2010 6:42:55 PM) From: Ken Klose -- Subject: [antlr-interest] How does INTEGER+ '.' INTEGER+ match "2."? > INTEGER: DIGIT+; > PRICE: INTEGER '.' INTEGER; Integer and price are ambiguous and, if "2." is a valid price, need to make the decimal field

[il-antlr-interest: 29742] [antlr-interest] How does INTEGER+ '.' INTEGER+ match "2."?

2010-08-08 Thread Ken Klose
I'm an ANTLR noob constructing a grammar to parse a data file that is a mix of structured data and unstructured text. At various points in this data file there are entire lines of free form text that I need to associate with the previously matched data record. I am having difficulty. I've distill

[il-antlr-interest: 29741] Re: [antlr-interest] Right recursive rule and creating the AST in reverse order

2010-08-08 Thread John B. Brodie
Greetings! passing the FROM tree down the rule set doesn't seem too bad to me. DISCLAIMER: i can barely spell C# and certainly know nothing whatsoever about LINQ --- so i probably have mis-understood something crucial. On Sun, 2010-08-08 at 19:10 +0100, Luis Pureza wrote: > Hi, > > I'm writing

[il-antlr-interest: 29740] Re: [antlr-interest] "Return via Exception Technique" and VS2010

2010-08-08 Thread Sam Harwell
First of all, you should absolutely not be using exception handling for flow control. If you are, there's a critical design error involved and you should fix it before worrying about other things. Second, the way Java handles exceptions is different from the way the CLR handles them. The CLR builds

[il-antlr-interest: 29739] [antlr-interest] Right recursive rule and creating the AST in reverse order

2010-08-08 Thread Luis Pureza
Hi, I'm writing a grammar to parse a language similar to C#'s LINQ*. For example: from obj in list where obj.attribute > 200 select obj.attribute * 100 Notice that, unlike regular SQL, the FROM clause appears before the SELECT and WHERE clauses. To parse this I've written the following rules:

[il-antlr-interest: 29738] Re: [antlr-interest] Building a tree grammar expression to recognize arithmetic expressions

2010-08-08 Thread John B. Brodie
On Sun, 2010-08-08 at 17:02 +0100, Alex Storkey wrote: > Thanks! > > Now I'm getting the error: > [fatal] rule expression has non-LL(*) decision due to recursive rule > invocations reachable from alts 1,2. Resolve by left-factoring or using > syntactic predicates or using backtrack=true option. >

[il-antlr-interest: 29737] [antlr-interest] Keeping trees around

2010-08-08 Thread Steve Ebersole
Most of the uses of Antlr I have seen show temporary use of ASTs. I mean temporary here in that usually the AST is built, used and discarded in a single step. I have a particular usage where I am generating SQL statements and really I could pre-build large chunks of the resulting SQL AST up-front

[il-antlr-interest: 29736] Re: [antlr-interest] Building a tree grammar expression to recognize arithmetic expressions

2010-08-08 Thread Alex Storkey
Thanks! Now I'm getting the error: [fatal] rule expression has non-LL(*) decision due to recursive rule invocations reachable from alts 1,2. Resolve by left-factoring or using syntactic predicates or using backtrack=true option. Which I guess kinda makes sense, but how do I go about sorting it? J

[il-antlr-interest: 29734] Re: [antlr-interest] Building a tree grammar expression to recognize arithmetic expressions

2010-08-08 Thread John B. Brodie
Greetings! the ^ meta-operator in the suffix position is a tree construction operation and is NOT valid for tree recognition. you should be getting a warning similar to: warning(149): treeTest.g:0:0: rewrite syntax or operator with no output option; setting output=AST or if you have already set

[il-antlr-interest: 29733] [antlr-interest] "Return via Exception Technique" and VS2010

2010-08-08 Thread Kevin Carroll
I'm having a problem that hopefully someone on this list can shed some light on. I've implemented a tree-based interpreter in C# on .Net for a DSL using ANTLR. I've used Terrence Parr's "Language Implementation Patterns" book for guidance. In his chapter on tree-based interpreters, he used a t

[il-antlr-interest: 29732] Re: [antlr-interest] Building a tree grammar expression to recognize arithmetic expressions

2010-08-08 Thread Alex Storkey
Okay, sorry to keep posting but I've managed to get the antlrworks debugger working on my tree grammar and I have discovered the problem. It seems like instead of the rule *expression* consuming the MINUS symbol, the minus symbol is ignore by the expression rule and consumed by the *term*rule, spe

[il-antlr-interest: 29730] Re: [antlr-interest] Need some help with AST creation

2010-08-08 Thread Luis Pureza
Thank you all for your replies. It worked. :-) On Fri, Aug 6, 2010 at 8:33 PM, Junkman wrote: > Jim Idle wrote: >> You can just do this: >> >> >> ddd: a=TOKEN^ B C D { $a.type = INDEX; } ; >> >> Jim >> > > Typical C programmer mentality.  :-) > > Best, > > J > > List: http://www.antlr.org/mailman