[il-antlr-interest: 23721] Re: [antlr-interest] Modifying tree based on semantic content

2009-05-15 Thread Tilman Bender
Hi David, I think this is possible with rewrite rules, but it depends on how you structure you grammar: e.g. Have lexer rules for STRING, INT, FLOAT so you could do things like expr: a=STRING '+' b=STRING -> ^(CONCATENATE a b) | a=number '+' b=number -> ^(PLUS a b) ; number:

[il-antlr-interest: 23722] Re: [antlr-interest] How do I throw exception on ERROR "no viable alternative at character "

2009-05-15 Thread Tilman Bender
Hi, Please have a look at the error reporting and recovery page on the wiki: http://www.antlr.org/wiki/display/ANTLR3/Error+reporting+and+recovery Maybe you could also override this: http://www.antlr.org/api/Java/classorg_1_1antlr_1_1runtime_1_1_base_recognizer.html#6c32f5b03a9049357f3ddfbccee9a

[il-antlr-interest: 23723] Re: [antlr-interest] Modifying tree based on semantic content

2009-05-15 Thread David Jameson
Tilman, thanks for the suggestion. Sadly, that approach will only work if a and b are literals. It will not work if the non-terminals a and/ or b represent identifiers whose type can only be determined by checking the symbol table. Cheers, D On May 15, 2009, at 4:43 AM, Tilman Bender wrote

[il-antlr-interest: 23724] Re: [antlr-interest] Modifying tree based on semantic content

2009-05-15 Thread Steve Ebersole
someRule : a PLUS b -> { areStrings($a.tree,$b.tree) } ^(CONCATENATE a b) -> ^(PLUS a b) On Thu, 2009-05-14 at 23:38 -0400, David Jameson wrote: > Is there any way to control the built-in tree generation (from an > initial parse phase) based on semantics of what is being par

[il-antlr-interest: 23725] Re: [antlr-interest] Modifying tree based on semantic content

2009-05-15 Thread David Jameson
I was not aware of this kind of construction. Thank you for bringing it to my attention. Where is there an article that specifically discusses this mechanism? I couldn't find it in my ANTLR book nor through (a few) google searches? In other words, what exactly is "areStrings(...)" --- is i

[il-antlr-interest: 23726] Re: [antlr-interest] Modifying tree based on semantic content

2009-05-15 Thread Steve Ebersole
On Fri, 2009-05-15 at 07:34 -0400, David Jameson wrote: > I was not aware of this kind of construction. Thank you for bringing > it to my attention. Where is there an article that specifically > discusses this mechanism? I couldn't find it in my ANTLR book nor > through (a few) google searc

[il-antlr-interest: 23727] [antlr-interest] Lexer matching non-matching rule

2009-05-15 Thread Jesper Larsson
Sorry if this is a stupid question, but if it is I hope it has a quick stupid answer. My ANTLR-generated lexer protests about unexpected characters in a situation where it could have matched the input with other rules. My understanding of ANTLR and other tools that generate lexers is that it shou

[il-antlr-interest: 23728] Re: [antlr-interest] Lexer matching non-matching rule

2009-05-15 Thread Michael
Am Friday 15 May 2009 14:03:16 schrieb Jesper Larsson: > > URL:('a'..'z') ('a'..'z' | '0'..'9' | '+' | '-' | '.')* ':' > ~('\f' | '\n' | '\r' | '\t' | ' ')*; if you leave out the dot in the URL rule it works as it should. If the dot is there the IDENT rule is not cal

[il-antlr-interest: 23729] [antlr-interest] ANTLR 3 grammar for C++

2009-05-15 Thread Mark Volkmann
I'm looking for an ANTLR 3 grammar for C++. Does one exist? -- R. Mark Volkmann Object Computing, Inc. List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~-~--~~~---~--

[il-antlr-interest: 23730] Re: [antlr-interest] Modifying tree based on semantic content

