TTCompilerRules
TTCompilerRules
defines how the python abstract syntax tree (AST) library should handle various syntactic elements as it visits each node of the AST.
These rules are automatically called as the ast (abstract syntax tree) library ‘visits’ syntactic structures within the TTPython file to compile.
The TTSQ
constructor is also an especially essential component of the
compilation process!
- class ticktalkpython.CompilerRules.TTEnvVisitor(node)
- generic_visit(node: AST) set
Called if no explicit visitor function exists for a node.
- class ticktalkpython.CompilerRules.TTGraphCompilationVisitor(graph: TTGraph, debug=False, source=None, pathname=None)
A child class of ast.NodeVisitor, which walks through the ast and calls specific handlers for each syntactic construct
- Parameters:
graph (TTGraph) – An instantiated but empty graph, ready to be filled in as the AST is walked
- compile_with_shadow_table(node, syms: List[str], rename_arcs: List[str], arcs: List[TTArc], has_trigger: bool)
Compiles node with a shadow table. The table is created by the given syms and output_arcs.
- generate_branch_sq(input_env: List[TTArc], has_constants: bool)
Generates a string representing a Python if_else
- generate_sq(node: Call, func: FunctionDef, name: str, input_arcs: List[TTArc], is_singleton=False, input_ctrl_arc=None, firing_rule: TTFiringRuleType = None, num_output_arcs=1) TTSQ
Preps the input arcs, creates SQ, and adds it to the sq_list
- generic_visit(node)
Called if no explicit visitor function exists for a node.
- replace_context(ctxt: Context)
Returns the old context and replaces the current context with the one given
- scrape_kwarg(s, node: Call)
Searches for the value of key s in kwargs. Note that the node needs keywords
- ticktalkpython.CompilerRules.import_sqified_functions_from_module(module, graph)
Find the module and import any SQify or STREAMify-decorated functions