LobsterLang-0.1.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

AstEval

Synopsis

Documentation

evalAst :: [ScopeMb] -> Ast -> (Either String (Maybe Ast), [ScopeMb]) Source #

Evaluate a Ast. Takes a stack representing variables and the Ast to evaluate. Returns a tuple containing either the resulting Ast (can be Nothing for no evaluation is possible) or a Ast containing the error message in case of error and the stack after evaluation.

evalBiValOp :: (Int -> Int -> Int) -> [ScopeMb] -> Ast -> (Either String (Maybe Ast), [ScopeMb]) Source #

Evaluate the Ast for a given binary value operator such as +, -, or *. Takes a function that takes two Int and return one Int, the stack as a '[ScopeMb]', and the Ast to evaluate. Return a tuple containing the new stack post evaluation, and the application of the function onto the values inside the given Ast or a Ast containing the error message in case of error

evalBiBoolOp :: (Bool -> Bool -> Bool) -> [ScopeMb] -> Ast -> (Either String (Maybe Ast), [ScopeMb]) Source #

Evaluate the Ast for a given binary boolean operator such as && or ||. Takes a function that takes two Bool and return one Bool, the stack as a '[ScopeMb]', and the Ast to evaluate. Return a tuple containing the new stack post evaluation, and the application of the function onto the booleans inside the given Ast or a Ast containing the error message in case of error

evalBiCompValOp :: (Int -> Int -> Bool) -> [ScopeMb] -> Ast -> (Either String (Maybe Ast), [ScopeMb]) Source #

Evaluate the Ast for a given binary comparison operator such as ==, >, or <=. Takes a function that takes two Int and return one Bool, the stack as a '[ScopeMb]', and the Ast to evaluate. Return a tuple containing the new stack post evaluation, and the application of the function onto the values inside the given Ast or a Ast containing the error message in case of error