mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 16:34:47 +01:00
arglist rearrangement
This commit is contained in:
parent
39f04896f7
commit
e7df9fbe46
1 changed files with 74 additions and 54 deletions
|
@ -199,7 +199,7 @@ class Parser(object):
|
||||||
self.lexer = lexer = Lexer()
|
self.lexer = lexer = Lexer()
|
||||||
self.tokens = lexer.tokens
|
self.tokens = lexer.tokens
|
||||||
|
|
||||||
opt_rules = (
|
opt_rules = [
|
||||||
'newlines', 'arglist', 'func_call', 'rarrow_test', 'typedargslist',
|
'newlines', 'arglist', 'func_call', 'rarrow_test', 'typedargslist',
|
||||||
'equals_test', 'colon_test', 'tfpdef', 'comma_tfpdef_list',
|
'equals_test', 'colon_test', 'tfpdef', 'comma_tfpdef_list',
|
||||||
'comma_pow_tfpdef', 'vfpdef', 'comma_vfpdef_list',
|
'comma_pow_tfpdef', 'vfpdef', 'comma_vfpdef_list',
|
||||||
|
@ -213,12 +213,13 @@ class Parser(object):
|
||||||
'op_factor_list', 'trailer_list', 'testlist_comp',
|
'op_factor_list', 'trailer_list', 'testlist_comp',
|
||||||
'yield_expr_or_testlist_comp', 'dictorsetmaker',
|
'yield_expr_or_testlist_comp', 'dictorsetmaker',
|
||||||
'comma_subscript_list', 'test', 'sliceop', 'comp_iter',
|
'comma_subscript_list', 'test', 'sliceop', 'comp_iter',
|
||||||
'yield_arg', 'argument_comma_list', 'comma_argument_list',
|
'yield_arg', 'test_comma_list',]
|
||||||
'test_comma_list', )
|
if VER_MAJOR_MINOR <= VER_3_4:
|
||||||
|
opt_rules += ['argument_comma_list', 'comma_argument_list',]
|
||||||
for rule in opt_rules:
|
for rule in opt_rules:
|
||||||
self._opt_rule(rule)
|
self._opt_rule(rule)
|
||||||
|
|
||||||
list_rules = (
|
list_rules = [
|
||||||
'comma_tfpdef', 'comma_vfpdef', 'semi_small_stmt',
|
'comma_tfpdef', 'comma_vfpdef', 'semi_small_stmt',
|
||||||
'comma_test_or_star_expr', 'period_or_ellipsis',
|
'comma_test_or_star_expr', 'period_or_ellipsis',
|
||||||
'comma_import_as_name', 'comma_dotted_as_name', 'period_name',
|
'comma_import_as_name', 'comma_dotted_as_name', 'period_name',
|
||||||
|
@ -226,9 +227,10 @@ class Parser(object):
|
||||||
'or_and_test', 'and_not_test', 'comp_op_expr', 'pipe_xor_expr',
|
'or_and_test', 'and_not_test', 'comp_op_expr', 'pipe_xor_expr',
|
||||||
'xor_and_expr', 'ampersand_shift_expr', 'shift_arith_expr',
|
'xor_and_expr', 'ampersand_shift_expr', 'shift_arith_expr',
|
||||||
'pm_term', 'op_factor', 'trailer', 'comma_subscript',
|
'pm_term', 'op_factor', 'trailer', 'comma_subscript',
|
||||||
'comma_expr_or_star_expr', 'comma_test', 'argument_comma',
|
'comma_expr_or_star_expr', 'comma_test', 'comma_argument', 'comma_item',
|
||||||
'comma_argument', 'comma_item', 'attr_period_name', 'test_comma',
|
'attr_period_name', 'test_comma', 'equals_yield_expr_or_testlist', ]
|
||||||
'equals_yield_expr_or_testlist', )
|
if VER_MAJOR_MINOR <= VER_3_4:
|
||||||
|
list_rules += ['argument_comma',]
|
||||||
for rule in list_rules:
|
for rule in list_rules:
|
||||||
self._list_rule(rule)
|
self._list_rule(rule)
|
||||||
|
|
||||||
|
@ -1978,6 +1980,23 @@ class Parser(object):
|
||||||
else:
|
else:
|
||||||
args['args'].append(arg)
|
args['args'].append(arg)
|
||||||
|
|
||||||
|
#
|
||||||
|
# arglist rule had significant changes
|
||||||
|
#
|
||||||
|
if VER_3_5 <= VER_MAJOR_MINOR:
|
||||||
|
def p_arglist(self, p):
|
||||||
|
"""arglist : argument comma_opt
|
||||||
|
| argument comma_argument_list comma_opt
|
||||||
|
"""
|
||||||
|
p0 = {'args': [], 'keywords': []}
|
||||||
|
p1, p2 = p[1], p[2]
|
||||||
|
p2 = None if p2 == ',' else p2
|
||||||
|
self._set_arg(p0, p1)
|
||||||
|
if p2 is not None:
|
||||||
|
for arg in p2:
|
||||||
|
self._set_arg(p0, arg)
|
||||||
|
p[0] = p0
|
||||||
|
else: # Python v3.4
|
||||||
def p_arglist(self, p):
|
def p_arglist(self, p):
|
||||||
"""arglist : argument comma_opt
|
"""arglist : argument comma_opt
|
||||||
| argument_comma_list argument comma_opt
|
| argument_comma_list argument comma_opt
|
||||||
|
@ -2027,12 +2046,13 @@ class Parser(object):
|
||||||
assert False
|
assert False
|
||||||
p[0] = p0
|
p[0] = p0
|
||||||
|
|
||||||
|
if VER_MAJOR_MINOR <= VER_3_4:
|
||||||
def p_argument_comma(self, p):
|
def p_argument_comma(self, p):
|
||||||
"""argument_comma : argument COMMA"""
|
"""argument_comma : argument COMMA"""
|
||||||
p[0] = [p[1]]
|
p[0] = [p[1]]
|
||||||
|
|
||||||
def p_comma_argument(self, p):
|
def p_comma_argument(self, p):
|
||||||
"""comma_argument : COMMA argument """
|
"""comma_argument : COMMA argument"""
|
||||||
p[0] = [p[2]]
|
p[0] = [p[2]]
|
||||||
|
|
||||||
@docstring_by_version(
|
@docstring_by_version(
|
||||||
|
|
Loading…
Add table
Reference in a new issue