diff options
author | alandonovan <adonovan@google.com> | 2018-03-06 16:35:26 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-06 16:35:26 -0500 |
commit | ae01c0c66bdda9cb627eefcef207464143ec6d2e (patch) | |
tree | 7fced2da048846049fdfcbaea7150e7bab84bd5d | |
parent | 601ada0289bb4da7220ae07a66667c1ff510e717 (diff) | |
download | starlark-go-ae01c0c66bdda9cb627eefcef207464143ec6d2e.tar.gz |
grammar: fix two problems with CallSuffix (#82)
1. Unlike parameters, the operands of *args and **kwargs used as
arguments may be any Test expression, not just an identifier.
2. A trailing comma is not permitted after *args or **kwargs.
The implementation already does the right thing (following Python 3).
-rw-r--r-- | doc/spec.md | 5 | ||||
-rw-r--r-- | syntax/grammar.txt | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/doc/spec.md b/doc/spec.md index 0f4f193..5d6205f 100644 --- a/doc/spec.md +++ b/doc/spec.md @@ -1500,6 +1500,9 @@ Operand = identifier DotSuffix = '.' identifier . CallSuffix = '(' [Arguments [',']] ')' . SliceSuffix = '[' [Expression] [':' Test [':' Test]] ']' . + +# A CallSuffix does not allow a trailing comma +# if the last argument is '*' Test or '**' Test. ``` TODO: resolve position of +x, -x, and 'not x' in grammar: Operand or UnaryExpr? @@ -2084,7 +2087,7 @@ print(x) # 1 CallSuffix = '(' [Arguments] ')' . Arguments = Argument {',' Argument} . -Argument = Test | identifier '=' Test | '*' identifier | '**' identifier . +Argument = Test | identifier '=' Test | '*' Test | '**' Test . ``` A value `f` of type `function` or `builtin_function_or_method` may be called using the expression `f(...)`. diff --git a/syntax/grammar.txt b/syntax/grammar.txt index 6d914e0..47f0312 100644 --- a/syntax/grammar.txt +++ b/syntax/grammar.txt @@ -66,8 +66,11 @@ DotSuffix = '.' identifier . CallSuffix = '(' [Arguments [',']] ')' . SliceSuffix = '[' [Expression] [':' Test [':' Test]] ']' . +# A CallSuffix does not allow a trailing comma +# if the last argument is '*' Test or '**' Test. + Arguments = Argument {',' Argument} . -Argument = Test | identifier '=' Test | '*' identifier | '**' identifier . +Argument = Test | identifier '=' Test | '*' Test | '**' Test . ListExpr = '[' [Expression [',']] ']' . ListComp = '[' Test {CompClause} ']'. |