[cfe-dev] Disambiguating C++ Lambdas and Objective-C Messages
John Freeman
jfreeman at cse.tamu.edu
Tue Jul 12 08:13:58 PDT 2011
Howdy Doug,
Based on recommendations, I'm looking at the following decision tree
after seeing a '['.
if lang = C++
if lang = Objective-C
if lookahead indicates lambda
parse_lambda
else if lookahead indicates message
parse_message
else
allocate lambda capture list
if tentative parse of lambda successful
finish_parse_lambda(list)
else
parse_message
else
parse_lambda
else if lang = Objective-C
parse_message
else
error
The parse_lambda and finish_parse_lambda functions will need to be
different, although the first function could call the second.
Is it too much? Should I try something simpler? Should I try an
alternative structure, like this:
if lang = C++ && lang != Objective-C
parse_lambda
else if lang != C++ && lang = Objective-C
parse_message
else if lang = C++ && lang = Objective-C
if lookahead indicates lambda
parse_lambda
else if lookahead indicates message
parse_message
else
allocate lambda capture list
if tentative parse of lambda successful
finish_parse_lambda(list)
else
parse_message
else
error
Should I wrap the lookahead and the tentative parsing into a single
TryParse* function? Perhaps it could return a valid but unusable
ExprResult upon parsing a lambda with unrecoverable errors, and an
invalid ExprResult when lookahead or tentative parsing indicated a
message. If that does not fit within the convention for invalid/usable,
could you please explain it?
- John
More information about the cfe-dev
mailing list