[il-antlr-interest: 24762] [antlr-interest] How to debug tree grammar??

2009-07-19 Thread sunao furukawa
Hello! My name is Sunao Furukawa. I am Japanese.Sorry,I can speak English a little. I use ANTLRWorks1.2.3.but I cannot debug tree grammar file T1.g. 1.I generated E3.tokens and E3Lexer.java and E3Parser.java from E3.g in ANTLRWorks. 2.I generated and compiled T1.g(T1.java,T1.tokens),and E3.token

[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: 24760] [antlr-interest] Exceptions handling, Line and Char Position

2009-07-19 Thread Michal Orzechowski
Exceptions handling, Line and Char stream Position Hi all, I've written a tree parsing rule, and have few doubts concerning nice exceptions handling. I have such thing working: def_tags : (a=ID {db.tags.register($ID.text);})* ; catch[DatabaseAbstractException e]

[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 >> >> a & b & c  -> (& (& a b) c) : an AND node with

[il-antlr-interest: 24758] Re: [antlr-interest] Can never be matched

2009-07-19 Thread Bryan S Follins
Sorry group, perhaps I should have made myself clear. This code is just skeleton. I just wanted to be sure I was on the right track. I have to add my actions later. -Original Message- From: Patrick Higgins [mailto:patrick1...@yahoo.com] Sent: Sunday, July 19, 2009 13:45 To: Bryan S Fo

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

2009-07-19 Thread David-Sarah Hopwood
hakan eryargi wrote: > 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 c

[il-antlr-interest: 24756] Re: [antlr-interest] Can never be matched

2009-07-19 Thread Patrick Higgins
I don't know what your grammar is supposed to be doing, but from the looks of it, there's a lot of confusion and unfortunately I wouldn't say that you're "almost done". Are you using ANTLR because your course asks you to specifically use it and you have some examples and explanations of how t

[il-antlr-interest: 24755] [antlr-interest] ANTLRWorks adds junk characters at the end of file

2009-07-19 Thread Luís Reis
When opening a file with ANTLRWorks, it automatically adds one(or more) junk character to the end of the file. Attempting to compile that file with those junk characters causes an "unexpected char: 0x0" error. Is there any way to avoid having those characters added? If I remove those characters, c

[il-antlr-interest: 24754] Re: [antlr-interest] Can never be matched

2009-07-19 Thread John B. Brodie
On Sun, 2009-07-19 at 12:10 -0700, Bryan S Follins wrote: > I'm almost done with a lesson grammar but I ran into a problem I get an > error referencing the TOKEN RULE, which is on Line 17 (TOKEN : ID) It also > references Line 20, where there is a blank before SEPERATOR. > > The error reads

[il-antlr-interest: 24753] [antlr-interest] Can never be matched

2009-07-19 Thread Bryan S Follins
I'm almost done with a lesson grammar but I ran into a problem I get an error referencing the TOKEN RULE, which is on Line 17 (TOKEN : ID) It also references Line 20, where there is a blank before SEPERATOR. The error reads: error (line)20.1: groupassign.g(file name) (line)17:8: The follow

[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: >> well, i know both trees e

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

2009-07-19 Thread John B. Brodie
Greetings! On Sun, 2009-07-19 at 21:02 +0300, hakan eryargi wrote: > well, i know both trees evaluate to same result, but i want it this > way for human readability. this will be used for defining requirments > and later will be presented in a gui. and i guess it's easier to debug > this way.. >

[il-antlr-interest: 24750] Re: [antlr-interest] Multiple evaluations of the same tree

2009-07-19 Thread Hugo Picado
Hi Michael, It worked great, thanks for the answer. Regards, Hugo. On Sat, Jul 18, 2009 at 2:12 AM, Michael Bedward wrote: > Hello Hugo, > > Try this: > > BufferedTreeNodeStream nodes = new BufferedTreeNodeStream(myTree); > LangWalker evaluator = new LangWalker(nodes); > for(int i = 0; i < 1000

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

2009-07-19 Thread hakan eryargi
well, i know both trees evaluate to same result, but i want it this way for human readability. this will be used for defining requirments and later will be presented in a gui. and i guess it's easier to debug this way.. so you mean writing experssion as: (just postponing OR for now) expression

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

2009-07-19 Thread Jim Idle
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. it's ok but it creates an AST > from expression > > a & b & c -> (& (& a b) c) : an AND node

[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: 24746] Re: [antlr-interest] Filtering peer nodes in a tree

2009-07-19 Thread Terence Parr
that is meant to work...i have some debugging to do it looks like in the patternmatching with .* :( T On Jul 19, 2009, at 1:41 AM, J. Stephen Riley Silber wrote: > > > I tried using a rule like ^( BLOCK .* ASSIGN ASSIGN .* ), but that > didn't seem to work. > > I've recently discovered that .*

[il-antlr-interest: 24745] Re: [antlr-interest] Problem coding Antlr grammar for strings

2009-07-19 Thread Luís Reis
2009/7/19 Gavin Lambert > At 22:39 19/07/2009, Luís Reis wrote: > >> and that problem still persists... The diagram on the right of ANTLRWorks' >> interpreter shows MismatchedTokenException(-1!=11) >> > > -1 means EOF, which means that something is consuming to the end of the > file. > > What ha

[il-antlr-interest: 24744] Re: [antlr-interest] Problem coding Antlr grammar for strings

2009-07-19 Thread Gavin Lambert
At 22:39 19/07/2009, Luís Reis wrote: >and that problem still persists... The diagram >on the right of ANTLRWorks' interpreter shows >MismatchedTokenException(-1!=11) -1 means EOF, which means that something is consuming to the end of the file. What happens when you run it through the debugg

[il-antlr-interest: 24743] Re: [antlr-interest] Problem coding Antlr grammar for strings

2009-07-19 Thread Luís Reis
2009/7/19 Gavin Lambert > At 07:51 19/07/2009, Luís Reis wrote: > >> STRINGCONST >> : ('@"' ( options {greedy=false;} : . )* '"') //Accepts lots of stuff, >> including newlines >> | ('"' ( >>( >> '\\' ('\\' | '"' | 'n' | 't' | OCTALCHAR) >>) | ( >> ~('"'|'\\'|LINEBREAK) >>

[il-antlr-interest: 24742] Re: [antlr-interest] Filtering peer nodes in a tree

2009-07-19 Thread J. Stephen Riley Silber
  > I tried using a rule like ^( BLOCK .* ASSIGN ASSIGN .* ), but that didn't > seem to work. I've recently discovered that .* on the end doesn't seem to work too well. I think I tried .+ or was it .* followed by UP...no, i think it was ~UP*. I need to fix this. Ter I just tried all of those, t