I've been looking at this for several hours... and then I am grated inspiration 
just after I send the email to the group...

unary
:
(NOT | NEGATE)^ unary
|
term
;



On May 17, 2010, at 5:25 PM, Andy Hull wrote:

Hi everyone,

I really need my parser to emit something like this for unary values:

 unary: ^(NOT unary) | ^(NEGATE unary);

because I need to deal with recursive unary constructs like !!17

but I'm having difficulty with the parser. Currently I have a parser rule like:

unary:   ((NOT | NEGATE)^)? term;

but clearly this won't handled nested unary operators. Given that for the input:

!!17

I need to produce

^(NOT ^(NOT INTEGER))

Can someone point me in the correct direction?

Thanks in advance!

Andy

--


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

--
Andy Hull | Senior Software Engineer
SunRun Inc.<http://www.sunrunhome.com/>
direct  415.684.9851

Review SunRun on Yelp<http://www.yelp.com/biz/sunrun-san-francisco>
click on the link above and then on ‘write a review’


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to