blancas.kern.expr

Support for the evaluation of expressions.

add-op

Additive operator: addition or subtraction.

and-op

Parses the logical AND operator.

chainl

(chainl p op a)
Parses a value or a sequence or values separated by a binary operator.
If there's no initial value, defaults to a. Associates to the left.

chainl*

(chainl* tok p op a)
Parses a value or a sequence or values separated by a binary operator.
If there's no initial value, defaults to a. Associates to the left.
The resulting value is an AST node.

chainl1

(chainl1 p op)
Parses p; as long as there is a binary operator op, reads the op and
another instance of p, then applies the operator on both values.
The operator associates to the left.

chainl1*

(chainl1* tok p op)
Parses p; as long as there is a binary operator op, reads the op and
another p, then makes an AST node with the operator on both values.
The operator associates to the left.

chainr

(chainr p op a)
Parses a value or a sequence or values with infix binary operators.
If there's no initial value, defaults to a. Associates to the right.

chainr*

(chainr* tok p op a)
Parses a value or a sequence or values with infix binary operators.
If there's no initial value, defaults to a. Associates to the right.
The operator associates to the right.

chainr1

(chainr1 p op)
Parses p; as long as there is a binary operator op, reads the op and
calls itself to compute the rest of the expression, then it applies
the operator on both values. The operator associates to the right.

chainr1*

(chainr1* tok p op)
Parses p; as long as there is a binary operator op, reads the op and
calls itself to make the rest of the expression AST, then it makes
an AST node with the operator on both values. The operator associates
to the right.

mul-op

Multiplicative operator: multiplication, division, or modulo.

or-op

Parses the logical OR operator.

postfix

(postfix p op a)
Like postfix1, but both the operator and operand are optional.
If no operand is given, it returns the default value a.

postfix*

(postfix* tok p op a)
Like postfix1*, but both the operator and operand are optional.
If no operand is given, it returns the default value a.

postfix1

(postfix1 p op)
Parses an operand p followed by zero or more operators. It applies the
parsed functions to the operand or the result of a previous application.

postfix1*

(postfix1* tok p op)
Parses an operand p followed by zero or more operators op. It builds
an AST node for each parsed function, where the operand is a node
for a value or a previous  application of a postfix operator.

pow-op

Parses the POW operator.

prefix

(prefix p op a)
Like prefix1, but both the operator and operand are optional.
If no operand is given, it returns the default value a.

prefix*

(prefix* tok p op a)
Like prefix1*, but both the operator and operand are optional.
If no operand is given, it returns the default value a.

prefix1

(prefix1 p op)
Parses zero or more operators op before an operand p. It applies
the parsed functions to the operand in reverse order of parsing.

prefix1*

(prefix1* tok p op)
Parses zero or more operators op before an operand p. It builds an
AST node for each parsed function, where the operand is a node
for a value or a further application of a prefix operator.

rel-op

Parses one of the relational operators.

uni-op

Unary prefix operator: logical not or numeric minus.