Update grammar_grapher with the new forced (&&) directive (#31704)

This commit is contained in:
Luca Chiodini 2022-03-06 15:26:28 +01:00 committed by GitHub
parent eafec26ae5
commit 7f07b5ee9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,6 +29,7 @@ from pegen.build import build_parser
from pegen.grammar import (
Alt,
Cut,
Forced,
Grammar,
Group,
Leaf,
@ -60,6 +61,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):