On Feb 1, 2010, at 12:29 AM, Dag Sverre Seljebotn wrote:

> Stefan Behnel wrote:
>> Robert Bradshaw, 30.01.2010 01:31:
>>
>>> There's no way to interpret the expression
>>>
>>>     new A(1,10)
>>>
>>> as valid Python, so there's no ambiguity.
>>>
>>
>> Ok, it's not /really/ a keyword then, in the sense that it cannot  
>> appear
>> outside of its grammar context. It would still be allowed everywhere,
>> except that the case that it is followed by a name would be special  
>> cased.

Exactly. The same as "extern" or "public" is not really a keyword.

>> But doesn't that overly complicate the parser? I mean, 'new' can
>> potentially appear in most places of an expression, and it can  
>> always mean
>> both things...
>>
> There's a limit to how simple the parser can be anyway, we can't use  
> the
> simple parsing strategy of Python since we're supporting some C  
> syntax.
> The tokenizer supports putting tokens back, so one can simply try for
> "new X" first, and if there's no match then one can put the token back
> into the tokenizer and call p_expr. Not much more complicated than
> anything else that goes on in the parser...

Which is basically what happens. Even then it's much cleaner than some  
other areas of the parser.

- Robert

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to