Parser¶
parse and parse_file read QVR source into AST nodes
(grammar) and raise ParseError on malformed syntax, before
any tensor is created. A tree that parses may still have mismatched types, unresolved names, or
unsupported effects, which later checking
rejects.
parser
¶
Parser for the quivers DSL.
The lexer/parser pipeline is delegated to panproto after overriding its qvr
protocol with Quivers' packaged current grammar. The public parse entry
point consumes .qvr source bytes and returns a Module of didactic models.
This package's submodules group the walker logic by topic:
._registryfor the panproto registry singleton,ParseError, and the_Treeview that every walker reads from.._helpersfor the low-level helpers_required_text,_required_field,_field_text, and_walk_draw_arg..optionsfor the[k=v, ...]option-block walkers..expressionsfor type / space / morphism-expression / let-arith walkers..program_stepsfor program-block step walkers..statementsfor the top-level_walk_statementdispatcher and every per-declaration walker (object, morphism, deduction, contraction, signature, encoder, decoder, loss, ...)..corefor the publicparse/parse_fileentry points, the whole-tree syntax validation that rejects ERROR and missing nodes, and the refusal of binders spelled as the reserved let wordsRESERVED_LET_WORDS.
Every public name is re-exported here so from quivers.dsl.parser
import X keeps working unchanged.
RESERVED_LET_WORDS
module-attribute
¶
RESERVED_LET_WORDS: dict[str, str] = {'unit': 'the unit value', 'true': 'the Boolean literal true', 'false': 'the Boolean literal false', 'not': 'Boolean negation', 'factor': 'the factor comprehension', 'case': 'a case function', 'for': 'a tabulation'}
The words a let expression reads as something other than a name.
They are the unit value unit, the Booleans true and false,
the negation not, and the expression keywords factor, case and
for, each mapped to what it denotes. A binder spelled as one of them could never
be referred to, since every later occurrence parses as the literal or
the keyword, so a binder may not use them.
VALUE_METHODS
module-attribute
¶
VALUE_METHODS: Mapping[str, frozenset[str]] = MappingProxyType({'decoder': frozenset({'log_prob', 'sample'})})
Declaration kinds whose values have a fixed method interface, mapped to it.
A decoder's value has the interface of a distribution over terms
(quivers.structural.decoder.Decoder): D.log_prob(term, code) and
D.sample(code) call its methods. Any other segment after a decoder's
name names a member it generates, such as D.law or D.nll.
BINDER_POSITIONS
module-attribute
¶
BINDER_POSITIONS: frozenset[tuple[str, str]] = frozenset({('notation_production', 'items'), ('qiec_value_parameter', 'name'), ('qiec_type_binder', 'name'), ('qiec_index_binder', 'name'), ('qiec_index_map_clause', 'parameters'), ('qiec_effect_binder', 'name'), ('qiec_local_binding', 'name'), ('qiec_case_static_binder', 'name'), ('qiec_instance_computation', 'name'), ('qiec_as_pattern', 'name'), ('qiec_binder_pattern', 'binders'), ('let_lambda', 'param'), ('let_factor_binder', 'var'), ('let_axis_binder', 'name'), ('program_decl', 'params'), ('typed_program_param', 'name'), ('sample_step', 'vars'), ('observe_step', 'vars'), ('call_step', 'vars'), ('let_step', 'name'), ('score_step', 'name'), ('marginalize_step', 'var'), ('var_tuple', '<child>'), ('rule_decl', 'variables'), ('schema_parameter', 'names'), ('contraction_input', 'name'), ('composition_rule_entry', 'params'), ('syntax_decl', 'params'), ('argument_variable', 'name'), ('encoder_op_rule', 'args'), ('encoder_op_rule', 'state'), ('encoder_op_rule', 'prefix'), ('encoder_init_rule', 'arg'), ('encoder_message_rule', 'src'), ('encoder_message_rule', 'tgt'), ('encoder_update_rule', 'self'), ('encoder_update_rule', 'msgs'), ('decoder_structure', 'arg'), ('decoder_primitive', 'arg'), ('decoder_factor', 'arg'), ('decoder_binder_select', 'arg'), ('string_graph_variable', 'name'), ('object_term_abstraction', 'names'), ('context_entry', 'name'), ('judgment_argument', 'name'), ('judgment_rule', 'schematic'), ('pattern_synonym_decl', 'parameters'), ('test_binder', 'name'), ('test_let', 'name'), ('let_case_branch', 'binder'), ('category_binder', 'name'), ('deduction_template', 'parameter')})
Positions binding a local name.
CLOSED_KINDS
module-attribute
¶
CLOSED_KINDS: frozenset[str] = frozenset({'deduction_atoms', 'deduction_binders', 'deduction_lexicon', 'deduction_lexicon_from_file', 'rule_instantiations', 'schema_constraint', 'deduction_category_set', 'semantic_clause', 'deduction_template', 'deduction_lexical_rule'})
Node kinds whose whole subtree is the private language of a deduction.
DECLARATION_POSITIONS
module-attribute
¶
DECLARATION_POSITIONS: dict[tuple[str, str], str] = {('notation_decl', 'name'): 'notation', ('category_decl', 'names'): 'category', ('object_decl', 'names'): 'object', ('morphism_decl', 'names'): 'morphism', ('define_decl', 'name'): 'define', ('computation_decl', 'name'): 'computation', ('typed_hole_decl', 'name'): 'computation', ('score_binding_decl', 'name'): 'computation', ('program_decl', 'name'): 'program', ('deduction_decl', 'name'): 'deduction', ('deduction_signature_decl', 'name'): 'deduction_signature', ('lexicon_decl', 'name'): 'lexicon', ('syntax_decl', 'name'): 'syntax', ('constructor_decl', 'name'): 'constructor', ('encoder_decl', 'name'): 'encoder', ('decoder_decl', 'name'): 'decoder', ('loss_decl', 'name'): 'loss', ('contraction_decl', 'name'): 'contraction', ('bundle_decl', 'name'): 'bundle', ('rule_decl', 'name'): 'rule', ('schema_decl', 'name'): 'schema', ('composition_decl', 'name'): 'composition', ('index_decl', 'name'): 'index', ('index_map_decl', 'name'): 'index_map', ('qiec_index_constructor', 'name'): 'constructor', ('indexed_family_decl', 'name'): 'family', ('qiec_constructor_decl', 'name'): 'constructor', ('effect_decl', 'name'): 'effect', ('effect_instance_decl', 'name'): 'instance', ('handler_decl', 'name'): 'handler', ('interpretation_decl', 'name'): 'computation', ('relation_decl', 'name'): 'relation', ('relation_compose_decl', 'name'): 'relation', ('relation_transform_decl', 'name'): 'relation', ('string_graph_decl', 'name'): 'string_graph', ('scoped_operation_decl', 'name'): 'scoped_operation', ('effect_law_decl', 'name'): 'effect_law', ('judgment_decl', 'name'): 'judgment', ('pattern_synonym_decl', 'name'): 'pattern', ('record_decl', 'name'): 'record', ('signature_decl', 'name'): 'signature', ('family_spec', 'name'): 'family', ('computation_spec', 'name'): 'computation', ('deduction_spec', 'name'): 'deduction', ('module_decl', 'name'): 'module', ('theory_decl', 'name'): 'theory', ('view_decl', 'name'): 'view', ('model_decl', 'name'): 'model', ('semiring_decl', 'name'): 'semiring'}
Positions declaring a module-level name, mapped to the declaration kind.
LABEL_POSITIONS
module-attribute
¶
LABEL_POSITIONS: frozenset[tuple[str, str]] = frozenset({('qiec_index_map_clause', 'constructor'), ('quotation', '<child>'), ('quotation_pattern', '<child>'), ('notation_group', '<child>'), ('notation_block', '<child>'), ('notation_production', 'name'), ('notation_relation', 'tighter'), ('notation_relation', 'looser'), ('notation_relation', 'same'), ('open_notation_decl', 'notation'), ('option_entry', 'key'), ('experiment_decl', 'name'), ('experiment_data', 'name'), ('experiment_fix', 'name'), ('experiment_fix', 'value'), ('experiment_sweep', 'name'), ('experiment_infer', 'method'), ('let_hole', 'name'), ('qiec_type_hole', 'name'), ('sharing_constraint', 'name'), ('pragma_entry', 'key'), ('pragma_entry', 'value'), ('constructor_kwarg', 'key'), ('named_draw_arg', 'parameter'), ('let_named_argument', 'name'), ('let_reduction', 'operator'), ('return_label_entry', 'label'), ('qiec_record_field_pattern', 'label'), ('scan_expr', 'outputs'), ('sample_step', 'operation'), ('interpretation_clause', 'constructor'), ('qiec_handler_operation_clause', 'operation'), ('qiec_operation_decl', 'name'), ('effect_site_estimator', 'name'), ('effect_site_estimator', 'method'), ('enum_set_literal', 'elements'), ('free_residuated_arg', 'op'), ('equation_decl', 'name'), ('judgment_rule', 'name'), ('deriving_class', 'name'), ('deduction_rule', 'name'), ('rule_instantiation', 'schema'), ('schema_constraint', 'parameter'), ('schema_constraint', 'domain'), ('object_spine', 'slash'), ('object_spine', 'argument'), ('object_spine', 'length'), ('object_sequence', 'argument'), ('object_sequence', 'length'), ('let_case_branch', 'label'), ('let_injection', 'label'), ('let_record_field', 'label'), ('qiec_row_field', 'label'), ('deduction_atoms', 'atoms'), ('deduction_binders', 'binders'), ('atom_features', 'name'), ('atom_feature', 'name'), ('atom_feature', 'set'), ('category_binder', 'set'), ('deduction_category_set', 'name'), ('deduction_template', 'name'), ('object_features', 'atom'), ('sort_decl', 'name'), ('vertex_kind_decl', 'name'), ('edge_kind_decl', 'name'), ('edge_kind_decl', 'src'), ('edge_kind_decl', 'tgt'), ('constructor_decl', 'codomain'), ('constructor_argument', 'sort'), ('argument_variable', 'sort'), ('encoder_dim', 'sort'), ('decoder_dim', 'sort'), ('encoder_init_rule', 'kind'), ('encoder_message_rule', 'edge_kind'), ('encoder_update_rule', 'vertex_kind'), ('encoder_var_init', 'var_sort'), ('encoder_var_init', 'annot_sort'), ('encoder_var_init', 'ty'), ('theory_parameter', 'name'), ('theory_sort', 'name'), ('theory_binder', 'names'), ('theory_binder', 'sort'), ('theory_operation', 'name'), ('theory_operation', 'inputs'), ('theory_operation', 'output'), ('theory_argument', 'parameter'), ('theory_rename', 'source'), ('theory_rename', 'target'), ('theory_hiding', 'names'), ('view_mapping', 'source'), ('view_mapping', 'target'), ('view_assumption', 'equations'), ('model_interpretation', 'symbol'), ('semiring_decl', 'algebra'), ('deduction_semiring', 'name')})
Positions whose token names nothing in a scope.
MODULE_POSITIONS
module-attribute
¶
MODULE_POSITIONS: frozenset[tuple[str, str]] = frozenset({('import_decl', 'path'), ('import_decl', 'alias'), ('import_list', 'names'), ('open_decl', 'module'), ('module_parameter', 'name'), ('qiec_module_parameter', 'name'), ('qiec_implicit_module_parameter', 'name'), ('hole_decl', 'path'), ('link_decl', 'hole'), ('link_decl', 'module')})
Positions of the module system's own statements.
OTHER_REFERENCE_POSITIONS
module-attribute
¶
OTHER_REFERENCE_POSITIONS: frozenset[tuple[str, str]] = frozenset({('notation_decl', 'syntax'), ('notation_production', 'template'), ('antiquotation', 'name'), ('argument_variable', 'annotation'), ('hole_decl', 'signature'), ('experiment_program', 'entry'), ('experiment_handle', 'instance'), ('share_decl', 'site'), ('share_decl', 'target'), ('bracket_index_arg', 'name'), ('signature_expr', 'base'), ('signature_expr', 'core'), ('deduction_extension', 'name'), ('lexicon_reference', 'name'), ('lexicon_decl', 'signature'), ('bundle_decl', 'rules'), ('cap_expr', 'object'), ('composition_rule_entry', 'key'), ('constructor_kwarg', 'value'), ('context_entry', 'type'), ('context_extension', 'context'), ('continuous_constructor', 'args'), ('cup_expr', 'object'), ('decoder_decl', 'sig_args'), ('decoder_decl', 'signature'), ('deriving_class', 'morphisms'), ('deriving_decl', 'family'), ('discrete_constructor', 'cardinality'), ('effect_law_owner_decl', 'owner'), ('encoder_decl', 'sig_args'), ('encoder_decl', 'signature'), ('encoder_op_rule', 'op'), ('equation_decl', 'left'), ('equation_decl', 'right'), ('family_call_arg', 'args'), ('family_call_arg', 'family'), ('free_monoid_expr', 'generators'), ('free_residuated_expr', 'generators'), ('ident_list', '<child>'), ('identity_expr', 'object'), ('interpretation_clause', 'operation'), ('interpretation_decl', 'deduction'), ('judgment_rule', 'conclusion'), ('judgment_rule', 'premises'), ('judgment_sort', 'argument'), ('judgment_sort', 'name'), ('list_arg', '<child>'), ('marginalize_step', 'args'), ('marginalize_step', 'morphism'), ('marginalize_step', 'static_args'), ('method_call', 'args'), ('morphism_call', 'args'), ('morphism_call', 'static_args'), ('morphism_init_family', 'args'), ('morphism_init_family', 'family'), ('named_draw_arg', 'value'), ('object_atom', '<child>'), ('object_effect_apply', 'effect'), ('object_term_abstraction', 'body'), ('object_term_application', 'arguments'), ('object_term_application', 'head'), ('object_term_instantiation', 'arguments'), ('object_term_instantiation', 'head'), ('observe_step', 'args'), ('observe_step', 'morphism'), ('observe_step', 'static_args'), ('option_call', 'args'), ('option_call', 'func'), ('option_entry', 'value'), ('option_list', 'item'), ('parser_arg', 'value'), ('qiec_call_computation', 'callee'), ('qiec_constructor_pattern', 'constructor'), ('qiec_constructor_value', 'constructor'), ('qiec_effect_ref', 'name'), ('qiec_effect_row_literal', 'lacks'), ('qiec_effect_row_literal', 'tail'), ('qiec_handle_computation', 'instance'), ('qiec_handler_application', 'name'), ('qiec_index_application', 'constructor'), ('qiec_index_name', 'name'), ('qiec_index_sort', 'signature'), ('qiec_name_pattern', 'name'), ('qiec_record_type', 'tail'), ('qiec_row_entry', 'name'), ('qiec_row_predicate', 'larger'), ('qiec_row_predicate', 'left'), ('qiec_row_predicate', 'result'), ('qiec_row_predicate', 'right'), ('qiec_type_application', 'constructor'), ('qiec_type_name', 'name'), ('qiec_user_index_sort', 'name'), ('qiec_variant_type', 'tail'), ('qiec_weighted_total', 'action'), ('qiec_weighted_total', 'addition'), ('relation_arc_decl', 'weight'), ('relation_auto_intersection_recipe', 'source'), ('relation_binary_recipe', 'other'), ('relation_binary_recipe', 'source'), ('relation_boundary_decl', 'weight'), ('relation_compose_decl', 'left'), ('relation_compose_decl', 'right'), ('relation_conditioning_recipe', 'source'), ('relation_join_recipe', 'other'), ('relation_join_recipe', 'source'), ('relation_projection_recipe', 'source'), ('relation_tape_decl', 'alphabet'), ('relation_unary_recipe', 'source'), ('return_label_entry', 'var'), ('return_step', 'return'), ('return_tuple', '<child>'), ('sample_step', 'args'), ('sample_step', 'morphism'), ('sample_step', 'static_args'), ('scan_expr', 'init'), ('score_binding_decl', 'graph'), ('score_binding_decl', 'relation'), ('splice_decl', 'generator'), ('string_graph_factor', 'relation'), ('string_graph_factor', 'scope'), ('string_graph_variable', 'alphabet'), ('theory_argument', 'theory'), ('theory_argument', 'view'), ('theory_decl', 'value'), ('theory_hiding', 'theory'), ('theory_include', 'theory'), ('theory_instantiation', 'theory'), ('theory_parameter', 'theory'), ('theory_renaming', 'theory'), ('theory_sum', 'shared'), ('theory_sum', 'summands'), ('view_decl', 'codomain'), ('view_decl', 'domain'), ('model_decl', 'source'), ('model_decl', 'theory'), ('model_decl', 'view'), ('model_interpretation', 'value'), ('semiring_decl', 'theory'), ('semiring_decl', 'carrier'), ('deduction_semiring', 'instance'), ('deduction_semiring', 'theory'), ('deduction_refines', 'base'), ('deduction_semantics', 'judgment')})
The remaining reference positions: each token names something in scope (a
local, a declaration, an imported name, or a builtin) and trailing segments
of a dotted one are a qualified path. Every identifier position of the
grammar is in exactly one of these tables, which
tests/dsl/test_name_positions.py checks against the grammar.
REFERENCE_POSITIONS
module-attribute
¶
REFERENCE_POSITIONS: dict[tuple[str, str], Position] = {('expr_ident', '<child>'): 'morphism', ('morphism_call', 'callee'): 'morphism', ('let_var', '<child>'): 'value', ('let_call', 'func'): 'value', ('qiec_effect_request', 'target'): 'request', ('module_path', 'name'): 'module', ('module_application', 'functor'): 'module'}
Reference positions whose trailing segments are read as members of a value.
Every reference position not listed is other.
SEQUENTIAL_SCOPES
module-attribute
¶
SEQUENTIAL_SCOPES: dict[str, str] = {'program_decl': 'steps', 'marginalize_step': 'scope', 'test_decl': 'steps', 'example_decl': 'steps', 'property_decl': 'steps'}
Nodes whose list field binds sequentially: a step's binders are visible in the steps after it.
TREE_SCOPES
module-attribute
¶
TREE_SCOPES: dict[str, tuple[frozenset[str], frozenset[str]]] = {'qiec_pure_binding': (frozenset({'binder'}), frozenset({'then'})), 'qiec_bind_computation': (frozenset({'binder'}), frozenset({'then'})), 'qiec_case_branch': (frozenset({'pattern', 'constructor', 'binders', 'fields'}), frozenset({'body', 'guard'})), 'qiec_handler_return_clause': (frozenset({'binder'}), frozenset({'body'})), 'qiec_handler_operation_clause': (frozenset({'binders', 'parameters'}), frozenset({'body'})), 'qiec_instance_computation': (frozenset({'name'}), frozenset({'body'})), 'qiec_case_motive': (frozenset({'indices'}), frozenset({'result'})), 'qiec_index_map_clause': (frozenset({'parameters'}), frozenset({'body'})), 'interpretation_decl': (frozenset({'options'}), frozenset({'carrier'})), 'let_lambda': (frozenset({'param'}), frozenset({'body'})), 'let_factor': (frozenset({'binders'}), frozenset({'body', 'cases'})), 'let_tabulation': (frozenset({'binders'}), frozenset({'body'})), 'let_reduction': (frozenset({'binders'}), frozenset({'body'})), 'let_case_branch': (frozenset({'binder'}), frozenset({'body'})), 'lexicon_polymorphic_category': (frozenset({'binders'}), frozenset({'category'})), 'object_term_abstraction': (frozenset({'names'}), frozenset({'body'})), 'qiec_binder_pattern': (frozenset({'binders'}), frozenset({'body'})), 'marginalize_step': (frozenset({'var'}), frozenset({'scope'}))}
Nodes whose binders (found in the first fields) are visible in the subtrees of the second fields only.
VALUE_DECLARATION_KINDS
module-attribute
¶
VALUE_DECLARATION_KINDS: frozenset[str] = frozenset({'morphism', 'define', 'contraction', 'program', 'object', 'category'})
Declaration kinds whose values support member access: a morphism takes
postfix forms, so f.dagger is the dagger of f. Every other
declaration's dotted continuation names something it generates or contains
(G.Item, Vec.Cons).
WHOLE_SCOPES
module-attribute
¶
WHOLE_SCOPES: dict[str, frozenset[str]] = {'notation_production': frozenset({'items'}), 'computation_decl': frozenset({'binders', 'parameters'}), 'typed_hole_decl': frozenset({'binders', 'parameters'}), 'handler_decl': frozenset({'binders', 'parameters'}), 'indexed_family_decl': frozenset({'parameters', 'indices'}), 'qiec_constructor_decl': frozenset({'binders'}), 'effect_decl': frozenset({'binders'}), 'qiec_operation_decl': frozenset({'binders'}), 'program_decl': frozenset({'binders', 'parameters', 'params'}), 'rule_decl': frozenset({'variables'}), 'schema_decl': frozenset({'parameters'}), 'contraction_decl': frozenset({'inputs'}), 'composition_rule_entry': frozenset({'params'}), 'syntax_decl': frozenset({'params'}), 'constructor_decl': frozenset({'arguments'}), 'constructor_argument': frozenset({'binds'}), 'encoder_op_rule': frozenset({'args', 'state', 'prefix'}), 'encoder_init_rule': frozenset({'arg'}), 'encoder_message_rule': frozenset({'src', 'tgt'}), 'encoder_update_rule': frozenset({'self', 'msgs'}), 'decoder_structure': frozenset({'arg'}), 'decoder_primitive': frozenset({'arg'}), 'decoder_factor': frozenset({'arg'}), 'decoder_binder_select': frozenset({'arg'}), 'string_graph_decl': frozenset({'variables'}), 'judgment_decl': frozenset({'arguments'}), 'judgment_rule': frozenset({'schematic'}), 'context_extension': frozenset({'entries'}), 'pattern_synonym_decl': frozenset({'binders', 'parameters'}), 'property_decl': frozenset({'binders'}), 'deduction_template': frozenset({'parameter'})}
Nodes whose binders (found anywhere in the listed fields) are visible in the whole node.
WRAPPER_KINDS
module-attribute
¶
Wrappers around a top-level declaration.
MODULE_PARAMETER_KINDS
module-attribute
¶
MODULE_PARAMETER_KINDS: frozenset[str] = frozenset({'qiec_module_parameter', 'qiec_implicit_module_parameter'})
The parameter kinds that make a computation a region.
REGION_BODY_FIELDS
module-attribute
¶
The fields holding the statements of a region's body.
REGION_KINDS
module-attribute
¶
Nodes that open a scope of module-level names of their own: a module or signature body, and a computation with module parameters.
LINKING_WALKERS
module-attribute
¶
LINKING_WALKERS: dict[str, Callable[[_Tree, str], Statement]] = {'hole_decl': walk_hole, 'link_decl': walk_link, 'share_decl': walk_share}
The walker of each linking statement kind.
PREAMBLE_KINDS
module-attribute
¶
Linking statements that may stand among a module's imports: they do not end the imports, and may also follow declarations.
MODULE_LANGUAGE_KINDS
module-attribute
¶
MODULE_LANGUAGE_KINDS = frozenset({'signature_decl', 'module_decl', 'implicit_decl', 'family_spec', 'computation_spec', 'deduction_spec'})
The statement kinds this module walks.
NOTATION_STATEMENT_KINDS
module-attribute
¶
The vertex kinds of the notation statements.
EXPERIMENT_KIND
module-attribute
¶
The vertex kind of an experiment declaration.
THEORY_WALKERS
module-attribute
¶
THEORY_WALKERS: dict[str, Callable[..., TheoryDecl | ViewDecl | ModelDecl]] = {'theory_decl': walk_theory_decl, 'view_decl': walk_view_decl, 'model_decl': walk_model_decl}
The walker of each theory-layer declaration kind.
Position
¶
How trailing segments of a dotted reference are read.
In a morphism position (a morphism expression) segments after a value
are postfix forms; in a value position (a pure expression) they are
method calls or projections; in a request position (perform) the
last segment is the operation; in a module position (a module
expression) the whole name may name a module; anywhere else a dotted name
is a qualified reference.
Role
¶
What an identifier token is, by its grammar position.
StatementWalker
¶
Walks one statement vertex, as the statement dispatcher does.
NameUse
didactic-model
¶
Bases: Model
How the walkers read one name token.
| ATTRIBUTE | DESCRIPTION |
|---|---|
start, end |
The token's byte span.
TYPE:
|
reference |
The text the token's reference part reads as: the flat name name resolution assigned, or the token's own spelling of that part.
TYPE:
|
members |
How many trailing segments of the token select members of the referenced value (methods, postfix forms) rather than naming it.
TYPE:
|
NameView
didactic-model
¶
NameView(*, uses: tuple[NameUse, ...] = (), line_offset: int = 0)
Bases: Model
How the parse walkers read the names of one file.
Name resolution decides, per token, which flat name a reference reads as and which trailing segments of a dotted token are member accesses. The walkers read every token through this view, so an ordinary walk produces a program whose references are already resolved.
| ATTRIBUTE | DESCRIPTION |
|---|---|
uses |
The tokens resolution decided something about, by start offset.
TYPE:
|
line_offset |
Added to every line the walkers record, so the lines of the modules of one flat program do not overlap.
TYPE:
|
ParseError
¶
Bases: Exception
Raised when .qvr source fails to parse or wrap into AST nodes.
parse and parse_file raise it with a message that starts with
the file path and locates the first syntax error.
ParseTree
¶
Indexed view of a parsed panproto schema.
The walkers read a file's concrete syntax through it: its vertices,
fields, and source text, the latter through the name view name
resolution sets (set_view).
Source code in src/quivers/dsl/parser/_registry.py
set_view
¶
set_view(view: NameView) -> None
Read every later walk through view.
| PARAMETER | DESCRIPTION |
|---|---|
view
|
The resolved names and the line offset.
TYPE:
|
Source code in src/quivers/dsl/parser/_registry.py
name_use
¶
name_use(vid: str) -> NameUse | None
The resolution of the name token spanning vid, if any.
| PARAMETER | DESCRIPTION |
|---|---|
vid
|
A vertex whose span is exactly one name token.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NameUse | None
|
What resolution decided for the token, or |
Source code in src/quivers/dsl/parser/_registry.py
line_col_at
¶
1-based line and 0-based column of a byte offset in the source.
Source code in src/quivers/dsl/parser/_registry.py
Declared
didactic-model
¶
Declared(*, name: str, kind: str, statement: int, exported: bool = False, start: int = 0, end: int = 0, line: int = 0, column: int = 0, docs: tuple[str, ...] = (), region: str = '')
Bases: Model
A module-level name and one declaration of it.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
The declared name.
TYPE:
|
kind |
The declaration kind (
TYPE:
|
statement |
The index of the declaring top-level statement.
TYPE:
|
exported |
Whether
TYPE:
|
start, end |
The byte span of the declaring token.
TYPE:
|
line, column |
Its 1-based line and 0-based column.
TYPE:
|
docs |
The declaration's doc-comment lines.
TYPE:
|
region |
The region node whose body declares it,
TYPE:
|
ExportedName
didactic-model
¶
ExportedName(*, name: str, statement: int, start: int, end: int, line: int = 0, column: int = 0, is_name: bool = True, region: str = '')
Bases: Model
A name made public by an export NAME statement.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
The exported name as written.
TYPE:
|
statement |
The statement index.
TYPE:
|
start, end |
The byte span of the name.
TYPE:
|
line, column |
Its location.
TYPE:
|
is_name |
Whether the export names a declaration;
TYPE:
|
FileNames
didactic-model
¶
FileNames(*, occurrences: tuple[Occurrence, ...] = (), declarations: tuple[Declared, ...] = (), imports: tuple[ModuleImport, ...] = (), opens: tuple[ModuleOpen, ...] = (), exported_names: tuple[ExportedName, ...] = (), holes: tuple[ModuleHole, ...] = (), links: tuple[ModuleLink, ...] = (), shares: tuple[SiteShare, ...] = (), regions: tuple[Region, ...] = (), nested: tuple[Occurrence, ...] = (), nested_declarations: tuple[Declared, ...] = (), nested_opens: tuple[ModuleOpen, ...] = (), nested_exports: tuple[ExportedName, ...] = (), statement_count: int = 0, first_declaration: int = 0)
Bases: Model
Everything a file says about names, read from its parse tree.
| ATTRIBUTE | DESCRIPTION |
|---|---|
occurrences |
Every identifier token, in source order.
TYPE:
|
declarations |
Every module-level declaration, in source order.
TYPE:
|
imports |
The
TYPE:
|
opens |
The
TYPE:
|
exported_names |
The names of
TYPE:
|
holes |
The
TYPE:
|
links |
The
TYPE:
|
shares |
The
TYPE:
|
regions |
Every module, signature, and module-parameterized computation of
the file, outermost first; the other fields hold the file's own
names, and
TYPE:
|
nested |
The occurrences inside regions.
TYPE:
|
nested_declarations |
The declarations of region bodies.
TYPE:
|
nested_opens |
The
TYPE:
|
nested_exports |
The
TYPE:
|
statement_count |
The number of top-level statements.
TYPE:
|
first_declaration |
The index of the first statement that is not an import, an open, a hole, or a link (the statement count when there is none).
TYPE:
|
region_info
¶
region_info(vid: str) -> Region
The record of one region.
| PARAMETER | DESCRIPTION |
|---|---|
vid
|
The region node.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Region
|
Its record. |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If the file has no region at |
Source code in src/quivers/dsl/parser/scopes.py
region
¶
region(vid: str) -> FileNames
The names of one region, as a file's names are.
| PARAMETER | DESCRIPTION |
|---|---|
vid
|
The region node,
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FileNames
|
The region's occurrences, declarations, opens, and exports; its regions are the whole file's. |
Source code in src/quivers/dsl/parser/scopes.py
children_of
¶
children_of(vid: str) -> tuple[Region, ...]
The regions directly inside a region.
| PARAMETER | DESCRIPTION |
|---|---|
vid
|
The region node,
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Region, ...]
|
The regions whose parent it is, in source order. |
Source code in src/quivers/dsl/parser/scopes.py
declared_names
¶
The module-level names the file declares.
| RETURNS | DESCRIPTION |
|---|---|
frozenset[str]
|
Each declared name once. |
kinds_of
¶
The declaration kinds of a module-level name.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
A declared name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
frozenset[str]
|
Every kind the name is declared with (empty when undeclared). |
Source code in src/quivers/dsl/parser/scopes.py
ImportedName
didactic-model
¶
Bases: Model
One name in an import or open list.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
The name as written.
TYPE:
|
start, end |
Its byte span.
TYPE:
|
line, column |
Its location.
TYPE:
|
ModuleHole
didactic-model
¶
ModuleHole(*, path: str, signature: str, statement: int = 0, path_start: int = 0, path_end: int = 0, signature_start: int = 0, signature_end: int = 0, line: int = 0, column: int = 0)
Bases: Model
A hole statement.
| ATTRIBUTE | DESCRIPTION |
|---|---|
path |
The dotted module path the hole occupies.
TYPE:
|
signature |
The signature reference as written.
TYPE:
|
statement |
The statement index.
TYPE:
|
path_start, path_end |
The byte span of the path token.
TYPE:
|
signature_start, signature_end |
The byte span of the signature token.
TYPE:
|
line, column |
The location of the path token.
TYPE:
|
ModuleImport
didactic-model
¶
ModuleImport(*, path: str, alias: str | None = None, items: tuple[ImportedName, ...] | None = None, hidden: tuple[ImportedName, ...] = (), reexport: bool = False, meta: bool = False, statement: int = 0, path_start: int = 0, path_end: int = 0, alias_start: int = 0, alias_end: int = 0, line: int = 0, column: int = 0)
Bases: Model
An import statement.
| ATTRIBUTE | DESCRIPTION |
|---|---|
path |
The dotted module path.
TYPE:
|
alias |
The
TYPE:
|
items |
The selected names, or
TYPE:
|
hidden |
The names after
TYPE:
|
reexport |
Whether
TYPE:
|
meta |
Whether
TYPE:
|
statement |
The statement index.
TYPE:
|
path_start, path_end |
The byte span of the path token.
TYPE:
|
alias_start, alias_end |
The byte span of the alias token (0 when absent).
TYPE:
|
line, column |
The location of the path token.
TYPE:
|
ModuleLink
didactic-model
¶
ModuleLink(*, hole: str, module: str, statement: int = 0, hole_start: int = 0, hole_end: int = 0, module_start: int = 0, module_end: int = 0, line: int = 0, column: int = 0)
Bases: Model
A link statement.
| ATTRIBUTE | DESCRIPTION |
|---|---|
hole |
The dotted path of the hole it fills.
TYPE:
|
module |
The dotted path of the filling module.
TYPE:
|
statement |
The statement index.
TYPE:
|
hole_start, hole_end |
The byte span of the hole token.
TYPE:
|
module_start, module_end |
The byte span of the module token.
TYPE:
|
line, column |
The location of the hole token.
TYPE:
|
ModuleOpen
didactic-model
¶
ModuleOpen(*, module: str, items: tuple[ImportedName, ...] | None = None, hidden: tuple[ImportedName, ...] = (), statement: int = 0, start: int = 0, end: int = 0, line: int = 0, column: int = 0, region: str = '')
Bases: Model
An open statement.
| ATTRIBUTE | DESCRIPTION |
|---|---|
module |
The opened alias or module path.
TYPE:
|
items |
The selected names, or
TYPE:
|
hidden |
The names after
TYPE:
|
statement |
The statement index.
TYPE:
|
start, end |
The byte span of the module token.
TYPE:
|
line, column |
Its location.
TYPE:
|
Occurrence
didactic-model
¶
Occurrence(*, start: int, end: int, text: str, role: Role, parent_kind: str, field: str, statement: int, local: bool = False, position: Position = 'other', declaration_kind: str = '', line: int = 0, column: int = 0, region: str = '', pun: bool = False)
Bases: Model
One identifier token and what its position makes it.
| ATTRIBUTE | DESCRIPTION |
|---|---|
start, end |
The token's byte span.
TYPE:
|
text |
The token as written, possibly a dotted path.
TYPE:
|
role |
What the token is.
TYPE:
|
parent_kind, field |
The grammar position: the parent's node kind and the field (or
TYPE:
|
statement |
The index of the enclosing top-level statement.
TYPE:
|
local |
Whether a local binder in scope binds the first segment.
TYPE:
|
position |
How trailing segments of a dotted reference are read.
TYPE:
|
declaration_kind |
For a declaration, its kind.
TYPE:
|
line, column |
The token's 1-based line and 0-based column.
TYPE:
|
region |
The region node the token belongs to (a module or signature
body, or a computation with module parameters),
TYPE:
|
pun |
Whether the token is a pun
TYPE:
|
segments
property
¶
The dotted segments of the token.
| RETURNS | DESCRIPTION |
|---|---|
tuple[str, ...]
|
The segments, outermost first. |
SiteShare
didactic-model
¶
SiteShare(*, site: str, target: str, statement: int = 0, site_start: int = 0, site_end: int = 0, target_start: int = 0, target_end: int = 0, line: int = 0, column: int = 0)
Bases: Model
A share statement.
| ATTRIBUTE | DESCRIPTION |
|---|---|
site, target |
The two paths as written.
TYPE:
|
statement |
The statement index.
TYPE:
|
site_start, site_end, target_start, target_end |
The byte spans of the two path tokens.
TYPE:
|
line, column |
The location of the statement's first path.
TYPE:
|
Region
didactic-model
¶
Region(*, vid: str, kind: Literal['module', 'signature', 'template'], name: str, parent: str = '', statements: tuple[str, ...] = (), parameters: tuple[RegionParameter, ...] = (), implicit: bool = False, exported: bool = False, statement: int = 0, start: int = 0, end: int = 0, line: int = 0, column: int = 0)
Bases: Model
A node that opens a scope of module-level names of its own.
A module body, a signature body, and a computation with module parameters each declare names, bind module parameters, or both, and resolve every other name in the scope around them.
| ATTRIBUTE | DESCRIPTION |
|---|---|
vid |
The region node.
TYPE:
|
kind |
A module (structure or functor), a signature, or a computation with module parameters.
TYPE:
|
name |
The declared name.
TYPE:
|
parent |
The enclosing region node,
TYPE:
|
statements |
The statements of its body, in order (the computation itself for a template).
TYPE:
|
parameters |
Its module parameters, in order.
TYPE:
|
implicit |
Whether
TYPE:
|
exported |
Whether
TYPE:
|
statement |
The index of the declaring statement in the parent region.
TYPE:
|
start, end |
The byte span of the name.
TYPE:
|
line, column |
The location of the name.
TYPE:
|
RegionParameter
didactic-model
¶
RegionParameter(*, name: str, vid: str, signature: str, implicit: bool = False, start: int = 0, end: int = 0, line: int = 0, column: int = 0)
Bases: Model
A module parameter of a region: a functor's, or a computation's.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
The parameter's name.
TYPE:
|
vid |
The parameter node.
TYPE:
|
signature |
Its
TYPE:
|
implicit |
Whether calls leave the argument to instance resolution.
TYPE:
|
start, end |
The byte span of the name.
TYPE:
|
line, column |
Its location.
TYPE:
|
LexicalBody
didactic-model
¶
LexicalBody(*, atoms: tuple[str, ...] = (), features: tuple[AtomFeatures, ...] = (), category_sets: tuple[CategorySetDecl, ...] = (), semantics: SemanticsDecl | None = None, templates: tuple[LexicalTemplate, ...] = (), lexical_rules: tuple[LexicalRuleDecl, ...] = (), refines: str = '')
Bases: Model
The lexical parts of one deduction body.
| PARAMETER | DESCRIPTION |
|---|---|
atoms
|
Every declared atom, a featured one by its name.
TYPE:
|
features
|
The atoms declared with features.
TYPE:
|
category_sets
|
The
TYPE:
|
semantics
|
The
TYPE:
|
templates
|
The
TYPE:
|
lexical_rules
|
The
TYPE:
|
refines
|
The deduction a
TYPE:
|
DeductionBody
didactic-model
¶
DeductionBody(*, atoms: tuple[str, ...] = (), binders: tuple[str, ...] = (), rules: tuple[SequentRule, ...] = (), lexicon: tuple[LexiconEntry, ...] = (), lexicon_from_file: str | None = None, lexicon_from_file_options: tuple[OptionEntry, ...] = (), extends: tuple[DeductionExtension, ...] = (), lexicons: tuple[LexiconReference, ...] = (), instantiations: tuple[RuleInstantiation, ...] = (), lexicon_line: int = 0, lexicon_col: int = 0)
Bases: Model
The parts of one deduction or deduction-signature body.
| PARAMETER | DESCRIPTION |
|---|---|
atoms
|
The declared atoms.
TYPE:
|
binders
|
The declared binder constructors.
TYPE:
|
rules
|
The rules and rule schemata.
TYPE:
|
lexicon
|
The entries of inline lexicon blocks.
TYPE:
|
lexicon_from_file
|
The path of a
TYPE:
|
lexicon_from_file_options
|
That line's options.
TYPE:
|
extends
|
The
TYPE:
|
lexicons
|
The lexicon modules named on
TYPE:
|
instantiations
|
The
TYPE:
|
lexicon_line
|
Where the first inline lexicon block or
TYPE:
|
lexicon_col
|
Where the first inline lexicon block or
TYPE:
|
file_names
¶
file_names(tree: _Tree, file_path: str = '<source>', *, constructors: frozenset[str] | None = None) -> FileNames
Collect the name occurrences of a parsed file.
| PARAMETER | DESCRIPTION |
|---|---|
tree
|
The parsed tree.
TYPE:
|
file_path
|
The path recorded on diagnostics.
TYPE:
|
constructors
|
The constructor names in unqualified scope; the file's own when omitted.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FileNames
|
The occurrences, declarations, imports, opens, and exports. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If a declaration or binder is qualified, an import alias is qualified, or an import or open follows a declaration. |
Source code in src/quivers/dsl/parser/core.py
parse
¶
parse(source: str | bytes, file_path: str = '<source>') -> Module
Parse .qvr source into a Module.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
The source text, or its UTF-8 bytes.
TYPE:
|
file_path
|
The path recorded on diagnostics.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Module
|
The module's statements in source order. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If the source has a syntax error or a node the AST cannot represent. |
Source code in src/quivers/dsl/parser/core.py
parse_file
¶
parse_file(path: str | Path) -> Module
Parse a .qvr file at path.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
The file to read.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Module
|
The file's statements in source order. |
| RAISES | DESCRIPTION |
|---|---|
OSError
|
If the file cannot be read. |
ParseError
|
If the file does not parse. |
Source code in src/quivers/dsl/parser/core.py
parse_tree
¶
Parse .qvr source into its validated concrete syntax tree.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
The source text, or its UTF-8 bytes.
TYPE:
|
file_path
|
The path recorded on diagnostics.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
_Tree
|
The tree, free of syntax damage and of reserved binder names. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If the source has a syntax error. |
Source code in src/quivers/dsl/parser/core.py
walk_tree
¶
Walk a parsed tree into a Module, reading names through its view.
| PARAMETER | DESCRIPTION |
|---|---|
tree
|
The parsed tree, with the name view to read it through.
TYPE:
|
names
|
The file's name occurrences, from
TYPE:
|
file_path
|
The path recorded on diagnostics.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Module
|
The module's statements in source order. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If a node does not walk, or |
Source code in src/quivers/dsl/parser/core.py
walk_statements
¶
walk_statements(tree: _Tree, names: FileNames, statements: tuple[tuple[int, str], ...], file_path: str = '<source>') -> Module
Walk some statements of a module or region, reading names through the view.
| PARAMETER | DESCRIPTION |
|---|---|
tree
|
The parsed tree, with the name view to read it through.
TYPE:
|
names
|
The names of the module or region the statements belong to.
TYPE:
|
statements
|
Each statement vertex with its index in the module or region.
TYPE:
|
file_path
|
The path recorded on diagnostics.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Module
|
The statements in order, and the tests and experiments among them. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If a node does not walk, or |
Source code in src/quivers/dsl/parser/core.py
local_name_view
¶
The name view of a file read without its imports.
| PARAMETER | DESCRIPTION |
|---|---|
names
|
The file's name occurrences.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NameView
|
A view that marks the member accesses decidable from the file alone and renames nothing. |
Source code in src/quivers/dsl/parser/names.py
split_member_path
¶
Split a name token into its reference and its member accesses.
| PARAMETER | DESCRIPTION |
|---|---|
tree
|
The parsed tree, with its name view.
TYPE:
|
vid
|
A vertex spanning exactly one name token.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[str, tuple[str, ...]]
|
The reference, as resolution reads it, and the member segments that follow it, outermost first (empty when the whole token is a reference). |
Source code in src/quivers/dsl/parser/names.py
split_request_target
¶
Split a perform target into its instance and its operation.
| PARAMETER | DESCRIPTION |
|---|---|
tree
|
The parsed tree, with its name view.
TYPE:
|
vid
|
The target token of an effect request.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[str, str]
|
The instance, as resolution reads it, and the operation, the last segment. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the target has a single segment, so names no operation. |
Source code in src/quivers/dsl/parser/names.py
value_members
¶
How many of the segments after a declaration's name select members of its value.
| PARAMETER | DESCRIPTION |
|---|---|
position
|
The reference position of the dotted path.
TYPE:
|
kinds
|
The declaration kinds of the name the path starts with.
TYPE:
|
remainder
|
The segments after that name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
Every segment of |
Source code in src/quivers/dsl/parser/names.py
analyze_names
¶
analyze_names(tree: _Tree, *, constructors: frozenset[str] | None = None) -> FileNames
Collect every name occurrence of a parsed file.
| PARAMETER | DESCRIPTION |
|---|---|
tree
|
The parsed tree.
TYPE:
|
constructors
|
The constructor names in unqualified scope, which a bare name in a pattern refers to instead of binding. Defaults to the file's own.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FileNames
|
The occurrences, declarations, imports, opens, and exported names. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If a declaration or binder is spelled as a qualified path, an
import alias is qualified, or an |
Source code in src/quivers/dsl/parser/scopes.py
1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 | |
declared_constructors
¶
The constructor names a file declares at module level.
| PARAMETER | DESCRIPTION |
|---|---|
tree
|
The parsed tree.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
frozenset[str]
|
The names of every family, index, and signature constructor. |
Source code in src/quivers/dsl/parser/scopes.py
top_level_statements
¶
The top-level statement vertices of a tree, in source order.
| PARAMETER | DESCRIPTION |
|---|---|
tree
|
The parsed tree.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
The vertex ids, comments excluded. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If the tree has no |
Source code in src/quivers/dsl/parser/scopes.py
walk_hole
¶
walk_hole(tree: _Tree, vid: str) -> HoleDecl
Walk a hole P : S statement.
| PARAMETER | DESCRIPTION |
|---|---|
tree
|
The parse tree.
TYPE:
|
vid
|
The
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
HoleDecl
|
The statement. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If the statement lacks its path or signature. |
Source code in src/quivers/dsl/parser/linking.py
walk_link
¶
walk_link(tree: _Tree, vid: str) -> LinkDecl
Walk a link P = M statement.
| PARAMETER | DESCRIPTION |
|---|---|
tree
|
The parse tree.
TYPE:
|
vid
|
The
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LinkDecl
|
The statement. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If the statement lacks its hole or module. |
Source code in src/quivers/dsl/parser/linking.py
walk_share
¶
walk_share(tree: _Tree, vid: str) -> ShareDecl
Walk a share x with y statement.
| PARAMETER | DESCRIPTION |
|---|---|
tree
|
The parse tree.
TYPE:
|
vid
|
The
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ShareDecl
|
The statement, its two paths resolved through the name view. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If the statement lacks either path. |
walk_module_expr
¶
walk_module_expr(t: _Tree, vid: str) -> ModuleExpr
Walk a module expression.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The tree.
TYPE:
|
vid
|
A module-expression vertex.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ModuleExpr
|
The expression. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If the vertex is not a module expression. |
Source code in src/quivers/dsl/parser/module_language.py
walk_module_language_statement
¶
walk_module_language_statement(t: _Tree, vid: str, walk_statement: StatementWalker) -> Statement
Walk one module-language statement.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The tree.
TYPE:
|
vid
|
A vertex whose kind is in
TYPE:
|
walk_statement
|
Walks the statements of a body or a signature.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Statement
|
The walked statement. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If the vertex is not a module-language statement. |
Source code in src/quivers/dsl/parser/module_language.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
walk_signature_expr
¶
walk_signature_expr(t: _Tree, vid: str) -> SignatureExpr
Walk a signature reference and its sharing constraints.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The tree.
TYPE:
|
vid
|
A
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SignatureExpr
|
The reference, read through the tree's name view. |
Source code in src/quivers/dsl/parser/module_language.py
walk_fin_type
¶
walk_fin_type(t: _Tree, vid: str) -> QiecTypeExpr
Walk Fin n.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
A
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
QiecTypeExpr
|
The positional index set. |
Source code in src/quivers/dsl/parser/axes.py
walk_reduction
¶
walk_reduction(t: _Tree, vid: str) -> LetExprNode
Walk logsumexp over w : World. e.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
A
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LetExprNode
|
The reduction. |
Source code in src/quivers/dsl/parser/axes.py
walk_tabulation
¶
walk_tabulation(t: _Tree, vid: str) -> LetExprNode
Walk for w : World. e.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
A
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LetExprNode
|
The tabulation. |
Source code in src/quivers/dsl/parser/axes.py
walk_tensor_type
¶
walk_tensor_type(t: _Tree, vid: str) -> QiecTypeExpr
Walk (E)[T1, ..., Tk].
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
A
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
QiecTypeExpr
|
The tensor type. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If it lists no axis. |
Source code in src/quivers/dsl/parser/axes.py
walk_lexical_body
¶
walk_lexical_body(t: _Tree, vid: str, *, pragma: PragmaWalker) -> LexicalBody
Walk the lexical lines of a deduction body.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
The
TYPE:
|
pragma
|
Walks a
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LexicalBody
|
The parts, in source order. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If a line is malformed, a deduction has two |
Source code in src/quivers/dsl/parser/lexical.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
walk_polymorphic_category
¶
walk_polymorphic_category(t: _Tree, vid: str) -> LexiconCategoryPolymorphic
Walk a ∀ X in S, ... . C category.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
The
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LexiconCategoryPolymorphic
|
The category schema. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If the schema has no category. |
Source code in src/quivers/dsl/parser/lexical.py
walk_deduction_body
¶
walk_deduction_body(t: _Tree, vid: str, *, entry: EntryWalker, pragma: PragmaWalker) -> DeductionBody
Walk the body entries of a deduction or a deduction signature.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
The
TYPE:
|
entry
|
Walks a lexicon entry.
TYPE:
|
pragma
|
Walks a rule's pragma.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DeductionBody
|
Its parts, in source order. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If an entry is malformed. |
Source code in src/quivers/dsl/parser/deduction_modules.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | |
walk_deduction_signature_decl
¶
walk_deduction_signature_decl(t: _Tree, vid: str, *, docs: tuple[str, ...], entry: EntryWalker, pragma: PragmaWalker) -> DeductionSignatureDecl
Walk a deduction signature declaration.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
The
TYPE:
|
docs
|
Its doc comment.
TYPE:
|
entry
|
Walks a lexicon entry.
TYPE:
|
pragma
|
Walks a rule's pragma.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DeductionSignatureDecl
|
The signature. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If the body holds a lexicon block or a |
Source code in src/quivers/dsl/parser/deduction_modules.py
walk_lexicon_decl
¶
walk_lexicon_decl(t: _Tree, vid: str, *, docs: tuple[str, ...], entry: EntryWalker) -> LexiconDecl
Walk a lexicon NAME for S declaration.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
The
TYPE:
|
docs
|
Its doc comment.
TYPE:
|
entry
|
Walks a lexicon entry.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LexiconDecl
|
The lexicon module. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If its name or signature is missing. |
Source code in src/quivers/dsl/parser/deduction_modules.py
walk_rule_pattern
¶
walk_rule_pattern(t: _Tree, vid: str) -> ObjectExpr
Walk a premise or conclusion of a rule, reading slash spines.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
An object-expression vertex.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ObjectExpr
|
The pattern; a spine becomes an |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If a spine is malformed. |
Source code in src/quivers/dsl/parser/deduction_modules.py
walk_notation_items
¶
walk_notation_items(t: _Tree, vid: str) -> tuple[NotationItem, ...]
Walk the token tree under a quotation or a group.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
A
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[NotationItem, ...]
|
Its items in source order. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If a child is not a token-tree item. |
Source code in src/quivers/dsl/parser/notation.py
walk_notation_statement
¶
walk_notation_statement(t: _Tree, vid: str) -> Statement
Walk a notation declaration or an open notation statement.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
A vertex whose kind is in
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Statement
|
The |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If the vertex is not a notation statement. |
Source code in src/quivers/dsl/parser/notation.py
walk_quotation
¶
walk_quotation(t: _Tree, vid: str) -> QiecQuotation
Walk a quotation vertex in a value position.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
The
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
QiecQuotation
|
The quotation with its token tree. |
Source code in src/quivers/dsl/parser/notation.py
walk_quotation_pattern
¶
walk_quotation_pattern(t: _Tree, vid: str) -> QiecQuotationPattern
Walk a quotation_pattern vertex.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
The
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
QiecQuotationPattern
|
The pattern with its token tree. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If an antiquotation in the pattern is |
Source code in src/quivers/dsl/parser/notation.py
walk_judgment_decl
¶
walk_judgment_decl(t: _Tree, vid: str, line: int, col: int, *, docs: tuple[str, ...], pragma: Callable[[_Tree, str], tuple[OptionEntry, ...]]) -> JudgmentDecl
Read a judgment declaration.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
The
TYPE:
|
line
|
Its position.
TYPE:
|
col
|
Its position.
TYPE:
|
docs
|
Its doc comment lines, read by the statement walker.
TYPE:
|
pragma
|
The walker of a rule's trailing pragma.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
JudgmentDecl
|
The declaration. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If an argument has no mode or a rule no conclusion. |
Source code in src/quivers/dsl/parser/object_terms.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
walk_object_term
¶
walk_object_term(t: _Tree, vid: str) -> PatternSyntax
Read a written second-order term.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
An
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
PatternSyntax
|
The term as written, names unresolved. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If the vertex is not a term, or a binder's dot follows a name with no space so that the name and the body read as one dotted name. |
Source code in src/quivers/dsl/parser/object_terms.py
walk_syntax_equations
¶
walk_syntax_equations(t: _Tree, vid: str) -> tuple[tuple[EquationDecl, ...], tuple[OptionEntry, ...], bool]
Read a signature's equations block.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
The
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple
|
The equations, the block's options, and whether termination is assumed. |
Source code in src/quivers/dsl/parser/object_terms.py
literal_json
¶
The canonical JSON text of a literal experiment value.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
The value's vertex: a number, a string,
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Its JSON text, with sorted keys and no insignificant whitespace. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If the value is not a literal. |
Source code in src/quivers/dsl/parser/experiments.py
string_content
¶
The characters a string literal denotes.
| PARAMETER | DESCRIPTION |
|---|---|
text
|
The literal, quotes included.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Its content, with each backslash escape replaced by the character it escapes. |
Source code in src/quivers/dsl/parser/experiments.py
walk_experiment_decl
¶
walk_experiment_decl(t: _Tree, vid: str) -> ExperimentDecl
Walk an experiment declaration.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree, with the name view to read references through.
TYPE:
|
vid
|
The
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ExperimentDecl
|
The declaration. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If a clause that may occur once occurs twice, the |
Source code in src/quivers/dsl/parser/experiments.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | |
walk_deduction_semiring
¶
walk_deduction_semiring(t: _Tree, vid: str | None) -> DeductionSemiring | None
Read the semiring parameter of a deduction header, if it has one.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
The
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DeductionSemiring or None
|
The parameter. |
Source code in src/quivers/dsl/parser/semirings.py
walk_semiring_decl
¶
walk_semiring_decl(t: _Tree, vid: str, *, docs: tuple[str, ...] = ()) -> SemiringDecl
Read a semiring declaration.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
The
TYPE:
|
docs
|
Its doc comment lines.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SemiringDecl
|
The declaration. |
Source code in src/quivers/dsl/parser/semirings.py
walk_model_decl
¶
walk_model_decl(t: _Tree, vid: str, *, docs: tuple[str, ...] = ()) -> ModelDecl
Read a model declaration.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
The
TYPE:
|
docs
|
Its doc comment lines.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ModelDecl
|
The declaration. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If the construction is neither |
Source code in src/quivers/dsl/parser/theories.py
walk_theory_decl
¶
walk_theory_decl(t: _Tree, vid: str, *, docs: tuple[str, ...] = ()) -> TheoryDecl
Read a theory declaration.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
The
TYPE:
|
docs
|
Its doc comment lines.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
TheoryDecl
|
The declaration. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If the body declares two |
Source code in src/quivers/dsl/parser/theories.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | |
walk_theory_expression
¶
walk_theory_expression(t: _Tree, vid: str) -> TheoryExpr
Read a theory expression.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
A theory-expression vertex.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
TheoryExpr
|
The expression. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If the vertex is not a theory expression. |
Source code in src/quivers/dsl/parser/theories.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
walk_view_decl
¶
walk_view_decl(t: _Tree, vid: str, *, docs: tuple[str, ...] = ()) -> ViewDecl
Read a view declaration.
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The parse tree.
TYPE:
|
vid
|
The
TYPE:
|
docs
|
Its doc comment lines.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ViewDecl
|
The declaration. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If a mapping lacks a side. |