ROSE  0.9.10.103
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
Rose::BinaryAnalysis::SymbolicExprParser Class Reference

Description

Parses symbolic expressions from text.

Parses symbolic expressions using a simple LISP-like syntax, the same syntax used by the unparser. An expression can be a numeric constant with an optional negative sign, a hexadecimal bit vector, a numbered variable like "v123", a named variable, or an operator with arguments. Operators are expressed as an operator name and space-separated arguments; the operator and arguments are both inside the parentheses like in LISP. A width in bits can be appended to any constant, variable, or operator name and is a positive number inside square brackets. Inline comments are enclosed in angle brackets (less than and greater than signs) and can be nested. Backslashes are used to escape parentheses, square brackets, and angle brackets to remove their special meaning. The normal C/C++ backslash escapes are also understood.

Definition at line 26 of file BinarySymbolicExprParser.h.

#include <BinarySymbolicExprParser.h>

Classes

class  AtomExpansion
 Virtual base class for expanding atoms. More...
 
class  Expansion
 Virtual base class for atom and operator expansion. More...
 
class  OperatorExpansion
 Virtual base class for expanding operators. More...
 
class  RegisterSubstituter
 Expand register name to placeholder variables. More...
 
class  RegisterToValue
 Expand register names to register values. More...
 
class  SymbolicExprCmdlineParser
 Parse a symbolic expression from the command-line. More...
 
class  SyntaxError
 Syntax errors that are thrown. More...
 
class  TermPlaceholders
 Expand unrecognized terms to placholder variables. More...
 
class  Token
 Tokens generated by the lexical analysis. More...
 
class  TokenStream
 A stream of tokens. More...
 

Public Types

typedef std::vector< AtomExpansion::PtrAtomTable
 Ordered atom table. More...
 
typedef std::vector< OperatorExpansion::PtrOperatorTable
 Ordered operator table. More...
 

Public Member Functions

 SymbolicExprParser ()
 Default constructor. More...
 
 SymbolicExprParser (const SmtSolverPtr &solver)
 Parser using a specific SMT solver for simplifications. More...
 
SymbolicExpr::Ptr parse (const std::string &, const std::string &inputName="string")
 Create a symbolic expression by parsing a string. More...
 
SymbolicExpr::Ptr parse (std::istream &input, const std::string &filename, unsigned lineNumber=1, unsigned columnNumber=0)
 Create a symbolic expression by parsing a file. More...
 
SymbolicExpr::Ptr parse (TokenStream &)
 Create a symbolic expression by parsing a token stream. More...
 
void appendAtomExpansion (const AtomExpansion::Ptr &)
 Append a new functor for expanding atoms into symbolic expressions. More...
 
void appendOperatorExpansion (const OperatorExpansion::Ptr &)
 Append a new functor for expanding operators into symbolic expressions. More...
 
std::string docString () const
 Documentation string. More...
 
const AtomTableatomTable () const
 Return all atom expansion functors.
 
AtomTableatomTable ()
 Return all atom expansion functors.
 
const OperatorTableoperatorTable () const
 Return all operator expansion functors.
 
OperatorTableoperatorTable ()
 Return all operator expansion functors.
 
void defineRegisters (const InstructionSemantics2::BaseSemantics::RiscOperatorsPtr &)
 Add definitions for registers. More...
 
RegisterSubstituter::Ptr defineRegisters (const RegisterDictionary *)
 Add definitions for registers. More...
 

Static Public Member Functions

static SymbolicExprCmdlineParser::Ptr symbolicExprParser (SymbolicExpr::Ptr &storage)
 
static SymbolicExprCmdlineParser::Ptr symbolicExprParser (std::vector< SymbolicExpr::Ptr > &storage)
 
static SymbolicExprCmdlineParser::Ptr symbolicExprParser ()
 

Member Typedef Documentation

Ordered atom table.

Definition at line 349 of file BinarySymbolicExprParser.h.

Ordered operator table.

Definition at line 352 of file BinarySymbolicExprParser.h.

Constructor & Destructor Documentation

Rose::BinaryAnalysis::SymbolicExprParser::SymbolicExprParser ( )

Default constructor.

Rose::BinaryAnalysis::SymbolicExprParser::SymbolicExprParser ( const SmtSolverPtr solver)
explicit

Parser using a specific SMT solver for simplifications.

The solver may be null in which case ROSE's default simplifications are the only ones used.

Member Function Documentation

SymbolicExpr::Ptr Rose::BinaryAnalysis::SymbolicExprParser::parse ( const std::string &  ,
const std::string &  inputName = "string" 
)

Create a symbolic expression by parsing a string.

Parses an expression from a string. Throws a SyntaxError if problems are encountered, including when the string contains additional non-white-space following the expression.

SymbolicExpr::Ptr Rose::BinaryAnalysis::SymbolicExprParser::parse ( std::istream &  input,
const std::string &  filename,
unsigned  lineNumber = 1,
unsigned  columnNumber = 0 
)

Create a symbolic expression by parsing a file.

Parses the file and returns the first expression in the file. Throws a SyntaxError if problems are encountered.

SymbolicExpr::Ptr Rose::BinaryAnalysis::SymbolicExprParser::parse ( TokenStream )

Create a symbolic expression by parsing a token stream.

Parses the token stream and returns its first expression. Throws a SyntaxError if problems are encountered.

void Rose::BinaryAnalysis::SymbolicExprParser::appendAtomExpansion ( const AtomExpansion::Ptr )

Append a new functor for expanding atoms into symbolic expressions.

void Rose::BinaryAnalysis::SymbolicExprParser::appendOperatorExpansion ( const OperatorExpansion::Ptr )

Append a new functor for expanding operators into symbolic expressions.

std::string Rose::BinaryAnalysis::SymbolicExprParser::docString ( ) const

Documentation string.

Returns the documentation string for this parser. The documentation string is a a simple markup language that can be used by command-line parsers.

void Rose::BinaryAnalysis::SymbolicExprParser::defineRegisters ( const InstructionSemantics2::BaseSemantics::RiscOperatorsPtr )

Add definitions for registers.

If register definitions are specified, then whenever a register name appears as a token during parsing, it will be immediately replaced with the value of the register queried from the specified operator state. If a RiscOperators object is specified, then the replacement is the register's current value; if a register dictionary is specified, then the replacement is a new symbolic variable and an internal table is updated to associate the variable with a register name so that the register value can be substituted later.

RegisterSubstituter::Ptr Rose::BinaryAnalysis::SymbolicExprParser::defineRegisters ( const RegisterDictionary )

Add definitions for registers.

If register definitions are specified, then whenever a register name appears as a token during parsing, it will be immediately replaced with the value of the register queried from the specified operator state. If a RiscOperators object is specified, then the replacement is the register's current value; if a register dictionary is specified, then the replacement is a new symbolic variable and an internal table is updated to associate the variable with a register name so that the register value can be substituted later.


The documentation for this class was generated from the following file: