raesl.compile.ast.types#

AST storage of types.

Module Contents#

Classes#

BaseType

Base class of a type.

ElementaryType

A type of a singular value in ESL. The allowed values in a parent type always

TypeDef

A named type.

CompoundField

A named field in a Compound.

Compound

A collection of named typed values. Note that a Compound cannot have parents,

class raesl.compile.ast.types.BaseType#

Base class of a type.

abstract get_units() Set[str] | None#

Retrieve the units that may be used with values of the type.

Returns:

Set of unit names, set([‘-‘]) if it has no units specified, or None if the

type doesn’t support units.

class raesl.compile.ast.types.ElementaryType(parent: ElementaryType | None, units: List[raesl.compile.scanner.Token], intervals: List[Tuple[raesl.compile.ast.exprs.Value | None, raesl.compile.ast.exprs.Value | None]] | None)#

Bases: BaseType

A type of a singular value in ESL. The allowed values in a parent type always have priority over the allowed values in a child type.

Parameters:
  • parent – Parent elementary type if specified.

  • units – Allowed units of the type, should not have square brackets around the text.

  • intervals – Disjunction of allowed ranges of the type, pairs of (lowerbound, upperbound) where one of the bounds may be None. Constants and enumerations are expressed as intervals with the same lower and upper bound.

get_units()#

Retrieve the units that may be used with values of the type.

Returns:

Set of unit names, set([‘-‘]) if it has no units specified, or None if the

type doesn’t support units.

class raesl.compile.ast.types.TypeDef(name: raesl.compile.scanner.Token, the_type: BaseType)#

A named type.

Parameters:
  • name – Name of the type definition.

  • the_type – Type associated with the name.

class raesl.compile.ast.types.CompoundField(name: raesl.compile.scanner.Token, the_type: BaseType)#

A named field in a Compound.

Parameters:
  • name – Name of the compound field.

  • the_type – Type of the compound field.

class raesl.compile.ast.types.Compound(fields: List[CompoundField])#

Bases: BaseType

A collection of named typed values. Note that a Compound cannot have parents, units, or intervals.

Parameters:

fields – Fields of the compound.

get_units()#

Retrieve the units that may be used with values of the type.

Returns:

Set of unit names, set([‘-‘]) if it has no units specified, or None if the

type doesn’t support units.