def p_statement_and_or(p): '''statement : statement AND statement | statement OR statement | statement AND_NOT statement | statement OR_NOT statement ''' if p[1].is_leaf(): p[0] = lool_node() p[0].adopt_child(p[1]) else: p[0] = p[1] p[0].adopt_child(p[3]) p[1].operator = 'OR' p[3].operator = p[2].upper()
def p_statement_no_operator(p): '''statement : statement statement ''' if debug: print "13: " + str(p[0]) if debug: print "14: " + str(p[1]) if debug: print "15: " + str(p[2]) if debug: print "16: " + str(p[1].parent) if debug: print "17: " + str(p[2].parent) if debug: print "18: " + str(p[1].is_leaf()) if debug: print "19: " + str(p[2].is_leaf()) if p[2].is_leaf(): p[0] = lool_node() p[0].adopt_child(p[1]) p[0].adopt_child(p[2]) p[2].operator = 'OR' p[1].operator = 'OR' else: p[0] = p[2] p[0].adopt_child_reverse(p[1]) p[1].operator = 'OR'
def p_statement_term(p): '''statement : TERM ''' p[0] = lool_node() p[0].val = p[1]