def consJoin(elements, join, unit, assoc=False): if len(elements) == 0: return KConstant(unit) elif assoc and len(elements) == 1: return elements[0] else: return KApply(join, [elements[0], consJoin(elements[1:], join, unit)])
def depthBound(step, bound): if type(bound) is int: bound = intToken(bound) elif type(bound) is str and bound == "*": bound = KConstant('*_KMCD-GEN_DepthBound') else: _fatal('Unknown depth bound: ' + str(bound)) return KApply('___KMCD-GEN_GenStep_GenStep_DepthBound', [step, bound])
bound = KConstant('*_KMCD-GEN_DepthBound') else: _fatal('Unknown depth bound: ' + str(bound)) return KApply('___KMCD-GEN_GenStep_GenStep_DepthBound', [step, bound]) def consJoin(elements, join, unit, assoc=False): if len(elements) == 0: return KConstant(unit) elif assoc and len(elements) == 1: return elements[0] else: return KApply(join, [elements[0], consJoin(elements[1:], join, unit)]) genStep = KConstant('GenStep_KMCD-GEN_GenStep') genSteps = KConstant('GenSteps_KMCD-GEN_MCDSteps') snapshot = KConstant('snapshot_KMCD-GEN_AdminStep') def mcdSteps(steps): return consJoin(steps, '___KMCD-DRIVER_MCDSteps_MCDStep_MCDSteps', '.MCDSteps_KMCD-DRIVER_MCDSteps') def generatorSequence(genSteps): return consJoin(genSteps, '_;__KMCD-GEN_GenStep_GenStep_GenStep', '.GenStep_KMCD-GEN_GenStep', assoc=True)
bound = intToken(bound) elif type(bound) is str and bound == "*": bound = KConstant('*_KMCD-GEN_DepthBound') else: _fatal('Unknown depth bound: ' + str(bound)) return KApply('___KMCD-GEN_GenStep_GenStep_DepthBound', [step, bound]) def consJoin(elements, join, unit, assoc = False): if len(elements) == 0: return KConstant(unit) elif assoc and len(elements) == 1: return elements[0] else: return KApply(join, [elements[0], consJoin(elements[1:], join, unit)]) genStep = KConstant('GenStep_KMCD-GEN_GenStep') genSteps = KConstant('GenSteps_KMCD-GEN_MCDSteps') snapshot = KConstant('snapshot_KMCD-GEN_AdminStep') def mcdSteps(steps): return consJoin(steps, '___KMCD-DRIVER_MCDSteps_MCDStep_MCDSteps', '.MCDSteps_KMCD-DRIVER_MCDSteps') def generatorSequence(genSteps): return consJoin(genSteps, '_;__KMCD-GEN_GenStep_GenStep_GenStep', '.GenStep_KMCD-GEN_GenStep', assoc = True) def generatorChoice(genSteps): return consJoin(genSteps, '_|__KMCD-GEN_GenStep_GenStep_GenStep', '.GenStep_KMCD-GEN_GenStep', assoc = True) def addGenerator(generator): return KApply('AddGenerator(_)_KMCD-GEN_AdminStep_GenStep', [generator])