[Python-Dev] add new lambda syntax (original) (raw)

Amaury Forgeot d'Arc amauryfa at gmail.com
Fri Jun 28 19:01:47 CEST 2013


2013/6/28 Pynix Wang <pynix.wang at gmail.com>

I want use coffeescript function syntax to write python lambda expression so I modified the Grammar file.

_ _atom: ('(' [yieldexpr|testlistcomp|vararglist] ')' |_ _'[' [testlistcomp] ']' |_ _'{' [dictorsetmaker] '}' |_ _NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False')_ _trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME | '->' text_ _ but when I write _ _(x,y=1)->x+y_ _ the parser doesn't go into vararglist.

This grammar is not LL(1) anymore (it's probably LALR now) when seeing "x", it has the choice between testlist_comp and vararglist, and the first one is picked. Python's parser generator only supports LL(1) grammars.

-- Amaury Forgeot d'Arc -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130628/a191a82a/attachment.html>



More information about the Python-Dev mailing list