summaryrefslogtreecommitdiffstats
path: root/Grammar
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1993-11-30 13:40:46 (GMT)
committerGuido van Rossum <guido@python.org>1993-11-30 13:40:46 (GMT)
commit590baa4a7a43b596119b47f605e3e570c2b3b0ee (patch)
tree767cbcf90f5b53bf63be9c2ea9a8081551120f10 /Grammar
parent8732d6aeea250f23af50b772d710109c9ee3bc00 (diff)
downloadcpython-590baa4a7a43b596119b47f605e3e570c2b3b0ee.zip
cpython-590baa4a7a43b596119b47f605e3e570c2b3b0ee.tar.gz
cpython-590baa4a7a43b596119b47f605e3e570c2b3b0ee.tar.bz2
* 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.
Diffstat (limited to 'Grammar')
-rw-r--r--Grammar/Grammar12
1 files changed, 8 insertions, 4 deletions
diff --git a/Grammar/Grammar b/Grammar/Grammar
index 1094b09..6be7418 100644
--- a/Grammar/Grammar
+++ b/Grammar/Grammar
@@ -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)* [',']