ROSE 0.11.145.192
Public Member Functions | List of all members
Rose::BinaryAnalysis::SymbolicExpressionParser::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 125 of file SymbolicExpressionParser.h.

#include <Rose/BinaryAnalysis/SymbolicExpressionParser.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.
 
const std::string & name () const
 Name of this input stream.
 
unsigned lineNumber () const
 Current line number.
 
unsigned columnNumber () const
 Current column number.
 
const Tokenoperator[] (size_t idx)
 Returns the specified token without consuming it.
 
void shift (size_t n=1)
 Consume the specified number of tokens.
 
int nextCharacter ()
 Returns the next character.
 
int consumeCharacter ()
 Consume the next character.
 
void consumeWhiteSpace ()
 Skip over characters until a non-white-space character is encountered.
 
int consumeEscapeSequence ()
 Skip over an escape sequence and return the escaped character.
 
void consumeInlineComment ()
 Skip over angle-bracket comments.
 
void consumeWhiteSpaceAndComments ()
 Skip over white space and/or inline comments.
 
std::string consumeTerm ()
 Parse and consume a term.
 
SymbolicExpression::Type consumeType ()
 Parse and consume a type specification.
 
Token scan ()
 Parse and consume the next token.
 

Constructor & Destructor Documentation

◆ TokenStream()

Rose::BinaryAnalysis::SymbolicExpressionParser::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 138 of file SymbolicExpressionParser.h.

Member Function Documentation

◆ name()

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

Name of this input stream.

Definition at line 145 of file SymbolicExpressionParser.h.

◆ lineNumber()

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

Current line number.

Definition at line 148 of file SymbolicExpressionParser.h.

◆ columnNumber()

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

Current column number.

Definition at line 151 of file SymbolicExpressionParser.h.

◆ nextCharacter()

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

Returns the next character.

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

◆ consumeCharacter()

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

Consume the next character.

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

◆ consumeInlineComment()

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

◆ consumeTerm()

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

◆ consumeType()

SymbolicExpression::Type Rose::BinaryAnalysis::SymbolicExpressionParser::TokenStream::consumeType ( )

Parse and consume a type specification.

A type specification is a type name in square brackets. If the square brackets contain only an integer then the type is an integer type with the specified width.

◆ scan()

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