Skip to content

Commit

Permalink
rf: Walk all rules, collect all names
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Aug 30, 2024
1 parent 0f7bfb1 commit 2b16673
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tools/schemacode/bidsschematools/tests/test_expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@
import pytest
from pyparsing.exceptions import ParseException

from ..expressions import Array, ASTNode, BinOp, Function, Property, RightOp, expression
from ..expressions import (
Array,
ASTNode,
BinOp,
Element,
Function,
Property,
RightOp,
expression,
)
from ..types import Namespace


Expand Down Expand Up @@ -148,6 +157,13 @@ def find_names(node: Union[ASTNode, str]):
elif isinstance(node, Array):
for element in node.elements:
yield from find_names(element)
elif isinstance(node, Element):
yield from find_names(node.name)
yield from find_names(node.index)
elif isinstance(node, (int, float)):
return
else:
raise TypeError(f"Unexpected node type: {node!r}")


@find_names.register
Expand Down

0 comments on commit 2b16673

Please sign in to comment.