concepts.dsl.executors.executor_base.DSLExecutorBase#
- class DSLExecutorBase[source]#
Bases:
ABC
The baseclass for all executors of domain-specific languages.
Methods
execute
(expression)Execute an expression.
Get the implementation of a function.
Check whether the executor has an implementation for a function.
register_function
(name, func)Register an implementation for a function to the executor.
register_function_implementation
(name, func)Register an implementation for a function.
Attributes
The domain of the executor.
The implementations of functions, which is a mapping from function names to implementations.
- __init__(domain)[source]#
Initialize the executor.
- Parameters:
domain (DSLDomainBase) – the domain of the executor.
- __new__(**kwargs)#
- abstract execute(expression)[source]#
Execute an expression.
- Parameters:
expression (Expression) – the expression to execute.
- Returns:
the result of the execution.
- Return type:
- get_function_implementation(name)[source]#
Get the implementation of a function. When the executor does not have an implementation for the function, the implementation of the function in the domain will be returned. If that is also None, a KeyError will be raised.
- has_function_implementation(name)[source]#
Check whether the executor has an implementation for a function.
- register_function(name, func)[source]#
Register an implementation for a function to the executor. Alias for
register_function_implementation()
.
- property domain: DSLDomainBase#
The domain of the executor.