ROSE 0.11.145.147
|
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>
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::Ptr > | AtomTable |
Ordered atom table. | |
typedef std::vector< OperatorExpansion::Ptr > | OperatorTable |
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 AtomTable & | atomTable () const |
Return all atom expansion functors. | |
AtomTable & | atomTable () |
Return all atom expansion functors. | |
const OperatorTable & | operatorTable () const |
Return all operator expansion functors. | |
OperatorTable & | operatorTable () |
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 |
typedef std::vector<AtomExpansion::Ptr> Rose::BinaryAnalysis::SymbolicExpressionParser::AtomTable |
Ordered atom table.
Definition at line 262 of file SymbolicExpressionParser.h.
typedef std::vector<OperatorExpansion::Ptr> Rose::BinaryAnalysis::SymbolicExpressionParser::OperatorTable |
Ordered operator table.
Definition at line 286 of file SymbolicExpressionParser.h.
|
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.
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.
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.
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.
|
inline |
Return all atom expansion functors.
Definition at line 521 of file SymbolicExpressionParser.h.
|
inline |
Return all atom expansion functors.
Definition at line 522 of file SymbolicExpressionParser.h.
|
inline |
Return all operator expansion functors.
Definition at line 528 of file SymbolicExpressionParser.h.
|
inline |
Return all operator expansion functors.
Definition at line 529 of file SymbolicExpressionParser.h.
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.
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.
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.
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.
|
static |
Definition at line 479 of file SymbolicExpressionParser.h.