have compund statements

This commit is contained in:
Anthony Scopatz 2015-01-25 18:34:30 -06:00
parent 8faf25d351
commit d03685f74b
2 changed files with 19 additions and 2 deletions

View file

@ -431,6 +431,21 @@ def test_dictcomp_if_dictcomp_if():
def test_equals():
yield check_stmts, 'x = 42'
def test_equals_semi():
yield check_stmts, 'x = 42;'
def test_equals_two():
yield check_stmts, 'x = 42; y = 65'
def test_equals_two_semi():
yield check_stmts, 'x = 42; y = 65;'
def test_equals_three():
yield check_stmts, 'x = 42; y = 65; z = 6'
def test_equals_three_semi():
yield check_stmts, 'x = 42; y = 65; z = 6;'

View file

@ -418,14 +418,16 @@ class Parser(object):
def p_semi_small_stmt(self, p):
"""semi_small_stmt : SEMI small_stmt"""
p[0] = p[1] + p[2]
p[0] = [p[2]]
def p_simple_stmt(self, p):
"""simple_stmt : small_stmt semi_small_stmt_list_opt semi_opt NEWLINE
| small_stmt semi_small_stmt_list semi_opt NEWLINE
| small_stmt semi_opt NEWLINE
"""
p1, p2 = p[1], p[2]
p0 = [p1]
if p2 is not None:
if p2 is not None and p2 != ';':
p0 += p2
p[0] = p0