Kaydet (Commit) 5e83b7a9 authored tarafından Michael W. Hudson's avatar Michael W. Hudson

Teach the parsermodule about floor division. Fixes

[ 676521 ] parser module validation failure

bugfix candidate.
üst 090da4b6
...@@ -51,6 +51,10 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase): ...@@ -51,6 +51,10 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
self.check_expr("foo(a, b, c, *args, **kw)") self.check_expr("foo(a, b, c, *args, **kw)")
self.check_expr("foo(a, b, c, **kw)") self.check_expr("foo(a, b, c, **kw)")
self.check_expr("foo + bar") self.check_expr("foo + bar")
self.check_expr("foo - bar")
self.check_expr("foo * bar")
self.check_expr("foo / bar")
self.check_expr("foo // bar")
self.check_expr("lambda: 0") self.check_expr("lambda: 0")
self.check_expr("lambda x: 0") self.check_expr("lambda x: 0")
self.check_expr("lambda *y: 0") self.check_expr("lambda *y: 0")
...@@ -85,6 +89,7 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase): ...@@ -85,6 +89,7 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
self.check_suite("a -= b") self.check_suite("a -= b")
self.check_suite("a *= b") self.check_suite("a *= b")
self.check_suite("a /= b") self.check_suite("a /= b")
self.check_suite("a //= b")
self.check_suite("a %= b") self.check_suite("a %= b")
self.check_suite("a &= b") self.check_suite("a &= b")
self.check_suite("a |= b") self.check_suite("a |= b")
......
...@@ -1440,6 +1440,7 @@ validate_expr_stmt(node *tree) ...@@ -1440,6 +1440,7 @@ validate_expr_stmt(node *tree)
|| strcmp(s, "-=") == 0 || strcmp(s, "-=") == 0
|| strcmp(s, "*=") == 0 || strcmp(s, "*=") == 0
|| strcmp(s, "/=") == 0 || strcmp(s, "/=") == 0
|| strcmp(s, "//=") == 0
|| strcmp(s, "%=") == 0 || strcmp(s, "%=") == 0
|| strcmp(s, "&=") == 0 || strcmp(s, "&=") == 0
|| strcmp(s, "|=") == 0 || strcmp(s, "|=") == 0
...@@ -2095,6 +2096,7 @@ validate_term(node *tree) ...@@ -2095,6 +2096,7 @@ validate_term(node *tree)
for ( ; res && (pos < nch); pos += 2) for ( ; res && (pos < nch); pos += 2)
res = (((TYPE(CHILD(tree, pos)) == STAR) res = (((TYPE(CHILD(tree, pos)) == STAR)
|| (TYPE(CHILD(tree, pos)) == SLASH) || (TYPE(CHILD(tree, pos)) == SLASH)
|| (TYPE(CHILD(tree, pos)) == DOUBLESLASH)
|| (TYPE(CHILD(tree, pos)) == PERCENT)) || (TYPE(CHILD(tree, pos)) == PERCENT))
&& validate_factor(CHILD(tree, pos + 1))); && validate_factor(CHILD(tree, pos + 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