def __init__(self, lexical, raw_str, value, offset): self.__lexical__ = lexical self.__raw_str__ = raw_str self.__value__ = value self.__offset__ = offset s0 = State() s1 = State() s0.link(s1, self.__value__) self.graph = StateGraph(s0, s1)
def reduce8(state_stack, parse_stack, input_stack): """reduce => x : F *""" state_stack.pop() p2 = parse_stack.pop() assert p2.lexical_unit() == '*' state_stack.pop() p1 = parse_stack.pop() assert p1.lexical_unit() == 'F' state_stack.append(__goto_table__[state_stack[-1]]['x']) p0 = Elem('x', 'x', 'x', p1.offset()) s0 = State() s1 = State() p0.graph = StateGraph(s0, s1) s0.link(p1.graph.start, EPSILON) s0.link(s1, EPSILON) p1.graph.final.link(s1, EPSILON) p1.graph.final.link(s0, EPSILON) parse_stack.append(p0)
def reduce2(state_stack, parse_stack, input_stack): """reduce => s : t | s""" state_stack.pop() p3 = parse_stack.pop() assert p3.lexical_unit() == 's' state_stack.pop() p2 = parse_stack.pop() assert p2.lexical_unit() == '|' state_stack.pop() p1 = parse_stack.pop() assert p1.lexical_unit() == 't' state_stack.append(__goto_table__[state_stack[-1]]['s']) p0 = Elem('s', 's', 's', p1.offset()) s0 = State() s1 = State() p0.graph = StateGraph(s0, s1) s0.link(p1.graph.start, EPSILON) s0.link(p3.graph.start, EPSILON) p1.graph.final.link(s1, EPSILON) p3.graph.final.link(s1, EPSILON) parse_stack.append(p0)