2009-05-15 Thread David Jameson
I hate to bother you with more on this but I ran into difficulty when I tried to translate the simple question/response into my real grammar. My actual rule in my grammar is below --- I added two rewrite predicates, the idea being that if the type of LHS is a string, then my tree will have

[il-antlr-interest: 23731] Re: [antlr-interest] Modifying tree based on semantic content

2009-05-15 Thread David Jameson
Hmmm, answering my own question, it looks like you have to put a ? after the predicate D On May 15, 2009, at 7:57 AM, Steve Ebersole wrote: > On Fri, 2009-05-15 at 07:34 -0400, David Jameson wrote: >> I was not aware of this kind of construction. Thank you for bringing >> it to my attention.

[il-antlr-interest: 23732] Re: [antlr-interest] How do I throw exception on ERROR "no viable alternative at character "

2009-05-15 Thread Bharath R
Thanx a lot. Its working fine ! I have overridden the below method in the parser and lexer code generated. public void displayRecognitionError (String[] tokenNames,Recognit

[il-antlr-interest: 23733] Re: [antlr-interest] How do I throw exception on ERROR "no viable alternative at character "

2009-05-15 Thread Tilman Bender
Hi, Good to hear it works for you. But you probably shouldn't do that in the generated code or it will be gone once you need to regenerate the Praser/Lexer in case you change something. Instead you should do the overriding in a @members{} block like it is described on the wiki- page. hth Ti

[il-antlr-interest: 23734] [antlr-interest] How to free ANTLR3_STRING (c runtime)?

2009-05-15 Thread Chetty, Jay
What's the right way to free the ANTLR3_STRING returned from pANTLR3TOKEN_STREAM's toStringSS() I used destroy method of the string factory and it seems that's not the right way As I get these lines when my executable exists. *** glibc detected *** double free or corruption (fasttop): 0x081514

[il-antlr-interest: 23735] Re: [antlr-interest] How to free ANTLR3_STRING (c runtime)?

2009-05-15 Thread Jim Idle
Chetty, Jay wrote: > What's the right way to free the ANTLR3_STRING returned from > pANTLR3TOKEN_STREAM's toStringSS() > > > I used destroy method of the string factory and it seems that's not the right > way > As I get these lines when my executable exists. > > *** glibc detected *** double free

[il-antlr-interest: 23736] Re: [antlr-interest] How to free ANTLR3_STRING (c runtime)?

2009-05-15 Thread Chetty, Jay
Jim thanks for the reply. My understanding was also that string factory will manage the life time of the strings it created. But ran into out of memory issue on a 32 bit machine, so thought of freeing up some strings that Were created while forward looking some tokens during error reporting.

[il-antlr-interest: 23737] [antlr-interest] Hopefully just a little more help with syntax for semantic predicates?

2009-05-15 Thread dhjdhj
I have been trying all day to get the rule below accepted (oh yeah, that doesn't count about 2 hours wasted before I figured out that you can't have a space after the right curly brace and the question mark in a semantic predicate (grin)) I get a "cannot generate the grammar because" error

[il-antlr-interest: 23738] Re: [antlr-interest] How to free ANTLR3_STRING (c runtime)?

2009-05-15 Thread Jim Idle
Chetty, Jay wrote: > Jim thanks for the reply. > > My understanding was also that string factory will manage the life time of > the strings it created. > But ran into out of memory issue on a 32 bit machine, so thought of freeing > up some strings that > Were created while forward looking some

[il-antlr-interest: 23741] Re: [antlr-interest] Lexer matching non-matching rule

2009-05-15 Thread Indhu Bharathi
This is because on seeing 'f' of foo lexer has two options - 1. IDENT 2. URL. And it takes the second options since that seems to be longer that the first alternative. Note that the lexer always tries to match the longest token possible. After having decided to go for URL, it matches the inpu

[il-antlr-interest: 23740] Online Dating and friend finder

2009-05-15 Thread manju
Online Dating and friend finder http://friendfinder.com/go/g1100916 http://friendfinder.com/go/g1100916 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to