class EEEval::CalcParser

Defined in:

eval/shunting_yard_calc.cr

Constant 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

Class Method Detail

def self.build_ast(tokens : Array(Token)) : AST::Node #

Build AST from flat token list using the Shunting Yard algorithm. Returns the root AST node.


[View source]
def self.clear_expression(expression : String) #

Legacy methods kept for internal backward compatibility


[View source]
def self.compile(expression : String) : AST::Node #

Compile only: return AST root for repeated evaluation


[View source]
def self.evaluate(expression : String) #

[View source]
def self.has_left_associativity(operator : String) : Bool #

[View source]
def self.parse(expression : String, env : Hash(String, Float64)) : Float64 #

High-level parse: tokenize → build AST → evaluate with env


[View source]
def self.precedence(operator : String) : Int32 #

Operator helpers (unchanged)


[View source]
def self.should_pop?(op1 : String, op2 : String) : Bool #

[View source]
def self.tokenize(expression : String) : Array(Token) #

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.


[View source]