class
EEEval::CalcParser
- EEEval::CalcParser
- Reference
- Object
Defined in:
eval/shunting_yard_calc.crConstant Summary
-
FUNC_NAMES =
["log", "exp", "sin", "cos", "sqrt", "tan", "atan", "asin", "acos", "exp2", "log10", "log2", "abs", "floor", "ceil", "round", "sgn", "sinh", "cosh", "tanh", "gamma"] of ::String
Class Method Summary
-
.build_ast(tokens : Array(Token)) : AST::Node
------------------------------------------------------------------------- Build AST from flat token list using the Shunting Yard algorithm.
-
.clear_expression(expression : String)
------------------------------------------------------------------------- Legacy methods kept for internal backward compatibility -------------------------------------------------------------------------
-
.compile(expression : String) : AST::Node
------------------------------------------------------------------------- Compile only: return AST root for repeated evaluation -------------------------------------------------------------------------
- .evaluate(expression : String)
- .has_left_associativity(operator : String) : Bool
-
.parse(expression : String, env : Hash(String, Float64)) : Float64
------------------------------------------------------------------------- High-level parse: tokenize → build AST → evaluate with env -------------------------------------------------------------------------
-
.precedence(operator : String) : Int32
------------------------------------------------------------------------- Operator helpers (unchanged) -------------------------------------------------------------------------
- .should_pop?(op1 : String, op2 : String) : Bool
-
.tokenize(expression : String) : Array(Token)
Tokenizes an infix expression string into an Array of Token.
Class Method Detail
Tokenizes an infix expression string into an Array of Token. Variables (unknown words that are not functions) are emitted as Token::Type::Variable tokens so they can become VariableNode in the AST.