pyBabyMaker.engine.eval¶
This module provide template macro evaluation.
-
class
pyBabyMaker.engine.eval.DelayedEvaluator(func_name, args)¶ General container for storing info needed for executing macro at a later stage.
-
__init__(func_name, args)¶ Initialize evaluator.
Parameters: - func_name (str) – function name. Must be defined in
macro_funcs. - args (tuple/list) – function arguments.
- func_name (str) – function name. Must be defined in
-
eval()¶ Evaluate stored functions and all its arguments recursively.
-
-
class
pyBabyMaker.engine.eval.ForStmtEvaluator(idx, iterable, loop, known_symb)¶ Delayed evaluator for
for ... endforstatement.-
__init__(idx, iterable, loop, known_symb)¶ Initialize for-statement evaluator.
Parameters: - idx (str) – name of the loop variable.
- iterable (DelayedEvaluator) – the object to be iterated over.
- loop (list) – empty list to store evaluators in the for loop.
- known_symb (dict) – all known symbols.
-
eval()¶ Evaluate for-loop and all evaluable in its scope.
-
-
class
pyBabyMaker.engine.eval.IfStmtEvaluator(cond, branch)¶ Delayed evaluator for
if ... (elif ... else ...) fistatements.-
__init__(cond, branch)¶ Initialize if-statements evaluator.
Parameters: - cond (DelayedEvaluator) – conditional.
- branch (list) – empty list to store evaluators in the if branch.
-
add_cond(cond, branch)¶ Add an unevaluated conditional with iterable to be evaluated if the conditional is true.
Parameters: - cond (DelayedEvaluator) – conditional.
- eval_list (list) – empty list to store evaluators in the if branch.
-
eval()¶ Evaluate if-statements and all evaluable in its selected branch.
-