cprover
format_expr.cpp File Reference

Expression Pretty Printing. More...

#include "format_expr.h"
#include "arith_tools.h"
#include "expr.h"
#include "expr_iterator.h"
#include "fixedbv.h"
#include "format_type.h"
#include "ieee_float.h"
#include "invariant.h"
#include "mp_arith.h"
#include "rational.h"
#include "rational_tools.h"
#include "std_code.h"
#include "std_expr.h"
#include "string2int.h"
#include "string_utils.h"
#include <ostream>
#include <stack>
Include dependency graph for format_expr.cpp:

Go to the source code of this file.

Functions

static bool bracket_subexpression (const exprt &sub_expr, const exprt &expr)
 We use the precendences that most readers expect (i.e., the ones you learn in primary school), and stay clear of the surprising ones that C has. More...
 
static std::ostream & format_rec (std::ostream &os, const multi_ary_exprt &src)
 This formats a multi-ary expression, adding parentheses where indicated by bracket_subexpression. More...
 
static std::ostream & format_rec (std::ostream &os, const binary_exprt &src)
 This formats a binary expression, which we do as for multi-ary expressions. More...
 
static std::ostream & format_rec (std::ostream &os, const unary_exprt &src)
 This formats a unary expression, adding parentheses very aggressively. More...
 
static std::ostream & format_rec (std::ostream &os, const constant_exprt &src)
 This formats a constant. More...
 
std::ostream & fallback_format_rec (std::ostream &os, const exprt &expr)
 
std::ostream & format_rec (std::ostream &os, const exprt &expr)
 Formats an expression in a generic syntax that is inspired by C/C++/Java, and is meant for debugging. More...
 

Detailed Description

Expression Pretty Printing.

Definition in file format_expr.cpp.

Function Documentation

◆ bracket_subexpression()

static bool bracket_subexpression ( const exprt sub_expr,
const exprt expr 
)
static

We use the precendences that most readers expect (i.e., the ones you learn in primary school), and stay clear of the surprising ones that C has.

Definition at line 35 of file format_expr.cpp.

References exprt::has_operands(), and irept::id().

Referenced by format_rec().

◆ fallback_format_rec()

std::ostream& fallback_format_rec ( std::ostream &  os,
const exprt expr 
)

◆ format_rec() [1/5]

static std::ostream& format_rec ( std::ostream &  os,
const multi_ary_exprt src 
)
static

This formats a multi-ary expression, adding parentheses where indicated by bracket_subexpression.

Definition at line 61 of file format_expr.cpp.

References bracket_subexpression(), format(), irept::id(), and exprt::operands().

Referenced by format_rec(), operator<<(), local_safe_pointerst::output(), and local_safe_pointerst::output_safe_dereferences().

◆ format_rec() [2/5]

static std::ostream& format_rec ( std::ostream &  os,
const binary_exprt src 
)
static

This formats a binary expression, which we do as for multi-ary expressions.

Definition at line 88 of file format_expr.cpp.

References format_rec(), and to_multi_ary_expr().

◆ format_rec() [3/5]

static std::ostream& format_rec ( std::ostream &  os,
const unary_exprt src 
)
static

This formats a unary expression, adding parentheses very aggressively.

Definition at line 95 of file format_expr.cpp.

References format(), exprt::has_operands(), irept::id(), exprt::op0(), and irept::pretty().

◆ format_rec() [4/5]

static std::ostream& format_rec ( std::ostream &  os,
const constant_exprt src 
)
static

◆ format_rec() [5/5]

std::ostream& format_rec ( std::ostream &  os,
const exprt expr 
)