()
+def PEUnary(op, o1):
+ #Leaf(token.STRING, ' ')
+ try:
+ return Node(syms.atom, [op, o1])
+ except:
+ return "error in PEUnary: "+str(op)+","+str(o1)
+
+
+def PEBinary(op, o1, o2):
+ try:
+ return Node(syms.atom, [o1, Leaf(token.STRING, ' '), op, Leaf(token.STRING, ' '), o2])
+ except:
+ return "error in PEBinary: "+str(op)+","+str(o1)+","+str(o2)
+
+# unary minus
+
+
def p_expression_5(p):
'''expression : '-' attribute_list_opt expr_primary %prec UNARY_PREC '''
if(parse_debug):
print('expression_5', list(p))
+ p[0] = PEUnary(Leaf(token.MINUS, '-'), p[3])
+
# { PEUnary*tmp = new PEUnary('-', p[3]);
# FILE_NAME(tmp, @3);
# p[0] = tmp;
if(parse_debug):
print('expression_6', list(p))
+ p[0] = PEUnary(Leaf(token.TILDE, '~'), p[3])
+
# { PEUnary*tmp = new PEUnary('~', p[3]);
# FILE_NAME(tmp, @3);
# p[0] = tmp;
if(parse_debug):
print('expression_7', list(p))
+ p[0] = PEUnary(Leaf(token.AMPER, '&'), p[3])
+
# { PEUnary*tmp = new PEUnary('&', p[3]);
# FILE_NAME(tmp, @3);
# p[0] = tmp;
if(parse_debug):
print('expression_8', list(p))
+ p[0] = PEUnary(Leaf(token.STRING, '!'), p[3])
+
# { PEUnary*tmp = new PEUnary('!', p[3]);
# FILE_NAME(tmp, @3);
# p[0] = tmp;
if(parse_debug):
print('expression_9', list(p))
+ p[0] = PEUnary(Leaf(token.STRING, '|'), p[3])
+
# { PEUnary*tmp = new PEUnary('|', p[3]);
# FILE_NAME(tmp, @3);
# p[0] = tmp;
if(parse_debug):
print('expression_10', list(p))
+ p[0] = PEUnary(Leaf(token.STRING, '^'), p[3])
+
# { PEUnary*tmp = new PEUnary('^', p[3]);
# FILE_NAME(tmp, @3);
# p[0] = tmp;
if(parse_debug):
print('expression_14', list(p))
+ p[0] = PEUnary(Leaf(token.STRING, 'K_NAND'), p[3])
+
# { PEUnary*tmp = new PEUnary('A', p[3]);
# FILE_NAME(tmp, @3);
# p[0] = tmp;
if(parse_debug):
print('expression_15', list(p))
+ p[0] = PEUnary(Leaf(token.STRING, 'K_NOR'), p[3])
+
# { PEUnary*tmp = new PEUnary('N', p[3]);
# FILE_NAME(tmp, @3);
# p[0] = tmp;
if(parse_debug):
print('expression_16', list(p))
+ p[0] = PEUnary(Leaf(token.STRING, 'K_NXOR'), p[3])
+
# { PEUnary*tmp = new PEUnary('X', p[3]);
# FILE_NAME(tmp, @3);
# p[0] = tmp;
if(parse_debug):
print('expression_19', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, '^'), p[1], p[4])
+
# { PEBinary*tmp = new PEBinary('^', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_20', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, '**'), p[1], p[4])
+
# { PEBinary*tmp = new PEBPower('p', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_21', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, '*'), p[1], p[4])
+
# { PEBinary*tmp = new PEBinary('*', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_22', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, '/'), p[1], p[4])
+
# { PEBinary*tmp = new PEBinary('/', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_23', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, '%'), p[1], p[4])
+
# { PEBinary*tmp = new PEBinary('%', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
# FILE_NAME(tmp, @2);
# p[0] = tmp;
# }
+ p[0] = PEBinary(Leaf(token.PLUS, '+'), p[1], p[4])
+
+
()
def p_expression_25(p):
'''expression : expression '-' attribute_list_opt expression '''
- if(parse_debug):
+ if(parse_debug > 2):
print('expression_25', list(p))
# { PEBinary*tmp = new PEBinary('-', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
# }
- try:
- p[0] = Node(syms.atom, [p[1], Leaf(token.MINUS, '-'), p[4]])
- except:
- p[0] = "bad input in p_expression_25"
+ p[0] = PEBinary(Leaf(token.MINUS, '-'), p[1], p[4])
()
def p_expression_26(p):
'''expression : expression '&' attribute_list_opt expression '''
- if(parse_debug):
+ if(parse_debug > 2):
print('expression_26', list(p))
+ p[0] = PEBinary(Leaf(token.AMPER, '&'), p[1], p[4])
+
# { PEBinary*tmp = new PEBinary('&', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
def p_expression_27(p):
'''expression : expression '|' attribute_list_opt expression '''
- if(parse_debug):
+ if(parse_debug > 2):
print('expression_27', list(p))
+ p[0] = PEBinary(Leaf(token.VBAR, '|'), p[1], p[4])
+
+
# { PEBinary*tmp = new PEBinary('|', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_28', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, '~&'), p[1], p[4])
+
# { PEBinary*tmp = new PEBinary('A', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_29', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, '~|'), p[1], p[4])
+
# { PEBinary*tmp = new PEBinary('O', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_30', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, 'K_XNOR'), p[1], p[4])
+
# { PEBinary*tmp = new PEBinary('X', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_31', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, '<'), p[1], p[4])
+
# { PEBinary*tmp = new PEBComp('<', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_32', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, '>'), p[1], p[4])
+
# { PEBinary*tmp = new PEBComp('>', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_33', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, 'K_LS'), p[1], p[4])
+
# { PEBinary*tmp = new PEBShift('l', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_34', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, 'K_RS'), p[1], p[4])
+
# { PEBinary*tmp = new PEBShift('r', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_35', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, 'K_RSS'), p[1], p[4])
+
# { PEBinary*tmp = new PEBShift('R', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_36', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, '=='), p[1], p[4])
+
# { PEBinary*tmp = new PEBComp('e', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_37', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, 'K_CEQ'), p[1], p[4])
+
# { PEBinary*tmp = new PEBComp('E', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_38', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, 'K_WEQ'), p[1], p[4])
+
# { PEBinary*tmp = new PEBComp('w', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_39', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, '<='), p[1], p[4])
+
# { PEBinary*tmp = new PEBComp('L', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_40', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, '>='), p[1], p[4])
+
# { PEBinary*tmp = new PEBComp('G', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_41', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, '!='), p[1], p[4])
+
# { PEBinary*tmp = new PEBComp('n', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_42', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, 'K_CNE'), p[1], p[4])
+
# { PEBinary*tmp = new PEBComp('N', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_43', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, 'K_WNE'), p[1], p[4])
+
# { PEBinary*tmp = new PEBComp('W', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_44', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, '||'), p[1], p[4])
+
# { PEBinary*tmp = new PEBLogic('o', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_45', list(p))
+ p[0] = PEBinary(Leaf(token.STRING, '&&'), p[1], p[4])
+
# { PEBinary*tmp = new PEBLogic('a', p[1], p[4]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;
if(parse_debug):
print('expression_46', list(p))
+ p[0] = Node(syms.atom, [p[1], Leaf(token.STRING, ' ? '),
+ p[4], Leaf(token.STRING, ' : '), p[6]])
+
# { PETernary*tmp = new PETernary(p[1], p[4], p[6]);
# FILE_NAME(tmp, @2);
# p[0] = tmp;