TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
google::protobuf::io::Tokenizer Class Reference

#include <tokenizer.h>

Classes

struct  Token
 

Public Types

enum  TokenType {
  TYPE_START, TYPE_END, TYPE_IDENTIFIER, TYPE_INTEGER,
  TYPE_FLOAT, TYPE_STRING, TYPE_SYMBOL
}
 
enum  CommentStyle { CPP_COMMENT_STYLE, SH_COMMENT_STYLE }
 

Public Member Functions

 Tokenizer (ZeroCopyInputStream *input, ErrorCollector *error_collector)
 
 ~Tokenizer ()
 
const Tokencurrent ()
 
const Tokenprevious ()
 
bool Next ()
 
bool NextWithComments (string *prev_trailing_comments, vector< string > *detached_comments, string *next_leading_comments)
 
void set_allow_f_after_float (bool value)
 
void set_comment_style (CommentStyle style)
 
void set_require_space_after_number (bool require)
 
void set_allow_multiline_strings (bool allow)
 

Static Public Member Functions

static double ParseFloat (const string &text)
 
static void ParseString (const string &text, string *output)
 
static void ParseStringAppend (const string &text, string *output)
 
static bool ParseInteger (const string &text, uint64 max_value, uint64 *output)
 
static bool IsIdentifier (const string &text)
 

Private Types

enum  NextCommentStatus { LINE_COMMENT, BLOCK_COMMENT, SLASH_NOT_COMMENT, NO_COMMENT }
 

Private Member Functions

 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS (Tokenizer)
 
void NextChar ()
 
void Refresh ()
 
void RecordTo (string *target)
 
void StopRecording ()
 
void StartToken ()
 
void EndToken ()
 
void AddError (const string &message)
 
void ConsumeString (char delimiter)
 
TokenType ConsumeNumber (bool started_with_zero, bool started_with_dot)
 
void ConsumeLineComment (string *content)
 
void ConsumeBlockComment (string *content)
 
NextCommentStatus TryConsumeCommentStart ()
 
template<typename CharacterClass >
bool LookingAt ()
 
template<typename CharacterClass >
bool TryConsumeOne ()
 
bool TryConsume (char c)
 
template<typename CharacterClass >
void ConsumeZeroOrMore ()
 
template<typename CharacterClass >
void ConsumeOneOrMore (const char *error)
 

Private Attributes

Token current_
 
Token previous_
 
ZeroCopyInputStreaminput_
 
ErrorCollectorerror_collector_
 
char current_char_
 
const char * buffer_
 
int buffer_size_
 
int buffer_pos_
 
bool read_error_
 
int line_
 
int column_
 
string * record_target_
 
int record_start_
 
bool allow_f_after_float_
 
CommentStyle comment_style_
 
bool require_space_after_number_
 
bool allow_multiline_strings_
 

Static Private Attributes

static const int kTabWidth = 8
 

Member Enumeration Documentation

Enumerator
CPP_COMMENT_STYLE 
SH_COMMENT_STYLE 
221  {
222  // Line comments begin with "//", block comments are delimited by "/*" and
223  // "*/".
225  // Line comments begin with "#". No way to write block comments.
227  };
Enumerator
LINE_COMMENT 
BLOCK_COMMENT 
SLASH_NOT_COMMENT 
NO_COMMENT 
332  {
333  // Started a line comment.
334  LINE_COMMENT,
335 
336  // Started a block comment.
338 
339  // Consumed a slash, then realized it wasn't a comment. current_ has
340  // been filled in with a slash token. The caller should return it.
342 
343  // We do not appear to be starting a comment here.
344  NO_COMMENT
345  };
Enumerator
TYPE_START 
TYPE_END 
TYPE_IDENTIFIER 
TYPE_INTEGER 
TYPE_FLOAT 
TYPE_STRING 
TYPE_SYMBOL 
91  {
92  TYPE_START, // Next() has not yet been called.
93  TYPE_END, // End of input reached. "text" is empty.
94 
95  TYPE_IDENTIFIER, // A sequence of letters, digits, and underscores, not
96  // starting with a digit. It is an error for a number
97  // to be followed by an identifier with no space in
98  // between.
99  TYPE_INTEGER, // A sequence of digits representing an integer. Normally
100  // the digits are decimal, but a prefix of "0x" indicates
101  // a hex number and a leading zero indicates octal, just
102  // like with C numeric literals. A leading negative sign
103  // is NOT included in the token; it's up to the parser to
104  // interpret the unary minus operator on its own.
105  TYPE_FLOAT, // A floating point literal, with a fractional part and/or
106  // an exponent. Always in decimal. Again, never
107  // negative.
108  TYPE_STRING, // A quoted sequence of escaped characters. Either single
109  // or double quotes can be used, but they must match.
110  // A string literal cannot cross a line break.
111  TYPE_SYMBOL, // Any other printable character, like '!' or '+'.
112  // Symbols are always a single character, so "!+$%" is
113  // four tokens.
114  };

Constructor & Destructor Documentation

google::protobuf::io::Tokenizer::Tokenizer ( ZeroCopyInputStream input,
ErrorCollector error_collector 
)
google::protobuf::io::Tokenizer::~Tokenizer ( )

Member Function Documentation

