[il-antlr-interest: 24774] Re: [antlr-interest] accessing lexer sub tokens from a rule

2009-07-20 Thread hakan eryargi
ntValue=INTEGER | floatValue=FLOAT))? -> ^(ABILITY[$p, $s, $name, $intValue, $floatValue] ID ID INTEGER? FLOAT?) ; On Mon, Jul 20, 2009 at 4:04 AM, hakan eryargi wrote: > hello, > > is it possible to access sub tokens of lexer from a rule ? (sorry for > stupid naming) at the

[il-antlr-interest: 24761] [antlr-interest] accessing lexer sub tokens from a rule

2009-07-19 Thread hakan eryargi
hello, is it possible to access sub tokens of lexer from a rule ? (sorry for stupid naming) at the bottom is part of my grammar. i want to re-write primary rule something like: primary : a=ABILITY -> ABILITY[$a.scope, $a.id, ($a.INTEGER | $a.FLOAT)? ] | LPAREN! expression

[il-antlr-interest: 24759] Re: [antlr-interest] rewriting tree such that children are at same level

2009-07-19 Thread hakan eryargi
thanks. that's clearly simpler and better for this case :) On Mon, Jul 20, 2009 at 12:06 AM, David-Sarah Hopwood wrote: > hakan eryargi wrote: >> hello, >> >> below is the main part of my grammar. it's ok but it creates an AST >> from expression >> &

[il-antlr-interest: 24752] Re: [antlr-interest] rewriting tree such that children are at same level

2009-07-19 Thread hakan eryargi
thank you both. it seems ok now :) so that p+ means keep a list of primary (or whatever) and add primary to that list at '= primary' points On Sun, Jul 19, 2009 at 9:22 PM, John B. Brodie wrote: > Greetings! > > On Sun, 2009-07-19 at 21:02 +0300, hakan eryargi wrote: >>

[il-antlr-interest: 24749] Re: [antlr-interest] rewriting tree such that children are at same level

2009-07-19 Thread hakan eryargi
9, 2009 at 8:47 PM, Jim Idle wrote: > Not sure WHY you would want that buy it is just: > > p+=primary (AND p+=primary)* -> ^(AND $p+) > > Jim > > On Jul 19, 2009, at 7:04 AM, hakan eryargi wrote: > >> hello, >> >> below is the main part of my grammar. i

[il-antlr-interest: 24747] [antlr-interest] rewriting tree such that children are at same level

2009-07-19 Thread hakan eryargi
hello, below is the main part of my grammar. it's ok but it creates an AST from expression a & b & c -> (& (& a b) c) : an AND node with children c and another AND node with children a and b but i want: (& a b c) : an AND node with tree children how can i make that with a rewrite rule ? i've

[il-antlr-interest: 24715] Re: [antlr-interest] forcing parenthesis (no precedence)

2009-07-16 Thread hakan eryargi
thank you all. this effectively solved my problem :) On Thu, Jul 16, 2009 at 5:55 PM, David-Sarah Hopwood wrote: > Stuart Dootson wrote: >> On Thu, Jul 16, 2009 at 1:21 PM, hakan eryargi >> wrote: >>> i will really appreciate a simple sample if possible :) >> >

[il-antlr-interest: 24687] Re: [antlr-interest] forcing parenthesis (no precedence)

2009-07-16 Thread hakan eryargi
i will really appreciate a simple sample if possible :) On Thu, Jul 16, 2009 at 2:48 PM, Gavin Lambert wrote: > At 18:57 16/07/2009, hakan eryargi wrote: >>thank you but i can't get it. simply making AND's and OR's have >>same precedence doesnt force user to use

[il-antlr-interest: 24678] Re: [antlr-interest] forcing parenthesis (no precedence)

2009-07-15 Thread hakan eryargi
eed and make AND and OR tokens the same precedence in the same way that '+' and '=-' are. In general stealing rules from the example grammars (see the download section) will get you a long way! On Wed, Jul 15, 2009 at 12:20 PM, hakan eryargi wrote: > hello, > > i wa

[il-antlr-interest: 24654] [antlr-interest] forcing parenthesis (no precedence)

2009-07-15 Thread hakan eryargi
hello, i want to create a grammar for simple expressions and AND, OR statements. AND's and OR's have no precedence, so i want the user to explicitly use parenthesis if AND's and OR's mixed. how can i define such a grammar ? for example these are valid: EXP EXP & EXP EXP | EXP | EXP EXP & (EXP |