Commit 0a9cecf7 authored by Stefan Behnel's avatar Stefan Behnel

clean up some whitespace in parser code

parent 0a375513
...@@ -1097,6 +1097,7 @@ def p_genexp(s, expr): ...@@ -1097,6 +1097,7 @@ def p_genexp(s, expr):
expr_terminators = cython.declare(set, set([ expr_terminators = cython.declare(set, set([
')', ']', '}', ':', '=', 'NEWLINE'])) ')', ']', '}', ':', '=', 'NEWLINE']))
#------------------------------------------------------- #-------------------------------------------------------
# #
# Statements # Statements
...@@ -1110,12 +1111,14 @@ def p_global_statement(s): ...@@ -1110,12 +1111,14 @@ def p_global_statement(s):
names = p_ident_list(s) names = p_ident_list(s)
return Nodes.GlobalNode(pos, names = names) return Nodes.GlobalNode(pos, names = names)
def p_nonlocal_statement(s): def p_nonlocal_statement(s):
pos = s.position() pos = s.position()
s.next() s.next()
names = p_ident_list(s) names = p_ident_list(s)
return Nodes.NonlocalNode(pos, names = names) return Nodes.NonlocalNode(pos, names = names)
def p_expression_or_assignment(s): def p_expression_or_assignment(s):
expr_list = [p_testlist_star_expr(s)] expr_list = [p_testlist_star_expr(s)]
if s.sy == '=' and expr_list[0].is_starred: if s.sy == '=' and expr_list[0].is_starred:
...@@ -1140,7 +1143,7 @@ def p_expression_or_assignment(s): ...@@ -1140,7 +1143,7 @@ def p_expression_or_assignment(s):
lhs.pos, lhs.pos,
base=lhs.base, base=lhs.base,
index=make_slice_node(lhs.pos, lhs.start, lhs.stop)) index=make_slice_node(lhs.pos, lhs.start, lhs.stop))
elif not isinstance(lhs, (ExprNodes.AttributeNode, ExprNodes.IndexNode, ExprNodes.NameNode) ): elif not isinstance(lhs, (ExprNodes.AttributeNode, ExprNodes.IndexNode, ExprNodes.NameNode)):
error(lhs.pos, "Illegal operand for inplace operation.") error(lhs.pos, "Illegal operand for inplace operation.")
operator = s.sy[:-1] operator = s.sy[:-1]
s.next() s.next()
...@@ -1148,17 +1151,16 @@ def p_expression_or_assignment(s): ...@@ -1148,17 +1151,16 @@ def p_expression_or_assignment(s):
rhs = p_yield_expression(s) rhs = p_yield_expression(s)
else: else:
rhs = p_testlist(s) rhs = p_testlist(s)
return Nodes.InPlaceAssignmentNode(lhs.pos, operator = operator, lhs = lhs, rhs = rhs) return Nodes.InPlaceAssignmentNode(lhs.pos, operator=operator, lhs=lhs, rhs=rhs)
expr = expr_list[0] expr = expr_list[0]
return Nodes.ExprStatNode(expr.pos, expr=expr) return Nodes.ExprStatNode(expr.pos, expr=expr)
rhs = expr_list[-1] rhs = expr_list[-1]
if len(expr_list) == 2: if len(expr_list) == 2:
return Nodes.SingleAssignmentNode(rhs.pos, return Nodes.SingleAssignmentNode(rhs.pos, lhs=expr_list[0], rhs=rhs)
lhs = expr_list[0], rhs = rhs)
else: else:
return Nodes.CascadedAssignmentNode(rhs.pos, return Nodes.CascadedAssignmentNode(rhs.pos, lhs_list=expr_list[:-1], rhs=rhs)
lhs_list = expr_list[:-1], rhs = rhs)
def p_print_statement(s): def p_print_statement(s):
# s.sy == 'print' # s.sy == 'print'
...@@ -1182,10 +1184,11 @@ def p_print_statement(s): ...@@ -1182,10 +1184,11 @@ def p_print_statement(s):
ends_with_comma = 1 ends_with_comma = 1
break break
args.append(p_test(s)) args.append(p_test(s))
arg_tuple = ExprNodes.TupleNode(pos, args = args) arg_tuple = ExprNodes.TupleNode(pos, args=args)
return Nodes.PrintStatNode(pos, return Nodes.PrintStatNode(pos,
arg_tuple = arg_tuple, stream = stream, arg_tuple=arg_tuple, stream=stream,
append_newline = not ends_with_comma) append_newline=not ends_with_comma)
def p_exec_statement(s): def p_exec_statement(s):
# s.sy == 'exec' # s.sy == 'exec'
......
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