From 9952fc9646c5ffa333f1eaf7412763df3cb2e890 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 30 Nov 1993 13:40:46 +0000 Subject: * 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. --- Grammar/Grammar | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'Grammar') diff --git a/Grammar/Grammar b/Grammar/Grammar index 1094b09d75..6be7418b5f 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)* [','] -- cgit v1.2.1