ROSE  0.9.9.168
Public Member Functions | List of all members
Rose::BinaryAnalysis::SymbolicExprParser::TokenStream Class Reference

Description

A stream of tokens.

This container is conceptually infinite size padded with EOF tokens, although in practice it usually holds only one or two tokens at a time. Tokens are consumed by shifting them off the beginning of the stream.

Definition at line 112 of file BinarySymbolicExprParser.h.

#include <BinarySymbolicExprParser.h>

Public Member Functions

 TokenStream (std::istream &input, const std::string &name="input", unsigned lineNumber=1, unsigned columnNumber=0)
 Scan tokens from a character stream. More...
 
const std::string & name () const
 Name of this input stream. More...
 
unsigned lineNumber () const
 Current line number. More...
 
unsigned columnNumber () const
 Current column number. More...
 
const Tokenoperator[] (size_t idx)
 Returns the specified token without consuming it. More...
 
void shift (size_t n=1)
 Consume the specified number of tokens. More...
 
int nextCharacter ()
 Returns the next character. More...
 
int consumeCharacter ()
 Consume the next character. More...
 
void consumeWhiteSpace ()
 Skip over characters until a non-white-space character is encountered. More...
 
int consumeEscapeSequence ()
 Skip over an escape sequence and return the escaped character. More...
 
void consumeInlineComment ()
 Skip over angle-bracket comments. More...
 
void consumeWhiteSpaceAndComments ()
 Skip over white space and/or inline comments. More...
 
std::string consumeTerm ()
 Parse and consume a term. More...
 
size_t consumeWidth ()
 Parse and consume a width specification. More...
 
size_t consumeWidth (size_t &width2)
 Parse and consume a memory width specification. More...
 
Token scan ()
 Parse and consume the next token. More...
 

Constructor & Destructor Documentation

Rose::BinaryAnalysis::SymbolicExprParser::TokenStream::TokenStream ( std::istream &  input,
const std::string &  name = "input",
unsigned  lineNumber = 1,
unsigned  columnNumber = 0 
)
inlineexplicit

Scan tokens from a character stream.

The name parameter is the name to use for this stream in error messages (usually a file name), and the lineNumber and columnNumber are the position of the first character in the stream.

Definition at line 125 of file BinarySymbolicExprParser.h.

Member Function Documentation

const std::string& Rose::BinaryAnalysis::SymbolicExprParser::TokenStream::name ( ) const
inline

Name of this input stream.

Definition at line 132 of file BinarySymbolicExprParser.h.

unsigned Rose::BinaryAnalysis::SymbolicExprParser::TokenStream::lineNumber ( ) const
inline

Current line number.

Definition at line 135 of file BinarySymbolicExprParser.h.

unsigned Rose::BinaryAnalysis::SymbolicExprParser::TokenStream::columnNumber ( ) const
inline

Current column number.

Definition at line 138 of file BinarySymbolicExprParser.h.

const Token& Rose::BinaryAnalysis::SymbolicExprParser::TokenStream::operator[] ( size_t  idx)

Returns the specified token without consuming it.

void Rose::BinaryAnalysis::SymbolicExprParser::TokenStream::shift ( size_t  n = 1)

Consume the specified number of tokens.

int Rose::BinaryAnalysis::SymbolicExprParser::TokenStream::nextCharacter ( )

Returns the next character.

Returns the next character of input or EOF without consuming it.

int Rose::BinaryAnalysis::SymbolicExprParser::TokenStream::consumeCharacter ( )

Consume the next character.

Advances over the next character, adjusting line and column information. Returns the character consumed, or EOF.

void Rose::BinaryAnalysis::SymbolicExprParser::TokenStream::consumeWhiteSpace ( )

Skip over characters until a non-white-space character is encountered.

int Rose::BinaryAnalysis::SymbolicExprParser::TokenStream::consumeEscapeSequence ( )

Skip over an escape sequence and return the escaped character.

void Rose::BinaryAnalysis::SymbolicExprParser::TokenStream::consumeInlineComment ( )

Skip over angle-bracket comments.

Consumes angle bracket comments like "<this is a comment>". Any right angle brackets that are part of the comment must be escaped. Unescaped angle brackets can be nested like parentheses.

void Rose::BinaryAnalysis::SymbolicExprParser::TokenStream::consumeWhiteSpaceAndComments ( )

Skip over white space and/or inline comments.

std::string Rose::BinaryAnalysis::SymbolicExprParser::TokenStream::consumeTerm ( )

Parse and consume a term.

A term is a numeric constant or a symbol. Symbols that start with a letter or underscore contain only letters, underscores, and decimal digits. Symbols that start with other than a letter or underscore end at the first unescaped white-space, comment, parenthesis, angle bracket, or square bracket. Escaping the special character with a backslash will cause it to become part of the symbol.

size_t Rose::BinaryAnalysis::SymbolicExprParser::TokenStream::consumeWidth ( )

Parse and consume a width specification.

A width specification is a decimal number in square brackets.

size_t Rose::BinaryAnalysis::SymbolicExprParser::TokenStream::consumeWidth ( size_t &  width2)

Parse and consume a memory width specification.

A memory with specification is enclosed in square brackets and consists of a domain (address) width, followed by an arrow ("->"), followed by a range (value) width.

Token Rose::BinaryAnalysis::SymbolicExprParser::TokenStream::scan ( )

Parse and consume the next token.

Parses and consumes the next token and return it. Returns the special NONE token at end-of-input.


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