Expand description
This module parses string expressions into an AST which can then be compiled or evaluated.
§fasteval Algebra Grammar
Expression: Value (BinaryOp Value)*
Value: Constant || UnaryOp || PrintFunc || StdFunc
Constant: [+-]?[0-9]*(\.[0-9]+)?( ([eE][+-]?[0-9]+) || [pnuµmkKMGT] )? || [+-]?(NaN || inf)
UnaryOp: +Value || -Value || (Expression) || [Expression] || !Value
BinaryOp: + || - || * || / || % || ^ || < || <= || == || != || >= || > || (or || '||') || (and || '&&')
VarName: [a-zA-Z_][a-zA-Z_0-9]*
StdFunc: VarName((Expression,)*)? || VarName[(Expression,)*]?
PrintFunc: print(ExpressionOrString,*)
ExpressionOrString: Expression || String
String: ".*"
Structs§
- Expression
- An
Expression
is the top node of a parsed AST. - ExpressionI
- An
ExpressionI
represents an index intoSlab.ps.exprs
. - Parser
- Print
Func - Represents a
print()
function call in thefasteval
expression AST. - ValueI
- A
ValueI
represents an index intoSlab.ps.vals
.
Enums§
- Binary
Op - Binary Operators
- Expression
OrString - Used by the
print()
function. Can hold anExpression
or aString
. - StdFunc
- A Function Call with Standard Syntax.
- UnaryOp
- Unary Operators
- Value
- A
Value
can be a Constant, a UnaryOp, a StdFunc, or a PrintFunc.