[prev in list] [next in list] [prev in thread] [next in thread] 

List:       antlr-interest
Subject:    Re: [antlr-interest] and, finally, ternary operator works
From:       Terence Parr <parrt () cs ! usfca ! edu>
Date:       2011-02-26 16:48:47
Message-ID: C9BFE1AF-0446-4764-90CD-315CA359381E () cs ! usfca ! edu
[Download RAW message or body]


On Feb 25, 2011, at 7:14 PM, Sam Harwell wrote:

> Ternary for C++ is even stranger, though I'm not sure it's necessary to
> support it at this point.

C/C++ do it differently?

> 
> x ? a : b = c
> 
> should parse as this in C++:
> 
> (? x a (= b c))

ack.

> But as this is C (which is found to be invalid at a later time since the
> ternary operator cannot return an lvalue in C):
> 
> (= (? x a b) c)
> 
> However, in both C and C++ the following:
> 
> x = c ? a : b
> 
> Should parse as:
> 
> (= x (? c a b))

coorect.

> I've been watching for those check-ins, and I see one now! :)
> 

you'll be disappointed with size reduction. I only got 50% or so.  speed test coming.

Ter

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic