Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 526e909

Browse files
committed
Added varargs syntax "def f(a, b, +c): ..."
1 parent e9cde31 commit 526e909

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

Grammar/Grammar

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
# Grammar for Python, version 10
1+
# Grammar for Python
22

3-
# Changes since version 9:
4-
# Equality is now only tested with '=='
3+
# Change log:
4+
5+
# 11-Jan-92:
6+
# Variable length argument list syntax added: def f(a, b, +rest): ...
7+
8+
# 8-Jan-92:
9+
# Allow only '==' for equality testing
510

611
# Changes since version 8:
712
# Trailing commas in formal parameter lists are allowed
@@ -56,9 +61,10 @@ expr_input: testlist NEWLINE
5661
eval_input: testlist ENDMARKER
5762

5863
funcdef: 'def' NAME parameters ':' suite
59-
parameters: '(' [fplist] ')'
60-
fplist: fpdef (',' fpdef)* [',']
64+
parameters: '(' [varargslist] ')'
65+
varargslist: (fpdef ',')* '+' NAME | fpdef (',' fpdef)* [',']
6166
fpdef: NAME | '(' fplist ')'
67+
fplist: fpdef (',' fpdef)* [',']
6268

6369
stmt: simple_stmt | compound_stmt
6470
simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE

0 commit comments

Comments
 (0)