Parser¶
Parsing QVR source into AST nodes.
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 and the whole-tree syntax validation that rejects ERROR and missing nodes.
Every public name is re-exported here so from quivers.dsl.parser
import X keeps working unchanged.
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.
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. |