ptera.opparse
Parser for the selector syntax.
- class ptera.opparse.ASTNode(parts)
Node that results from parsing.
- args
List of arguments.
- ops
List of operators. Generally one less than the number of arguments.
- key
String key that represents the kind of operation we are dealing with: which arguments are non-null and what the ops are. If args == [a, b, None] and ops == [+, -] then key == “X + X - _”.
- location
Location of the node in the source code. It encompasses the locations of all args and ops.
- class ptera.opparse.Lexer(definitions)
The Lexer splits source code into Tokens.
- class ptera.opparse.OperatorPrecedenceTower(operators)
Compare operators using a simple operator tower.
- resolve(op)
Resolve the priority tuple for a given op.
- class ptera.opparse.Parser(lexer, order)
Operator precedence parser.
- finalize(parts)
Clean up a list of parts that form a completed ASTNode.
If the parts are [None, op, None], this is just the op.
If the parts are [arg1, op1, arg2, op2, … argn] then we create an ASTNode with the given args and ops.
- process(tokens)
Process a list of tokens.
- class ptera.opparse.Token(value, type, source, start, end)
Token produced by the lexer.
- value
Textual value of the token.
- type
Type of the token.
- location
Location of the token.
- ptera.opparse.cbrack(prio)
Create a priority tuple for a closing bracket.
- ptera.opparse.lassoc(prio)
Create a priority tuple for a left-associative operator.
- ptera.opparse.obrack(prio)
Create a priority tuple for an opening bracket.
- ptera.opparse.rassoc(prio)
Create a priority tuple for a right-associative operator.