raesl.compile.machine_files.type_defs#

Line matcher state machines for type definitions.

Module Contents#

Functions#

get_unit_specification_part(→ str)

State machine part implementing the 'unit-specification' rule.

_convert_unit_spec(...)

Convert a unit specification to a list of unit names, if it exists.

get_enumeration_specification_part(→ str)

State machine part implementing the 'enumeration-specification' rule.

get_short_enumeration_specification_part(→ str)

State machine part implementing the short 'enumeration-specification' rule.

_convert_enum_spec(...)

Convert an enumeration specification to a number of values if it exists in the

get_interval_specification_part(→ str)

State machine part implementing the 'interval-specification' rule.

_convert_interval_spec(...)

Convert an interval specification of a line to a (disjunctive) sequence of

get_constant_specification_part(→ str)

State machine part implementing the 'constant-specification' rule.

_convert_constant_spec(...)

Convert a constant specification of a line to a Value if it exits.

_process_define_type(→ None)

_process_new_type_def(→ None)

_process_derived_type_def(→ None)

_process_bundle_type(→ None)

_process_bundle_field(→ None)

Attributes#

_DEFINE_TYPE_SPEC

_NEW_TYPE_SPEC

_TYPE_IS_A_TYPE_SPEC

_BUNDLE_TYPE_SPEC

_BUNDLE_FIELD_SPEC

MACHINES

raesl.compile.machine_files.type_defs.get_unit_specification_part(start_loc: str, end_1locs: List[str], prefix: str = '') str#

State machine part implementing the ‘unit-specification’ rule.

unit-specification ::=

“with” ( “unit” | “units” ) UNIT-NAME { “,” UNIT-NAME }

raesl.compile.machine_files.type_defs._convert_unit_spec(tags: Dict[str, List[raesl.compile.scanner.Token]]) List[raesl.compile.scanner.Token] | None#

Convert a unit specification to a list of unit names, if it exists.

raesl.compile.machine_files.type_defs.get_enumeration_specification_part(start_loc: str, end_2locs: List[str], prefix: str = '') str#

State machine part implementing the ‘enumeration-specification’ rule.

enumeration-specification ::=

“is” “an” “enumeration” “of” VALUE [ UNIT ] { “,” VALUE [ UNIT ]}

raesl.compile.machine_files.type_defs.get_short_enumeration_specification_part(start_loc: str, end_2locs: List[str], prefix: str = '') str#

State machine part implementing the short ‘enumeration-specification’ rule.

short-enumeration-specification ::=

“enumeration” “of” VALUE [ UNIT ] { “,” VALUE [ UNIT ]}

raesl.compile.machine_files.type_defs._convert_enum_spec(tags: Dict[str, List[raesl.compile.scanner.Token]]) List[raesl.compile.ast.exprs.Value] | None#

Convert an enumeration specification to a number of values if it exists in the given tags.

Parameters:

tags – Tags from the matched line.

Returns:

Values of the enumeration.

raesl.compile.machine_files.type_defs.get_interval_specification_part(start_loc: str, end_4locs: List[str], prefix: str = '') str#

State machine part implementing the ‘interval-specification’ rule.

interval-specification ::=

“of” interval { “or” interval }

raesl.compile.machine_files.type_defs._convert_interval_spec(tags: Dict[str, List[raesl.compile.scanner.Token]]) List[Tuple[raesl.compile.ast.exprs.Value | None, raesl.compile.ast.exprs.Value | None]] | None#

Convert an interval specification of a line to a (disjunctive) sequence of expressions, if such a specification exists in the given tags.

raesl.compile.machine_files.type_defs.get_constant_specification_part(start_loc: str, end_2locs: List[str], prefix: str = '') str#

State machine part implementing the ‘constant-specification’ rule.

constant-specification ::=

“equal” “to” VALUE [ UNIT ]

raesl.compile.machine_files.type_defs._convert_constant_spec(tags: Dict[str, List[raesl.compile.scanner.Token]]) raesl.compile.ast.exprs.Value | None#

Convert a constant specification of a line to a Value if it exits.

raesl.compile.machine_files.type_defs._DEFINE_TYPE_SPEC = Multiline-String#
Show Value
"""
define_type:
    start initial;
    start -> s1 [DEFINE_KW] tag=define;
    s1 -> s2 [TYPE_KW];

    end accept=define_type;
    s2 -> end [NL_TK];
    s2 -> end [EOF_TK];
"""
raesl.compile.machine_files.type_defs._process_define_type(tags: raesl.compile.machine_files.typing.TokensDict, _accept: str, builder: raesl.compile.typechecking.ast_builder.AstBuilder) None#
raesl.compile.machine_files.type_defs._NEW_TYPE_SPEC#
raesl.compile.machine_files.type_defs._process_new_type_def(tags: raesl.compile.machine_files.typing.TokensDict, _accept: str, builder: raesl.compile.typechecking.ast_builder.AstBuilder) None#
raesl.compile.machine_files.type_defs._TYPE_IS_A_TYPE_SPEC#
raesl.compile.machine_files.type_defs._process_derived_type_def(tags: raesl.compile.machine_files.typing.TokensDict, _accept: str, builder: raesl.compile.typechecking.ast_builder.AstBuilder) None#
raesl.compile.machine_files.type_defs._BUNDLE_TYPE_SPEC = Multiline-String#
Show Value
"""
bundle_type:
    start initial;
    start -> s1 [NAME] tag=bundle_name;
    s1 -> s2 [IS_KW];
    s2 -> s3 [A_KW];
    s3 -> s4 [BUNDLE_KW];
    s4 -> s5 [OF_KW];

    end accept=bundle_type;
    s5 -> end [NL_TK];
    s5 -> end [EOF_TK];
"""
raesl.compile.machine_files.type_defs._process_bundle_type(tags: raesl.compile.machine_files.typing.TokensDict, _accept: str, builder: raesl.compile.typechecking.ast_builder.AstBuilder) None#
raesl.compile.machine_files.type_defs._BUNDLE_FIELD_SPEC = Multiline-String#
Show Value
"""
bundle_field:
    start initial;
    end accept=bundle_field;

    start -> s1 [STAR_TK];
    s1 -> s2 [NAME] tag=field_name;
    s2 -> s3 [IS_KW];
    s3 -> s4 [A_KW];

    s4 -> s5 [NAME] tag=field_type;

    s5 -> end [NL_TK];
    s5 -> end [EOF_TK];
"""
raesl.compile.machine_files.type_defs._process_bundle_field(tags: raesl.compile.machine_files.typing.TokensDict, _accept: str, builder: raesl.compile.typechecking.ast_builder.AstBuilder) None#
raesl.compile.machine_files.type_defs.MACHINES: raesl.compile.machine_files.typing.MachineTripletList = [('DEFINE_TYPE_MACHINE',), ('NEW_TYPE_MACHINE',), ('TYPE_IS_A_TYPE_MACHINE',),...#