95 lines
2.8 KiB
Python
95 lines
2.8 KiB
Python
# Copyright (c) PARRRATE T&V 2021. All rights reserved.
|
|
|
|
from bu4.combinatory.lcombinatory import LCombinatory
|
|
from bu4.encoding.codes import CODE_CMBS
|
|
from bu4.evaluation.av.aftervalue import AfterValue
|
|
from bu4.evaluation.constructs.evaluable import Evaluable
|
|
from bu4.evaluation.constructs.etraceable import ETraceable
|
|
from bu4.evaluation.targets.avanonymouscontainer import AVAnonymousContainer
|
|
from bu4.evaluation.targets.avcall import AVCall
|
|
from bu4.indexing.constructs.indexed import Indexed
|
|
from bu4.indexing.evaluation.eivtype import eivtype
|
|
from bu4.linking.constructs.linked import Linked
|
|
from bu4.linking.evaluation.elvtype import elvtype
|
|
from bu4.parsing.extensions.CodeExtension import CodeExtension
|
|
from bu4.transform.states.transformfinished import TransformFinished
|
|
from bu4.transform.states.transformstate import TransformState
|
|
|
|
__all__ = ('ESC', 'ESC1', 'ESC2', 'ISC', 'XIS', 'LSC', 'XLS',)
|
|
|
|
|
|
class ESC2(ETraceable):
|
|
def __init__(self, argument: Evaluable, lambda_: Evaluable):
|
|
self.argument = AVAnonymousContainer(argument).after_value
|
|
self.lambda_ = lambda_
|
|
|
|
def call(self, argument: Evaluable) -> Evaluable:
|
|
argument = AVAnonymousContainer(argument).after_value
|
|
return AfterValue(
|
|
AfterValue(
|
|
self.lambda_,
|
|
AVCall(argument)
|
|
),
|
|
AVCall(
|
|
AfterValue(
|
|
self.argument,
|
|
AVCall(argument)
|
|
)
|
|
)
|
|
)
|
|
|
|
def __str__(self):
|
|
return f'/{self.argument}/{self.lambda_}S'
|
|
|
|
|
|
class ESC1(ETraceable):
|
|
def __init__(self, lambda_: Evaluable):
|
|
self.lambda_ = AVAnonymousContainer(lambda_).after_value
|
|
|
|
def call(self, argument: Evaluable) -> Evaluable:
|
|
return ESC2(argument, self.lambda_)
|
|
|
|
def __str__(self):
|
|
return f'/{self.lambda_}S'
|
|
|
|
|
|
class ESC(ETraceable):
|
|
def call(self, argument: Evaluable) -> Evaluable:
|
|
return ESC1(argument)
|
|
|
|
|
|
class ISC(Indexed):
|
|
def attach(self, ev: eivtype) -> Evaluable:
|
|
return ESC()
|
|
|
|
def bytes(self) -> TransformState[bytes]:
|
|
return TransformFinished(bytes([CODE_CMBS]))
|
|
|
|
def __str__(self):
|
|
return f'I'
|
|
|
|
|
|
class XIS(CodeExtension[Indexed], code=CODE_CMBS):
|
|
def apply(self) -> TransformState[Indexed]:
|
|
return TransformFinished(ISC())
|
|
|
|
|
|
class LSC(LCombinatory):
|
|
def __init__(self):
|
|
self.future = set()
|
|
self.multifuture = set()
|
|
|
|
def attach(self, env: elvtype) -> Evaluable:
|
|
return ESC()
|
|
|
|
def index(self, promise: list[bytes]) -> TransformState[Indexed]:
|
|
return TransformFinished(ISC())
|
|
|
|
def __str__(self):
|
|
return f'S'
|
|
|
|
|
|
class XLS(CodeExtension[Linked], code=CODE_CMBS):
|
|
def apply(self) -> TransformState[Linked]:
|
|
return TransformFinished(LSC())
|