ROSE 0.11.145.147
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Rose::BinaryAnalysis::SymbolicExpressionParser 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 31 of file SymbolicExpressionParser.h.

#include <Rose/BinaryAnalysis/SymbolicExpressionParser.h>

Collaboration diagram for Rose::BinaryAnalysis::SymbolicExpressionParser:
Collaboration graph
[legend]

Classes

class  AtomExpansion
 Virtual base class for expanding atoms. More...
 
class  Expansion
 Virtual base class for atom and operator expansion. More...
 
class  MemorySubstituter
 Expand "memory" function to placeholder. 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  SubstitutionError
 Substitution error during expansion. 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.
 
typedef std::vector< OperatorExpansion::PtrOperatorTable
 Ordered operator table.
 

Public Member Functions

 SymbolicExpressionParser ()
 Default constructor.
 
 SymbolicExpressionParser (const SmtSolverPtr &solver)
 Parser using a specific SMT solver for simplifications.
 
SymbolicExpression::Ptr parse (const std::string &, const std::string &inputName="string")
 Create a symbolic expression by parsing a string.
 
SymbolicExpression::Ptr parse (std::istream &input, const std::string &filename, unsigned lineNumber=1, unsigned columnNumber=0)
 Create a symbolic expression by parsing a file.
 
SymbolicExpression::Ptr parse (TokenStream &)
 Create a symbolic expression by parsing a token stream.
 
void appendAtomExpansion (const AtomExpansion::Ptr &)
 Append a new functor for expanding atoms into symbolic expressions.
 
void appendOperatorExpansion (const OperatorExpansion::Ptr &)
 Append a new functor for expanding operators into symbolic expressions.
 
std::string docString () const
 Documentation string.
 
SymbolicExpression::Ptr delayedExpansion (const SymbolicExpression::Ptr &) const
 Perform delayed expansion.
 
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 InstructionSemantics::BaseSemantics::RiscOperatorsPtr &)
 Add definitions for registers.
 
RegisterSubstituter::Ptr defineRegisters (const RegisterDictionaryPtr &)
 Add definitions for registers.
 

Static Public Member Functions

static SymbolicExprCmdlineParser::Ptr symbolicExprParser (SymbolicExpression::Ptr &storage)
 
static SymbolicExprCmdlineParser::Ptr symbolicExprParser (std::vector< SymbolicExpression::Ptr > &storage)
 
static SymbolicExprCmdlineParser::Ptr symbolicExprParser ()
 
static void initDiagnostics ()
 

Static Public Attributes

static Sawyer::Message::Facility mlog
 

Member Typedef Documentation

◆ AtomTable

Ordered atom table.

Definition at line 262 of file SymbolicExpressionParser.h.

◆ OperatorTable

Ordered operator table.

Definition at line 286 of file SymbolicExpressionParser.h.

Constructor & Destructor Documentation

◆ SymbolicExpressionParser()

Rose::BinaryAnalysis::SymbolicExpressionParser::SymbolicExpressionParser ( 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

◆ parse() [1/3]

SymbolicExpression::Ptr Rose::BinaryAnalysis::SymbolicExpressionParser::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.

◆ parse() [2/3]

SymbolicExpression::Ptr Rose::BinaryAnalysis::SymbolicExpressionParser::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.

◆ parse() [3/3]

SymbolicExpression::Ptr Rose::BinaryAnalysis::SymbolicExpressionParser::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.

◆ atomTable() [1/2]

const AtomTable & Rose::BinaryAnalysis::SymbolicExpressionParser::atomTable ( ) const
inline

Return all atom expansion functors.

Definition at line 521 of file SymbolicExpressionParser.h.

◆ atomTable() [2/2]

AtomTable & Rose::BinaryAnalysis::SymbolicExpressionParser::atomTable ( )
inline

Return all atom expansion functors.

Definition at line 522 of file SymbolicExpressionParser.h.

◆ operatorTable() [1/2]

const OperatorTable & Rose::BinaryAnalysis::SymbolicExpressionParser::operatorTable ( ) const
inline

Return all operator expansion functors.

Definition at line 528 of file SymbolicExpressionParser.h.

◆ operatorTable() [2/2]

OperatorTable & Rose::BinaryAnalysis::SymbolicExpressionParser::operatorTable ( )
inline

Return all operator expansion functors.

Definition at line 529 of file SymbolicExpressionParser.h.

◆ docString()

std::string Rose::BinaryAnalysis::SymbolicExpressionParser::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.

◆ defineRegisters() [1/2]

void Rose::BinaryAnalysis::SymbolicExpressionParser::defineRegisters ( const InstructionSemantics::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.

◆ defineRegisters() [2/2]

RegisterSubstituter::Ptr Rose::BinaryAnalysis::SymbolicExpressionParser::defineRegisters ( const RegisterDictionaryPtr )

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.

◆ delayedExpansion()

SymbolicExpression::Ptr Rose::BinaryAnalysis::SymbolicExpressionParser::delayedExpansion ( const SymbolicExpression::Ptr ) const

Perform delayed expansion.

This runs the delayedExpansion method for each of the registerd expansion functors.

Member Data Documentation

◆ mlog

Sawyer::Message::Facility Rose::BinaryAnalysis::SymbolicExpressionParser::mlog
static

Definition at line 479 of file SymbolicExpressionParser.h.


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