Parser
opulse.definition.parser ¶
Parse definition and expression strings into :mod:opulse.definition.ast nodes.
A thin front end over :mod:opulse.definition.syntax. Without a registry the
parser knows the ten base operations (so &-1 still splits into & and
-); with a registry it knows every operator's role, priority and the base
markers, which is needed for unseparated symbols, marked numerals and
priority-based expression parsing.
DefinitionParser ¶
Parser bound to one set of :class:~opulse.config.Symbols (and optionally a registry).
add ¶
add(operator) -> None
Register one new operator's role (O(1); refresh re-reads the whole registry).
parse_expr ¶
parse_expr(
text: str,
expression_mode: bool = False,
strict: bool = False,
) -> ast.Expr
expression_mode uses operator priorities; otherwise one binary level, left-assoc.
strict requires parentheses around every binary operand that is itself binary.