31 lines
770 B
Python
31 lines
770 B
Python
# Copyright (c) PARRRATE T&V 2021. All rights reserved.
|
|
|
|
import abc
|
|
|
|
from bu4.evaluation.constructs.evaluable import Evaluable
|
|
from bu4.evaluation.constructs.evalue import EValue
|
|
|
|
__all__ = ('EVoid', 'ECoVoid',)
|
|
|
|
|
|
class EVoid(EValue, abc.ABC):
|
|
def call(self, argument: Evaluable) -> Evaluable:
|
|
if isinstance(argument, ECoVoid):
|
|
return argument.call(self)
|
|
else:
|
|
return self
|
|
|
|
|
|
class ECoVoid(EValue):
|
|
def void(self) -> EVoid:
|
|
raise NotImplementedError
|
|
|
|
def covoid(self, void: EVoid) -> Evaluable:
|
|
raise NotImplementedError
|
|
|
|
def call(self, argument: Evaluable) -> Evaluable:
|
|
if isinstance(argument, EVoid):
|
|
return self.covoid(argument)
|
|
else:
|
|
return self.void()
|