raesl.compile.ast.components#

Component definitions with their contents.

Module Contents#

Classes#

ComponentDefinition

ESL component definition.

VarParam

ESL component definition variable or parameter.

VariableGroup

One variable group in ESL (a named group of variables).

InstanceArgument

Actual argument of a component or relation.

ComponentInstance

ESL component instance in a component definition.

RelationInstance

ESL relation instance in a component definition.

Flow

Flow in a goal or Transformation.

Goal

Goal in an ESL component definition.

Transformation

Transformation in a component.

Design

Design rule in a component.

SubClause

Subclause in a goal, transformation, or behavior.

BehaviorFunction

One function specifying some behavior.

BehaviorCondition

A condition of a case.

BehaviorResult

A result of a case.

BehaviorCase

A set of desired behavioral results given a set of conditions.

Need

Informal need in ESL.

Functions#

get_doc_comment_comp_elements(...)

Retrieve the component elements interested in getting documentation comments from

Attributes#

CONSTRAINT

REQUIREMENT

NeedSubjectTypes

raesl.compile.ast.components.CONSTRAINT = 'constraint'#
raesl.compile.ast.components.REQUIREMENT = 'requirement'#
class raesl.compile.ast.components.ComponentDefinition(pos_tok: raesl.compile.scanner.Token, name_tok: raesl.compile.scanner.Token | None)#

Bases: raesl.compile.ast.comment_storage.DefaultDocStore

ESL component definition.

Parameters:
  • pos_tok – Position of the definition. Either the name token or the ‘world’ token.

  • name_tok – Token with the name of the component definition, None means ‘world’.

variables#

Variables of the component definition.

parameters#

Parameters of the component definition.

var_groups#

Groups of variables with a name.

component_instances#

Component instances of the component definition.

needs#

Needs of the component definition.

goals#

Goals of the component definition.

transforms#

Transformations of the component definition.

designs#

Designs of the component definition.

relations#

Relation instances of the component definition.

behaviors#

Behavior functions of the component definition.

class raesl.compile.ast.components.VarParam(is_variable: bool, name_tok: raesl.compile.scanner.Token, type_tok: raesl.compile.scanner.Token, is_property: bool = False)#

Bases: raesl.compile.ast.comment_storage.DocStore

ESL component definition variable or parameter.

Parameters:
  • is_variable – Whether the object represents a variable.

  • name_tok – Token with the name of the variable being defined.

  • type_tok – Token with the name of the type of the variable being defined.

  • is_property – Whether the parameter is a property.

type#

Type of the variable, if it exists. Set during type checking.

resolve_node(name: str) raesl.compile.ast.nodes.VarNode | None#

Find the varparam (sub) node that matches the dotted ‘name’.

Parameters:

name – Possibly dotted name that should point at an existing sub-node. The empty string denotes ‘self’.

Returns:

The node that matches the name, or None if no such node exists. In the

latter case, use ‘self.get_error_position(name)’ to get an indication where the match fails in the name.

resolve_element(name: str) raesl.compile.ast.comment_storage.DocAddElement | None#

Try to find the documentation element indicated by its (dotted) name.

Parameters:

name – Name of the element to find.

Returns:

The documentation element associated with the provided name if it can be

resolved.

get_error_position(name: str)#

Return the index in the given string where an error occurs in resolving the node.

Parameters:

name – Name of the element to find.

Returns:

Approximated index in the string where matching the element fails.

Returned value has no meaning if resolving a node succeeds.

__repr__()#

Return repr(self).

class raesl.compile.ast.components.VariableGroup(name_tok: raesl.compile.scanner.Token, variablepart_names: List[raesl.compile.scanner.Token])#

One variable group in ESL (a named group of variables).

It has no documentation comment, as its only purpose is to enable interfacing to child components.

As a variable group doesn’t need to contain uniquely named variables, their names cannot be used to build a Compound type. Therefore, it just stays a group, and it gets dealt with in component instantiation.

Parameters:
  • name_tok – Token with the name of the group being defined.

  • variablepart_names – Tokens with possibly dotted name of variable parts in the group.

node#

Node representing the group, if available.

class raesl.compile.ast.components.InstanceArgument(name_tok: raesl.compile.scanner.Token, argnode: raesl.compile.ast.nodes.Node | None = None)#

Actual argument of a component or relation.

Parameters:
  • name_tok – Name of the actual argument.

  • argnode – Node of the argument, filled during type checking.

class raesl.compile.ast.components.ComponentInstance(inst_name_tok: raesl.compile.scanner.Token, def_name_tok: raesl.compile.scanner.Token)#

Bases: raesl.compile.ast.comment_storage.DefaultDocStore

ESL component instance in a component definition.

Parameters:
  • inst_name_tok – Token with the name of the component instance.

  • def_name_tok – Token withe the name of the component definition to apply.

arguments#

Arguments of the instance.

compdef#

Component definition matching the name in ‘def_name_tok’, if it exists. Set during type checking.

class raesl.compile.ast.components.RelationInstance(inst_name_tok: raesl.compile.scanner.Token, def_name_tok: raesl.compile.scanner.Token, arguments: List[List[InstanceArgument]], reldef: raesl.compile.ast.relations.RelationDefinition | None)#

Bases: raesl.compile.ast.comment_storage.DefaultDocStore

ESL relation instance in a component definition.

