A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-March/086942.html below:

[Python-Dev] Python 3.0 grammar ambiguous?

[Python-Dev] Python 3.0 grammar ambiguous?Fabio Zadrozny fabiofz at gmail.com
Sun Mar 8 21:38:49 CET 2009
>> I was wondering how does Python
>> disambiguate that... anyone has any pointers on it?
>
> That is easy to answer:
>
> py> parser.expr("f(*x)").totuple()
> (258, (326, (303, (304, (305, (306, (307, (309, (310, (311, (312, (313,
> (314, (315, (316, (317, (1, 'f')), (321, (7, '('), (329, (16, '*'),
> (303, (304, (305, (306, (307, (309, (310, (311, (312, (313, (314, (315,
> (316, (317, (1, 'x')))))))))))))))), (8, ')')))))))))))))))), (4, ''),
> (0, ''))
> py> symbol.arglist
> 329
>
> So much for the "how", I don't know why it makes this choice; notice
> that this is the better choice, though:
>
> py> f((*x))
>  File "<stdin>", line 1
> SyntaxError: can use starred expression only as assignment target


Yeap, very strange that it works... I can't get it to work in JavaCC.

I'm considering setting arglist as
((argument() [','])+  ['**' test])
| '**' test

Because it is able to handle the constructs removing the ambiguity,
and make things right semantically later on, but I don't like the idea
of being so different from the official grammar (although I'm running
out of choices).

Thanks,

Fabio
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4