titus.pfaast.Pack

class titus.pfaast.Pack(exprs, pos=None)[source]

Bases: titus.pfaast.Expression

Abstract syntax tree for a pack construct.

class Context(retType, calls, exprsDeclareRes, pos=None)

Bases: titus.pfaast.ExpressionContext

__init__(retType, calls, exprsDeclareRes, pos=None)
Pack.__init__(exprs, pos=None)
Pack.collect(pf)

Walk over tree applying a partial function, returning a list of results in its domain.

Parameters:
  • pf (callable with isDefinedAt method) – partial function that takes any titus.pfaast.Ast as an argument, returning anything
  • pf.isDefinedAt (callable) – domain that takes any titus.pfaast.Ast as an argument, returning True if this item is in the domain, False otherwise
Return type:

list of function results

Returns:

a result for each abstract syntax tree node in the pf function’s domain

Pack.desc = 'pack'
Pack.jsonNode(lineNumbers, memo)

Convert this abstract syntax tree to Pythonized JSON.

Parameters:
  • lineNumbers (bool) – if True, include locator marks in each JSON object
  • memo (set of string) – used to avoid recursion; provide an empty set if unsure
Return type:

Pythonized JSON

Returns:

JSON representation

Pack.replace(pf)

Walk over tree applying a partial function, returning a transformed copy of the tree.

Parameters:
  • pf (callable with isDefinedAt method) – partial function that takes any titus.pfaast.Ast as an argument, returning a replacement titus.pfaast.Ast
  • pf.isDefinedAt (callable) – domain that takes any titus.pfaast.Ast as an argument, returning True if this item is in the domain, False otherwise
Return type:

new titus.pfaast.Ast tree

Returns:

tree with nodes in the pf function’s domain transformed; everything else left as-is

Pack.walk(task, symbolTable, functionTable, engineOptions, version)

Walk over tree applying a titus.pfaast.Task while checking for semantic errors.

This is how Python is generated from an abstract syntax tree: the titus.pfaast.Task in that case is titus.genpy.GeneratePython.

Parameters:
Return type:

(titus.pfaast.AstContext, titus.pfaast.TaskResult)

Returns:

(information about this abstract syntax tree node after type-checking, result of the generic task)