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.
eval()

Evaluate stored functions and all its arguments recursively.

class pyBabyMaker.engine.eval.ForStmtEvaluator(idx, iterable, loop, known_symb)

Delayed evaluator for for ... endfor statement.

__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 ...) fi statements.

__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.

class pyBabyMaker.engine.eval.Scope(iterable=[], parent=None, evalulator=None)
__init__(iterable=[], parent=None, evalulator=None)

Initialize self. See help(type(self)) for accurate signature.

class pyBabyMaker.engine.eval.TransForTemplateMacro(scope, known_symb)

Transformer for template macro.

__init__(scope, known_symb)

Initialize self. See help(type(self)) for accurate signature.

transform(*args, lineno=0, **kwargs)

Transform the given tree, and return the final result