Parameters:
  • inst_name_tok – Token with the name of the relation instance.

  • def_name_tok – Token withe the name of the relation definition to apply.

  • arguments – Arguments of the instance. One element for each parameter, where one element may have several arguments due to the ‘one or more’ feature.

  • reldef – Relation definition of this instance.

class raesl.compile.ast.components.Flow(name_tok)#

Flow in a goal or Transformation.

Parameters:

name_tok – Dotted name of the flow.

flow_node#

If not None, node represented by the flow.

class raesl.compile.ast.components.Goal(label_tok: raesl.compile.scanner.Token, active: raesl.compile.scanner.Token, doesaux: raesl.compile.scanner.Token, verb: raesl.compile.scanner.Token, flows: List[Flow], prepos: raesl.compile.scanner.Token, passive: raesl.compile.scanner.Token)#

Bases: raesl.compile.ast.comment_storage.DefaultDocStore

Goal in an ESL component definition.

Parameters:
  • label_tok – Label name of the goal.

  • active – Token with the name of the active component.

  • doesaux – ‘does’ or auxiliary word token.

  • verb – Verb of the goal.

  • flows – Flows of the goal.

  • prepos – Token with the preposition word.

  • passive – Token with the name of the passive component.

goal_kind#

Kind of goal, filled after construction. Either ‘requirement’ or ‘constraint’ string.

sub_clauses#

Sub-clauses of the goal.

active_comp#

If not None, resolved active component instance of the goal.

passive_comp#

If not None, resolved passive component instance of the goal.

class raesl.compile.ast.components.Transformation(label_tok: raesl.compile.scanner.Token, doesaux_tok: raesl.compile.scanner.Token, verb_tok: raesl.compile.scanner.Token, in_flows: List[Flow], prepos_tok: raesl.compile.scanner.Token, out_flows: List[Flow])#

Bases: raesl.compile.ast.comment_storage.DefaultDocStore

Transformation in a component.

Parameters:
  • label_tok – Label name of the transformation.

  • doesaux_tok – ‘does’ or aux word token.

  • verb_tok – Verb of the transformation.

  • in_flows – Inputs required for the transformation.

  • prepos_tok – Preposition of the transformation.

  • out_flows – Outputs resulting from the transformation.

transform_kind#

Kind of transformation, filled after construction. Either ‘requirement’ or ‘constraint’ string.

sub_clauses#

Sub-clauses of the transformation.

class raesl.compile.ast.components.Design(label_tok: raesl.compile.scanner.Token, expr: raesl.compile.ast.exprs.Expression)#

Bases: raesl.compile.ast.comment_storage.DefaultDocStore

Design rule in a component.

Parameters:
  • label_tok – Name of the design rule.

  • expr – Condition expressed in the design.

design_kind#

Kind of the design, filled in after construction. Contains either ‘requirement’ or ‘constraint’.

sub_clauses#

Sub-clauses of the design.

class raesl.compile.ast.components.SubClause(label_tok: raesl.compile.scanner.Token, expr: raesl.compile.ast.exprs.Expression)#

Subclause in a goal, transformation, or behavior.

Parameters:
  • label_tok – Name of the subclause.

  • expr – Expression describing the subclause.

class raesl.compile.ast.components.BehaviorFunction(behavior_kind: str, name_tok: raesl.compile.scanner.Token)#

Bases: raesl.compile.ast.comment_storage.DefaultDocStore

One function specifying some behavior.

Parameters:
  • behavior_kind – Kind of behavior. Either ‘requirement’ or ‘constraint’.

  • name_tok – Name of the behavior.

cases#

Behavior cases.

default_results#

Results that hold when none of the cases applies. None means there is no default result.

class raesl.compile.ast.components.BehaviorCondition(name_tok: raesl.compile.scanner.Token, comparison: raesl.compile.ast.exprs.Disjunction | raesl.compile.ast.exprs.RelationComparison)#

A condition of a case.

class raesl.compile.ast.components.BehaviorResult(name_tok: raesl.compile.scanner.Token, result: raesl.compile.ast.exprs.Comparison)#

A result of a case.

class raesl.compile.ast.components.BehaviorCase(name_tok: raesl.compile.scanner.Token, conditions: List[BehaviorCondition], results: List[BehaviorResult])#

A set of desired behavioral results given a set of conditions.

Parameters:
  • name_tok – Name of the behavior case.

  • conditions – Conditions that should hold for the case to apply.

  • results – Results that should hold when the case applies.

raesl.compile.ast.components.NeedSubjectTypes#
class raesl.compile.ast.components.Need(label_tok: raesl.compile.scanner.Token, subject_tok: raesl.compile.scanner.Token, description: str)#

Bases: raesl.compile.ast.comment_storage.DefaultDocStore

Informal need in ESL.

Parameters:
  • label_tok – Token with the name of the label.

  • subject_tok – Token with the name of the subject of the need.

  • description – Description of the need.

subject#

If not None, subject of the need.

raesl.compile.ast.components.get_doc_comment_comp_elements(comp: ComponentDefinition) Generator[raesl.compile.ast.comment_storage.DocStore, None, None]#

Retrieve the component elements interested in getting documentation comments from the input. This includes the component itself, so you can add documentation to it in its ‘comments’ section.

Parameters:

comp – Component definition to search.

Returns:

Generator yielding interested elements.