[cfe-dev] C++ new expression

Doug Gregor doug.gregor at gmail.com
Thu Nov 13 17:39:15 PST 2008


On Thu, Nov 13, 2008 at 2:06 AM, Sebastian Redl
<sebastian.redl at getdesigned.at> wrote:
>
> On Wed, 12 Nov 2008 17:06:40 -0800, "Eli Friedman" <eli.friedman at gmail.com>
> wrote:
>> On Wed, Nov 12, 2008 at 3:06 PM, Sebastian Redl
>> <sebastian.redl at getdesigned.at> wrote:
>>> Hi,
>>>
>>> I'm currently implementing parsing new and delete, and I need a bit of
>>> help.
>>> The grammar of new-expression means that at one point, I have to
>>> distinguish between
>>>
>>> '(' expression-list ')' # new-placement
>>> and
>>> '(' type-id ')' # alternate form of specifying the type
>>>
>>> type-id is a normal C++ type-id, like it appears in cast expressions.
>>> expression-list is an argument list as it appears in function calls.
>>>
>>> Is there anything already in the parser that helps me disambiguate
>>> between the two?
>>
>> ParseParenExpression should work, I think.
>
> I've thought about it, but would it correctly handle the expression list?
> Wouldn'it it parse it as a comma expression?

Yeah, you'll probably need to implement something like
ParseParenExpression that actually parses an expression-list inside
the parens.

  - Doug



More information about the cfe-dev mailing list