[cfe-dev] decl/expr ambiguity
clattner at apple.com
Sun Aug 24 16:32:11 PDT 2008
>> Is it possible to determine that something is "definitely a decl"
>> after reading the "int*" in this case?
>> int *X = ...
> Yes; once we've read "int*", we know it must be a decl.
Ok, but that only helps us if we parse the 'int*' in the unconditional
part of the parser. This approach is good for me, and using the
preparser to disambiguate hard but uncommon cases is also fine.
However, the current patch doesn't do any of this.
On Aug 24, 2008, at 3:59 PM, Argiris Kirtzidis wrote:
> Chris Lattner wrote:
>> Okay, here's another crazy idea. If you boil it down, my
>> objections to preparsing are basically:
>> 1. the perf cost of having to do the prepare in *every* decl case.
>> 2. [minor] the perf cost for qualified expr cases (std::cout << ...)
>> 3. [minor] the maintenance cost of the second parser.
> 1) This is not true, as I explain in this post:
Either I'm very confused (likely!) or your current patch doesn't do
this. As I mentioned in the other post, it looks like it runs the
preparser for any identifier at top level. It even runs it for the "x
= 4" case.
> 2) This is not inherent to the preparser, even if there's a
> "tentatively parse decl then parse as expr" approach, we still
> prefer to do such resolutions once; This perf cost needs to be
> solved in either case.
By using a "parse expr with leading qualified name" approach, or with
> 3) Ummm.. it's [minor] right ? :-)
Yes, if this is the only issue, then I agree it is the best approach :)
Thanks for working through this with me, I'm sorry I'm slow/
More information about the cfe-dev