[][src]Module fasteval::parser

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 into Slab.ps.exprs.

Parser
PrintFunc

Represents a print() function call in the fasteval expression AST.

ValueI

A ValueI represents an index into Slab.ps.vals.

Enums

BinaryOp

Binary Operators

ExpressionOrString

Used by the print() function. Can hold an Expression or a String.

StdFunc

A Function Call with Standard Syntax.

UnaryOp

Unary Operators

Value

A Value can be a Constant, a UnaryOp, a StdFunc, or a PrintFunc.

Constants

DEFAULT_EXPR_DEPTH_LIMIT
DEFAULT_EXPR_LEN_LIMIT