void google::protobuf::io::Tokenizer::AddError ( const string &  message)
inlineprivate
305  {
307  }
int line_
Definition: tokenizer.h:264
virtual void AddError(int line, int column, const string &message)=0
ErrorCollector * error_collector_
Definition: tokenizer.h:255
int column_
Definition: tokenizer.h:265

+ Here is the call graph for this function:

void google::protobuf::io::Tokenizer::ConsumeBlockComment ( string *  content)
private
void google::protobuf::io::Tokenizer::ConsumeLineComment ( string *  content)
private
TokenType google::protobuf::io::Tokenizer::ConsumeNumber ( bool  started_with_zero,
bool  started_with_dot 
)
private
template<typename CharacterClass >
void google::protobuf::io::Tokenizer::ConsumeOneOrMore ( const char *  error)
inlineprivate
void google::protobuf::io::Tokenizer::ConsumeString ( char  delimiter)
private
template<typename CharacterClass >
void google::protobuf::io::Tokenizer::ConsumeZeroOrMore ( )
inlineprivate
const Tokenizer::Token & Tokenizer::current ( )
inline
385  {
386  return current_;
387 }
Token current_
Definition: tokenizer.h:251
void google::protobuf::io::Tokenizer::EndToken ( )
inlineprivate
google::protobuf::io::Tokenizer::GOOGLE_DISALLOW_EVIL_CONSTRUCTORS ( Tokenizer  )
private
static bool google::protobuf::io::Tokenizer::IsIdentifier ( const string &  text)
static
template<typename CharacterClass >
bool google::protobuf::io::Tokenizer::LookingAt ( )
inlineprivate
bool google::protobuf::io::Tokenizer::Next ( )
void google::protobuf::io::Tokenizer::NextChar ( )
private
bool google::protobuf::io::Tokenizer::NextWithComments ( string *  prev_trailing_comments,
vector< string > *  detached_comments,
string *  next_leading_comments 
)
static double google::protobuf::io::Tokenizer::ParseFloat ( const string &  text)
static
static bool google::protobuf::io::Tokenizer::ParseInteger ( const string &  text,
uint64  max_value,
uint64 output 
)
static
void Tokenizer::ParseString ( const string &  text,
string *  output 
)
inlinestatic
393  {
394  output->clear();
395  ParseStringAppend(text, output);
396 }
#define output
Definition: wire_format_lite.h:381
static void ParseStringAppend(const string &text, string *output)

+ Here is the call graph for this function:

static void google::protobuf::io::Tokenizer::ParseStringAppend ( const string &  text,
string *  output 
)
static

+ Here is the caller graph for this function:

const Tokenizer::Token & Tokenizer::previous ( )
inline
389  {
390  return previous_;
391 }
Token previous_
Definition: tokenizer.h:252
void google::protobuf::io::Tokenizer::RecordTo ( string *  target)
inlineprivate
void google::protobuf::io::Tokenizer::Refresh ( )
private
void google::protobuf::io::Tokenizer::set_allow_f_after_float ( bool  value)
inline
bool allow_f_after_float_
Definition: tokenizer.h:275
const FieldDescriptor value
Definition: descriptor.h:1522
void google::protobuf::io::Tokenizer::set_allow_multiline_strings ( bool  allow)
inline
240  {
241  allow_multiline_strings_ = allow;
242  }
bool allow_multiline_strings_
Definition: tokenizer.h:278
void google::protobuf::io::Tokenizer::set_comment_style ( CommentStyle  style)
inline
230 { comment_style_ = style; }
CommentStyle comment_style_
Definition: tokenizer.h:276
void google::protobuf::io::Tokenizer::set_require_space_after_number ( bool  require)
inline
234  {
235  require_space_after_number_ = require;
236  }
bool require_space_after_number_
Definition: tokenizer.h:277
void google::protobuf::io::Tokenizer::StartToken ( )
inlineprivate
void google::protobuf::io::Tokenizer::StopRecording ( )
inlineprivate
bool google::protobuf::io::Tokenizer::TryConsume ( char  c)
inlineprivate
NextCommentStatus google::protobuf::io::Tokenizer::TryConsumeCommentStart ( )
private
template<typename CharacterClass >
bool google::protobuf::io::Tokenizer::TryConsumeOne ( )
inlineprivate

Member Data Documentation

bool google::protobuf::io::Tokenizer::allow_f_after_float_
private
bool google::protobuf::io::Tokenizer::allow_multiline_strings_
private
const char* google::protobuf::io::Tokenizer::buffer_
private
int google::protobuf::io::Tokenizer::buffer_pos_
private
int google::protobuf::io::Tokenizer::buffer_size_
private
int google::protobuf::io::Tokenizer::column_
private
CommentStyle google::protobuf::io::Tokenizer::comment_style_
private
Token google::protobuf::io::Tokenizer::current_
private
char google::protobuf::io::Tokenizer::current_char_
private
ErrorCollector* google::protobuf::io::Tokenizer::error_collector_
private
ZeroCopyInputStream* google::protobuf::io::Tokenizer::input_
private
const int google::protobuf::io::Tokenizer::kTabWidth = 8
staticprivate
int google::protobuf::io::Tokenizer::line_
private
Token google::protobuf::io::Tokenizer::previous_
private
bool google::protobuf::io::Tokenizer::read_error_
private
int google::protobuf::io::Tokenizer::record_start_
private
string* google::protobuf::io::Tokenizer::record_target_
private
bool google::protobuf::io::Tokenizer::require_space_after_number_
private

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