openpectus.lang.model.ast
Attributes
Classes
dict() -> new empty dictionary |
|
Defines data for cancel and force operations that control interpretation behavior. |
|
Marker interface that indicates that the node type uses the interrupt mechanism. |
|
Defines data for cancel and force operations that control interpretation behavior. |
|
Defines data for cancel and force operations that control interpretation behavior. |
|
Defines data for cancel and force operations that control interpretation behavior. |
|
Defines data for cancel and force operations that control interpretation behavior. |
|
Defines data for cancel and force operations that control interpretation behavior. |
|
Defines data for cancel and force operations that control interpretation behavior. |
|
Defines data for cancel and force operations that control interpretation behavior. |
|
Defines data for cancel and force operations that control interpretation behavior. |
|
Defines data for cancel and force operations that control interpretation behavior. |
|
Defines data for cancel and force operations that control interpretation behavior. |
|
Defines data for cancel and force operations that control interpretation behavior. |
|
Defines data for cancel and force operations that control interpretation behavior. |
|
Defines data for cancel and force operations that control interpretation behavior. |
|
Represents a node that counts as whitespace in regards to |
|
Represents a line with only a comment. |
|
Defines data for cancel and force operations that control interpretation behavior. |
|
Defines data for cancel and force operations that control interpretation behavior. |
|
Defines data for cancel and force operations that control interpretation behavior. |
|
Defines data for cancel and force operations that control interpretation behavior. |
|
Defines data for cancel and force operations that control interpretation behavior. |
|
Represents commands that are directly executable by the interpreter. |
|
Represents internal engine commands that have a command class subclassing InternalEngineCommand. |
|
Defines data for cancel and force operations that control interpretation behavior. |
|
Defines data for cancel and force operations that control interpretation behavior. |
|
Represents a uod command, subclassing UodCommand. |
|
Represents a line that contains only whitespace. |
|
Represents non-parsable instruction line. |
Module Contents
- class openpectus.lang.model.ast.Position(line, character)
- Parameters:
line (int)
character (int)
- line: int
Line number, zero based
- character: int
Character number on line, zero-based. Corresponds to the indentation of the line
- is_empty()
- Return type:
bool
- __eq__(value)
- __lt__(other)
- __gt__(other)
- __str__()
- __hash__()
- Return type:
int
- class openpectus.lang.model.ast.Range(start, end)
-
- start
- end
- is_empty()
- Return type:
bool
- __str__()
- __contains__(index)
Check if position or character index is within range
- Parameters:
index (Position)
- __eq__(other)
- Return type:
bool
- __hash__()
- Return type:
int
- class openpectus.lang.model.ast.NodeIdGenerator
- class openpectus.lang.model.ast.NodeState
Bases:
TypedDictdict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s
(key, value) pairs
- dict(iterable) -> new dictionary initialized as if via:
d = {} for k, v in iterable:
d[k] = v
- dict(**kwargs) -> new dictionary initialized with the name=value pairs
in the keyword argument list. For example: dict(one=1, two=2)
- id: str
- class_name: str
- name: str
- started: bool
- completed: bool
- cancelled: bool
- forced: bool
- action_history: list[str]
- openpectus.lang.model.ast.TNode
- class openpectus.lang.model.ast.SupportCancelForce
Defines data for cancel and force operations that control interpretation behavior.
- _cancellable: bool = False
- _cancelled: bool = False
- _forcible: bool = True
- _forced: bool = False
- property cancellable: bool
Whether the node is cancellable in its current state. Virtual property.
- Return type:
bool
- property cancelled: bool
Whether the node has been cancelled. Virtual property.
- Return type:
bool
- cancel()
- property forcible: bool
Whether the node is forcible in its current state. Virtual property.
- Return type:
bool
- property forced: bool
Whether the node has been forced. Virtual property.
- Return type:
bool
- force()
- class openpectus.lang.model.ast.SupportsInterrupt
Marker interface that indicates that the node type uses the interrupt mechanism.
Requirements: - it must provide a interrupt_registered property, currently NodeWithChildren does this - interpreter._create_interrupt_handler() must be able to create a handler for the node type
- class openpectus.lang.model.ast.Node(position=Position.empty, id='')
Bases:
SupportCancelForceDefines data for cancel and force operations that control interpretation behavior.
- instruction_names: list[str] = []
Specifies which node the parser should instantiate for a given instruction name(s)
- parent: NodeWithChildren | None = None
- id: str = ''
- instruction_part: str = ''
- threshold_part: str = ''
- arguments_part: str = ''
- arguments: str = ''
- comment_part: str = ''
- has_comment: bool = False
- has_argument: bool = False
- threshold: float | None = None
- indent_error: bool = False
- started: bool = False
- completed: bool = False
- action_history: list[str] = []
- _empty_node_class_names
- property name: str
Get node name. Parser guarantees it to not be None and be stripped. May be the empty string
- Return type:
str
- property instruction_name: str
- Return type:
str
- property runlog_name: str | None
- Return type:
str | None
- property display_name: str
- Return type:
str
- has_children()
- Return type:
bool
- can_load_state(state)
Determine whether state is valid for this kind of node
- Parameters:
state (NodeState)
- Return type:
bool
- get_child_by_instruction(instruction_name, arguments=None)
Find node by instruction name and optionally arguments.
- Parameters:
instruction_name (str)
arguments (str | None)
- Return type:
Node | None
- with_id(gen)
- Parameters:
gen (NodeIdGenerator)
- Return type:
Self
- has_error()
- Return type:
bool
- __str__()
- __repr__()
- as_tree()
- Return type:
str
- property parents: list[NodeWithChildren]
- Return type:
list[NodeWithChildren]
- property root: ProgramNode
- Return type:
- reset_runtime_state(recursive)
- Parameters:
recursive (bool)
- class openpectus.lang.model.ast.NodeWithChildren(position=Position.empty, id='')
Bases:
NodeDefines data for cancel and force operations that control interpretation behavior.
- interrupt_registered: bool = False
Whether an interrupt was registered to execute the node.
- children_complete: bool = False
Specifies that execution of child nodes should stop or is completed.
- _last_non_ws_line: int = 0
Populated by WhitespaceAnalyzer
- has_children()
- get_child_nodes(recursive=False, exclude_blocks=False)
- Parameters:
recursive (bool)
exclude_blocks (bool)
- Return type:
list[Node]
- get_first_child(node_type)
Return the first child node of the specified type, recursively, depth first
- Parameters:
node_type (Type[TNode])
- Return type:
TNode | None
- as_tree()
Return the node and its subtree as a string mimicing the source pcode
- Return type:
str
- apply_state(state)
- reset_runtime_state(recursive)
- class openpectus.lang.model.ast.ProgramNode(position=Position.empty, id='')
Bases:
NodeWithChildrenDefines data for cancel and force operations that control interpretation behavior.
- active_node: Node | None = None
The node currently executing. Is never ProgramNode. Is None untli first instruction is visited. Is not cleared at the end but keeps pointing to the last instruction.
The value is maintained by the interpreters program iterator.
- revision: int = 0
The program revision. Starts as 0 and increments every time an edit is performed while running.
- get_instructions(include_blanks=False)
Return list of all program instructions, recursively, depth first.
- Parameters:
include_blanks (bool)
- Return type:
list[Node]
- extract_tree_state()
Return map of all nodes’ state keyed by their node id.
This includes non-started nodes that should not be imported. apply_tree_state() handles the filtering on import.
- Return type:
dict[str, NodeState]
- reset_runtime_state(recursive)
- __str__()
- static empty()
- Return type:
- class openpectus.lang.model.ast.MarkNode(position=Position.empty, id='')
Bases:
NodeDefines data for cancel and force operations that control interpretation behavior.
- instruction_names = ['Mark']
Specifies which node the parser should instantiate for a given instruction name(s)
- _forcible = False
- class openpectus.lang.model.ast.BlockNode(position=Position.empty, id='')
Bases:
NodeWithChildrenDefines data for cancel and force operations that control interpretation behavior.
- instruction_names = ['Block']
Specifies which node the parser should instantiate for a given instruction name(s)
- lock_aquired = False
- reset_runtime_state(recursive)
- class openpectus.lang.model.ast.EndBlockNode(position=Position.empty, id='')
Bases:
NodeDefines data for cancel and force operations that control interpretation behavior.
- instruction_names = ['End block']
Specifies which node the parser should instantiate for a given instruction name(s)
- class openpectus.lang.model.ast.EndBlocksNode(position=Position.empty, id='')
Bases:
NodeDefines data for cancel and force operations that control interpretation behavior.
- instruction_names = ['End blocks']
Specifies which node the parser should instantiate for a given instruction name(s)
- class openpectus.lang.model.ast.BatchNode(position=Position.empty, id='')
Bases:
NodeDefines data for cancel and force operations that control interpretation behavior.
- instruction_names = ['Batch']
Specifies which node the parser should instantiate for a given instruction name(s)
- class openpectus.lang.model.ast.NodeWithTagOperatorValue(position=Position.empty, id='')
Bases:
NodeDefines data for cancel and force operations that control interpretation behavior.
- operators: list[str]
- tag_operator_value_part: str
- tag_operator_value: TagOperatorValue | None
- class openpectus.lang.model.ast.NodeWithCondition(position=Position.empty, id='')
Bases:
NodeWithTagOperatorValueDefines data for cancel and force operations that control interpretation behavior.
- operators = ['<=', '>=', '==', '!=', '<', '>', '=']
- interrupt_registered: bool = False
- activated: bool = False
Node condition was evaluated true
- reset_runtime_state(recursive)
- property cancellable: bool
Whether the node is cancellable in its current state. Virtual property.
- Return type:
bool
- property forcible: bool
Whether the node is forcible in its current state. Virtual property.
- Return type:
bool
- class openpectus.lang.model.ast.NodeWithAssignment(position=Position.empty, id='')
Bases:
NodeWithTagOperatorValueDefines data for cancel and force operations that control interpretation behavior.
- operators = ['=']
- class openpectus.lang.model.ast.WatchNode(position=Position.empty, id='')
Bases:
NodeWithChildren,NodeWithCondition,SupportsInterruptDefines data for cancel and force operations that control interpretation behavior.
- instruction_names = ['Watch']
Specifies which node the parser should instantiate for a given instruction name(s)
- class openpectus.lang.model.ast.AlarmNode(position=Position.empty, id='')
Bases:
NodeWithChildren,NodeWithCondition,SupportsInterruptDefines data for cancel and force operations that control interpretation behavior.
- instruction_names = ['Alarm']
Specifies which node the parser should instantiate for a given instruction name(s)
- run_count: int = 0
The number of times the alarm has completed
- extract_state()
- apply_state(state)
- reset_runtime_state(recursive)
- class openpectus.lang.model.ast.TagOperatorValue
- error = True
- lhs = ''
- op = ''
- rhs = ''
- tag_name: str | None = None
- tag_value: str | None = None
- tag_unit: str | None = None
- tag_value_numeric: int | float | None = None
- lhs_range
- stripped_lhs_range
- op_range
- rhs_range
- stripped_rhs_range
- tag_unit_range
- __str__()
- class openpectus.lang.model.ast.WhitespaceNode(position=Position.empty, id='')
Bases:
NodeRepresents a node that counts as whitespace in regards to interpretation, e.g. blank lines and comment lines.
Populated by WhitespaceAnalyzer
- has_only_trailing_whitespace: bool = False
Specifies that only whitespace instructions follow this whitespace instruction in the current scope as well as outer scopes.
- class openpectus.lang.model.ast.CommentNode(position=Position.empty, id='')
Bases:
WhitespaceNodeRepresents a line with only a comment.
- has_comment = True
- line: str = ''
- with_line(line)
- Parameters:
line (str)
- class openpectus.lang.model.ast.InjectedNode(position=Position.empty, id='')
Bases:
NodeWithChildren,SupportsInterruptDefines data for cancel and force operations that control interpretation behavior.
- class openpectus.lang.model.ast.MacroNode(position=Position.empty, id='')
Bases:
NodeWithChildrenDefines data for cancel and force operations that control interpretation behavior.
- instruction_names = ['Macro']
Specifies which node the parser should instantiate for a given instruction name(s)
- activated: bool = False
- _cancellable = False
- _forcible = False
- is_registered: bool = False
Whether the macro has been registered in the revision. Lifetime is revision.
- run_started_count: int = 0
The number of times the macro has started. Life time is the whole run
- extract_state()
- apply_state(state)
- prepare_for_call()
Clears state left over by any previous calls of the macro so it can be called again
- reset_runtime_state(recursive)
- class openpectus.lang.model.ast.CallMacroNode(position=Position.empty, id='')
Bases:
NodeDefines data for cancel and force operations that control interpretation behavior.
- instruction_names = ['Call macro']
Specifies which node the parser should instantiate for a given instruction name(s)
- _cancellable = False
- _forcible = False
- activated = False
- extract_state()
- apply_state(state)
- reset_runtime_state(recursive)
- class openpectus.lang.model.ast.NotifyNode(position=Position.empty, id='')
Bases:
NodeDefines data for cancel and force operations that control interpretation behavior.
- instruction_names = ['Notify']
Specifies which node the parser should instantiate for a given instruction name(s)
- _cancellable = False
- _forcible = False
- class openpectus.lang.model.ast.CommandBaseNode(position=Position.empty, id='')
Bases:
NodeDefines data for cancel and force operations that control interpretation behavior.
- class openpectus.lang.model.ast.InterpreterCommandNode(position=Position.empty, id='')
Bases:
CommandBaseNodeRepresents commands that are directly executable by the interpreter.
- instruction_names = ['Base', 'Increment run counter', 'Run counter', 'Wait']
Specifies which node the parser should instantiate for a given instruction name(s)
- wait_start_time: float | None = None
- extract_state()
- apply_state(state)
- reset_runtime_state(recursive)
- class openpectus.lang.model.ast.EngineCommandNode(position=Position.empty, id='')
Bases:
CommandBaseNodeRepresents internal engine commands that have a command class subclassing InternalEngineCommand.
- instruction_names = ['Stop', 'Pause', 'Unpause', 'Hold', 'Unhold', 'Restart', 'Info', 'Warning', 'Error']
Specifies which node the parser should instantiate for a given instruction name(s)
- class openpectus.lang.model.ast.SimulateNode(position=Position.empty, id='')
Bases:
NodeWithAssignmentDefines data for cancel and force operations that control interpretation behavior.
- instruction_names = ['Simulate']
Specifies which node the parser should instantiate for a given instruction name(s)
- class openpectus.lang.model.ast.SimulateOffNode(position=Position.empty, id='')
Bases:
NodeDefines data for cancel and force operations that control interpretation behavior.
- instruction_names = ['Simulate off']
Specifies which node the parser should instantiate for a given instruction name(s)
- class openpectus.lang.model.ast.UodCommandNode(position=Position.empty, id='')
Bases:
CommandBaseNodeRepresents a uod command, subclassing UodCommand.
- class openpectus.lang.model.ast.Comment(comment, position)
- Parameters:
comment (str)
position (Position)
- comment
- position
- class openpectus.lang.model.ast.Error(message=None)
- Parameters:
message (str | None)
- message: str | None = None
- class openpectus.lang.model.ast.BlankNode(position=Position.empty, id='')
Bases:
WhitespaceNodeRepresents a line that contains only whitespace.