]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.10] Update grammar_grapher with the new forced (&&) directive (GH-31704) (GH-31719)
authorLuca Chiodini <luca@chiodini.org>
Mon, 7 Mar 2022 14:54:08 +0000 (15:54 +0100)
committerGitHub <noreply@github.com>
Mon, 7 Mar 2022 14:54:08 +0000 (14:54 +0000)
(cherry picked from commit 7f07b5ee9c2d17f837c44440bf066c73f92dac14)

Co-authored-by: Luca Chiodini <luca@chiodini.org>
Tools/peg_generator/scripts/grammar_grapher.py

index 4afdbce8f966f2c7ca0b17820445c30124498ba6..c527e19b20997919383189381858390f32fb0e85 100755 (executable)
@@ -29,6 +29,7 @@ from pegen.build import build_parser
 from pegen.grammar import (
     Alt,
     Cut,
+    Forced,
     Grammar,
     Group,
     Leaf,
@@ -57,6 +58,8 @@ def references_for_item(item: Any) -> List[Any]:
         return [_ref for _item in item.items for _ref in references_for_item(_item)]
     elif isinstance(item, Cut):
         return []
+    elif isinstance(item, Forced):
+        return references_for_item(item.node)
     elif isinstance(item, Group):
         return references_for_item(item.rhs)
     elif isinstance(item, Lookahead):