Commit 16a3d38b authored by Stefan Behnel's avatar Stefan Behnel

adapt grammar to CPython (3.6-pre)

- comma at end of any argument list (even in lambdas)
- "yield from" does not accept implicit tuple arguments
parent 18dfcc5a
...@@ -8,6 +8,9 @@ Latest changes ...@@ -8,6 +8,9 @@ Latest changes
Features added Features added
-------------- --------------
* Parser was adapted to some minor syntax changes in Py3.6, e.g.
https://bugs.python.org/issue9232
Bugs fixed Bugs fixed
---------- ----------
......
...@@ -364,7 +364,8 @@ def p_yield_expression(s): ...@@ -364,7 +364,8 @@ def p_yield_expression(s):
is_yield_from = True is_yield_from = True
s.next() s.next()
if s.sy != ')' and s.sy not in statement_terminators: if s.sy != ')' and s.sy not in statement_terminators:
arg = p_testlist(s) # "yield from" does not support implicit tuples, but "yield" does ("yield 1,2")
arg = p_test(s) if is_yield_from else p_testlist(s)
else: else:
if is_yield_from: if is_yield_from:
s.error("'yield from' requires a source argument", s.error("'yield from' requires a source argument",
...@@ -2673,7 +2674,7 @@ def p_exception_value_clause(s): ...@@ -2673,7 +2674,7 @@ def p_exception_value_clause(s):
exc_val = p_test(s) exc_val = p_test(s)
return exc_val, exc_check return exc_val, exc_check
c_arg_list_terminators = cython.declare(set, set(['*', '**', '.', ')'])) c_arg_list_terminators = cython.declare(set, set(['*', '**', '.', ')', ':']))
def p_c_arg_list(s, ctx = Ctx(), in_pyfunc = 0, cmethod_flag = 0, def p_c_arg_list(s, ctx = Ctx(), in_pyfunc = 0, cmethod_flag = 0,
nonempty_declarators = 0, kw_only = 0, annotated = 1): nonempty_declarators = 0, kw_only = 0, annotated = 1):
...@@ -3111,6 +3112,8 @@ def p_varargslist(s, terminator=')', annotated=1): ...@@ -3111,6 +3112,8 @@ def p_varargslist(s, terminator=')', annotated=1):
if s.sy == '**': if s.sy == '**':
s.next() s.next()
starstar_arg = p_py_arg_decl(s, annotated=annotated) starstar_arg = p_py_arg_decl(s, annotated=annotated)
if s.sy == ',':
s.next()
return (args, star_arg, starstar_arg) return (args, star_arg, starstar_arg)
def p_py_arg_decl(s, annotated = 1): def p_py_arg_decl(s, annotated = 1):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment