def __init__(self, key, value, line_no): if is_debug(): print('init class: %s, with parameters: %s, %s, %s' % ('AssignCalcStatement', key, value, line_no)) super().__init__(line_no) self.key = key self.value = value
def __init__(self, label, line_no): if is_debug(): print('init class: %s, with parameters: %s, %s' % ('LabelStatement', label, line_no)) super().__init__(line_no, label) self.label = label self.table[self.label] = line_no
def __init__(self, k1, op, k2, label, line_no): if is_debug(): print('init class: %s, with parameters: %s, %s, %s, %s, %s' % ('IfStatement', k1, op, k2, label, line_no)) super().__init__(line_no) self.k1 = k1 self.op = op self.k2 = k2 self.label = label
def __run__(self): if is_debug(): print('Starting run program') index = 1 while True: if self.EXECUTION_PLAN.get(index) == None: break index = self.EXECUTION_PLAN[index].__next__()
import sys from statements import Factory as StatementFactory from lexer import tokenize from executer import Executer from tracer import is_debug """ """ if __name__ == '__main__': try: filename = sys.argv[1] file = open(filename) code = file.read() file.close() except (IndexError, FileNotFoundError): raise factory = StatementFactory() idx = 1 plan = {} for token in tokenize(code): if is_debug(): print(token) plan[idx] = factory.create_statement(token.value, token.paramaters) idx += 1 executer = Executer(plan) executer.__run__()
def __init__(self, label, line_no): if is_debug(): print('init class: %s, with parameters: %s, %s' % ('CallStatement', label, line_no)) super().__init__(label, line_no)
def __init__(self, key, line_no): if is_debug(): print('init class: %s, with parameters: %s, %s' % ('PrintStatement', key, line_no)) super().__init__(line_no) self.key = key