Added varargs syntax "def f(a, b, +c): ..."

This commit is contained in:
Guido van Rossum 1992-01-14 18:27:17 +00:00
parent e9cde31c47
commit 526e909614
1 changed files with 11 additions and 5 deletions

View File

@ -1,7 +1,12 @@
# Grammar for Python, version 10 # Grammar for Python
# Changes since version 9: # Change log:
# Equality is now only tested with '=='
# 11-Jan-92:
# Variable length argument list syntax added: def f(a, b, +rest): ...
# 8-Jan-92:
# Allow only '==' for equality testing
# Changes since version 8: # Changes since version 8:
# Trailing commas in formal parameter lists are allowed # Trailing commas in formal parameter lists are allowed
@ -56,9 +61,10 @@ expr_input: testlist NEWLINE
eval_input: testlist ENDMARKER eval_input: testlist ENDMARKER
funcdef: 'def' NAME parameters ':' suite funcdef: 'def' NAME parameters ':' suite
parameters: '(' [fplist] ')' parameters: '(' [varargslist] ')'
fplist: fpdef (',' fpdef)* [','] varargslist: (fpdef ',')* '+' NAME | fpdef (',' fpdef)* [',']
fpdef: NAME | '(' fplist ')' fpdef: NAME | '(' fplist ')'
fplist: fpdef (',' fpdef)* [',']
stmt: simple_stmt | compound_stmt stmt: simple_stmt | compound_stmt
simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE