dpmxl.references¶
Static analysis of what a rule reads. See Analyse rules statically.
dpmxl.references
¶
Static analysis: the selections and templates an expression refers to.
Reference
dataclass
¶
Reference(spec: SelectionSpec, span: tuple[int, int])
A selection completed by its inherited with context.
spec.table is the table code of a cell selection; for a table group
({g_Group, ...}) or operation ({o_Code, ...}) reference it is
None and kind and
code say what is referenced. Typed
parameters ({p_Name, ...}) are not selections and are not listed.
Attributes:
-
spec(SelectionSpec) –The selection with its
withcontext applied. -
span(tuple[int, int]) –The selection's source span.
kind
property
¶
What the selection reads: a table, a table group or an operation.
references
¶
Return every selection with its inherited context applied.
Table-group and operation references are included with spec.table set to
None: check Reference.kind and read the
group or operation code from Reference.code. A
group read reads every table the provider's table_group(code) lists;
tables expands groups that way when given the provider.
Targets of persistent assignments are included too.
Returns:
-
tuple[Reference, ...]–tuple[Reference, ...]: Selections in source order.
Examples:
>>> from dpmxl import parse
>>> node = parse("with {tC_01.00, c0010}: {r0010} = {r0020} + {g_G1, r0010}")
>>> [(ref.spec.text(), ref.kind, ref.code) for ref in references(node)]
...
[('{tC_01.00, r0010, c0010}', 'table', 'C_01.00'),
('{tC_01.00, r0020, c0010}', 'table', 'C_01.00'),
('{gG1, r0010, c0010}', 'table_group', 'G1')]
tables
¶
tables(
node: Node, provider: object | None = None
) -> tuple[str, ...]
Return the distinct table codes referenced by cell selections.
Parameters:
-
node(Node) –The expression tree.
-
provider(object | None, default:None) –Optional provider whose
table_group(code)method resolves table groups; each group read then counts as reading all its tables. Without it, groups are left out.
Returns:
-
tuple[str, ...]–tuple[str, ...]: Table codes in first-seen order.
Examples: