[il-antlr-interest: 35035] [antlr-interest] Changing the root of a tree in a tree parser

2011-11-28 Thread franck102
I am trying to do something that seems pretty simple, which is adjusting the root token of a tree in my tree parser. Basically my parser always sees a=b as a comparison and generates ^( EQUAL a b) as an AST, and in the tree parser I want to adjust that to ^( ASSIGN a b) if I am at the statement

[il-antlr-interest: 35036] [antlr-interest] Tree building limitation in tree grammars?

2011-11-28 Thread franck102
My parser grammar can generate a number of subtrees with similar structure, and just a different root type. In the tree grammar I am trying to just pass such a subtree along without any changes, but that is turning out to be much trickier than I expected, am I missing something? Given this AST:

[il-antlr-interest: 35039] Re: [antlr-interest] Confused about backtracking

2011-11-28 Thread franck102
Christian wrote Hi, what is the error/exception message? Regards, Christian MissingTokenException at the second '=', after parsing a=b.c as an expression. The tail recursion on expr is causing it it seems, but that's a real issue for me... here is a slightly modified version with

[il-antlr-interest: 35049] Re: [antlr-interest] Confused about backtracking

2011-11-28 Thread franck102
None of those suggestion will help with the actual grammar unfortunately. It is indeed ambiguous, that is the warning I get if I turn backtracking off, but I can't refactor the rules (or the actual, large grammar) w/o ending with a completely meaningless AST. I still don't understand why antlr

[il-antlr-interest: 35051] Re: [antlr-interest] Tree building limitation in tree grammars?

2011-11-28 Thread franck102
Thanks John, I had tried the first one (using a label assigned in each branch of the alternative), I just posted it wrong. Your 2nd 3rd suggestions should work I expect, thanks! Too bad the most natural one ^( ( AND | OR ) ... w/o rewrite doesn't work... -- View this message in context:

[il-antlr-interest: 35028] Re: [antlr-interest] Possible bug with backtrack-generated predicate methods

2011-11-26 Thread franck102
In fact the tree has been constructed by the leading (ID-ID), and that parameter being a tree is exactly why I gave up on hoisting. I am sure it can be made to work but getting the typing right was a pain. So here is exactly what I am trying to do, there is probably a better way than what I have

[il-antlr-interest: 35030] Re: [antlr-interest] Possible bug with backtrack-generated predicate methods

2011-11-26 Thread franck102
Bart Kiers wrote On Sat, Nov 26, 2011 at 9:58 AM, franck102 franck102@ wrote: In fact the tree has been constructed by the leading (ID-ID), That tree only exists inside your parenthesis, AFAIK. You can't reference it outside it (well, you can, but it will be `null`). This seems

[il-antlr-interest: 35031] [antlr-interest] Confused about backtracking

2011-11-26 Thread franck102
I think I am missing something fundamental about backtracking. The grammar below won't parse input such as a=b. c=d; ... even though I would expect it to backtrack after realizing that a=b.c leads to a dead-end. What am I missing? Thanks! PS: I am not looking for refactoring options, I have

[il-antlr-interest: 35020] [antlr-interest] Matching compound keywords in the lexer

2011-11-25 Thread franck102
I am trying to match multi-word keywords at the lexer level, I found the pattern below in previous answers but I can't figure out how to make the type assigned to $type visible to parser rules... any suggestion appreciated! I would rather not modify containOperator to get at the token type, this

[il-antlr-interest: 35026] [antlr-interest] Possible bug with backtrack-generated predicate methods

2011-11-25 Thread franck102
The grammar below won't compile, this looks like a bug to me? It seems that the syntactic predicate automatically generated by the backtrack option includes the rule parameter but doesn't have a declaration for it. The error I get is: [08:49:44] 1 error [08:50:01]

[il-antlr-interest: 35012] [antlr-interest] Understanding non LL(*) errors

2011-11-24 Thread franck102
Hi, I am new to grammar design and I am still struggling with understanding non LL(*) errors. In the example below I do understand that call f using 1, 2 is ambiguous, which I am trying to address with the greedy option, but I still get a fatal error trying to compile the grammar. I am looking

[il-antlr-interest: 35015] Re: [antlr-interest] Understanding non LL(*) errors

2011-11-24 Thread franck102
Made some progress after lots of head scratching and re-reading the antlr book: 1. I saw somewhere on a popular antlr web page that syntactic predicates could only appear at the beginning of an alternative, this is inaccurate, in fact my problem is solved by adding a predicate at the beginning of

[il-antlr-interest: 34981] Re: [antlr-interest] String concatenation expression rule

2011-11-20 Thread franck102
call, but it must not trigger in the first case because neither 2 or 3 are string literals... Franck From: Jim Idle [via ANTLR] ml-node+s1301665n7009129...@n2.nabble.com To: franck102 franck...@yahoo.com Sent: Friday, November 18, 2011 6:47 PM Subject: Re

[il-antlr-interest: 34963] [antlr-interest] String concatenation expression rule

2011-11-18 Thread franck102
I am writing a grammar for a fairly complex expression language, and in particular I need to support string concatenation which is performed simply by separating string literals with a space; and which automatically converts other expressions to a string if needed to concatenate: a b - ab 2+3 mm -

[il-antlr-interest: 34973] Re: [antlr-interest] String concatenation expression rule

2011-11-18 Thread franck102
to the string 33) Franck From: Bart Kiers [via ANTLR] ml-node+s1301665n7008016...@n2.nabble.com To: franck102 franck...@yahoo.com Sent: Friday, November 18, 2011 1:11 PM Subject: Re: String concatenation expression rule On Fri, Nov 18, 2011 at 12:39 PM