def p_postfix_expr ( self , p ) : if len ( p ) == 2 : p [ 0 ] = p [ 1 ] else : p [ 0 ] = ast . UnaryOp ( op = p [ 2 ] , value = p [ 1 ] , postfix = True )
python postfix expression calculator
postfix_expr : left_hand_side_expr | left_hand_side_expr PLUSPLUS | left_hand_side_expr MINUSMINUS
def p_postfix_expr(self, p):
        """postfix_expr : left_hand_side_expr
                        | left_hand_side_expr PLUSPLUS
                        | left_hand_side_expr MINUSMINUS
        """
        if len(p) == 2:
            p[0] = p[1]
        else:
            p[0] = ast.UnaryOp(op=p[2], value=p[1], postfix=True)