mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
* import.c (get_module): pass .py filename to parse_file, not .pyc filename!
* funcobject.c (func_repr): don't call getstringvalue(None) for anonymous
functions.
* bltinmodule.c: removed lambda (which is now a built-in function);
removed implied lambda for string arg to filter/map/reduce.
* Grammar, graminit.[ch], compile.[ch]: replaced lambda as built-in
function by lambda as grammar entity: instead of "lambda('x: x+1')" you
write "lambda x: x+1".
* Xtmodule.c (checkargdict): return 0, not NULL, for error.
This commit is contained in:
parent
8732d6aeea
commit
590baa4a7a
8 changed files with 757 additions and 783 deletions
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
# Change log:
|
||||
|
||||
# 30-Nov-93:
|
||||
# Removed lambda_input, added lambdef
|
||||
|
||||
# 25-Oct-93:
|
||||
# Added lambda_input
|
||||
|
||||
|
|
@ -77,14 +80,12 @@
|
|||
# Start symbols for the grammar:
|
||||
# single_input is a single interactive statement;
|
||||
# file_input is a module or sequence of commands read from an input file;
|
||||
# eval_input is the input for the eval() and input() functions;
|
||||
# lambda_input is the input for the proposed lambda() function.
|
||||
# eval_input is the input for the eval() and input() functions.
|
||||
|
||||
# NB: compound_stmt in single_input is followed by extra NEWLINE!
|
||||
single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE
|
||||
file_input: (NEWLINE | stmt)* ENDMARKER
|
||||
eval_input: testlist NEWLINE* ENDMARKER
|
||||
lambda_input: varargslist ':' testlist NEWLINE* ENDMARKER
|
||||
|
||||
funcdef: 'def' NAME parameters ':' suite
|
||||
parameters: '(' [varargslist] ')'
|
||||
|
|
@ -134,7 +135,10 @@ shift_expr: arith_expr (('<<'|'>>') arith_expr)*
|
|||
arith_expr: term (('+'|'-') term)*
|
||||
term: factor (('*'|'/'|'%') factor)*
|
||||
factor: ('+'|'-'|'~') factor | atom trailer*
|
||||
atom: '(' [testlist] ')' | '[' [testlist] ']' | '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING
|
||||
atom: '(' [testlist] ')' | '[' [testlist] ']' | '{' [dictmaker] '}' | '`' testlist '`' | lambdef | NAME | NUMBER | STRING
|
||||
# Note ambiguity in grammar: "lambda x: x[1]" could mean "(lambda x: x)[1]"
|
||||
# but the parser is eager so interprets it as "lambda x: (x[1])"...
|
||||
lambdef: 'lambda' [varargslist] ':' test
|
||||
trailer: '(' [testlist] ')' | '[' subscript ']' | '.' NAME
|
||||
subscript: test | [test] ':' [test]
|
||||
exprlist: expr (',' expr)* [',']
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue