concepts.dsl.dsl_domain.DSLDomainBase#

class DSLDomainBase[source]#

Bases: object

The baseclass for the domain definition of a domain-specific language.

Methods

define_const(dtype, value)

Define a constant with the given type and value.

define_function(function[, implementation])

Define a function in the domain.

define_type(t)

Define a type in the domain.

get_function(name)

Get the function with the given name.

has_function(name)

Check whether the domain has a function with the given name.

Attributes

name

The name of the domain.

types

The types defined in the domain, as a dictionary from type names to types.

functions

The functions defined in the domain, as a dictionary from function names to functions.

constants

The constants defined in the domain, as a dictionary from the name to the Value objects.

__init__(name=None)[source]#

Initialize the domain.

Parameters:

name (str | None) – the name of the domain. If not specified, the name of the class will be used.

__new__(**kwargs)#
define_const(dtype, value)[source]#

Define a constant with the given type and value.

Parameters:
  • dtype (ObjectType | ValueType) – the type of the constant.

  • value (str) – the value of the constant. The value should be a string that is the name of the constant.

define_function(function, implementation=True)[source]#

Define a function in the domain.

Parameters:
  • function (Function | Callable) – the function to be defined.

  • implementation (bool) – whether to store the function body of function as the implementation of the function.

Returns:

the function that is defined.

Return type:

Function

define_type(t)[source]#

Define a type in the domain.

Parameters:

t (ObjectType | ValueType) – the type to be defined.

Returns:

the type that is defined.

Return type:

ObjectType | ValueType

get_function(name)[source]#

Get the function with the given name.

Parameters:

name (str) – the name of the function.

Returns:

the function with the given name.

Return type:

Function

has_function(name)[source]#

Check whether the domain has a function with the given name.

Parameters:

name (str) – the name of the function.

Returns:

whether the domain has a function with the given name.

Return type:

bool

constants: Dict[str, ObjectConstant | Value]#

The constants defined in the domain, as a dictionary from the name to the Value objects.

functions: Dict[str, Function]#

The functions defined in the domain, as a dictionary from function names to functions.

name: str#

The name of the domain.

types: Dict[str, ObjectType | ValueType]#

The types defined in the domain, as a dictionary from type names to types.