Lexer Class Reference

This is the abstract base class for all json lexers. More...

#include <lexer.h>

Inheritance diagram for Lexer:

BeUtf32Lexer LeUtf32Lexer Utf16Lexer Utf8Lexer BeUtf16Lexer LeUtf16Lexer List of all members.

Public Member Functions

 Lexer (const std::string &input)
 Construct a lexer with the string of bytes to be parsed.
virtual ~Lexer ()
 Destructor is declared virtual, as it always should be.
virtual int Lex (YYSTYPE *lvalp)
 Continue parsing of the input string.

Protected Member Functions

virtual unsigned int GetChar ()=0
 Gets the next unicode character from the input.
virtual UstrGetString ()
 Gets a string from the input.
virtual Ustr GetNumber ()
 Reads and consumes the next continuous string of digits.
virtual unsigned int LookAhead ()
 Returns the next unicode character, but does not consume it.
virtual unsigned int GetHexValue ()
 Gets a 4-hex-value unicode character value from the input.

Protected Attributes

std::string m_Input
 The input bytes as they were received.
unsigned int m_Pos
 The current position while reading the input.

Detailed Description

This is the abstract base class for all json lexers.

Author:
Matthew Welch


Constructor & Destructor Documentation

Lexer::Lexer ( const std::string &  input  )  [inline]

Construct a lexer with the string of bytes to be parsed.

Parameters:
input The string of input bytes to be parsed.

virtual Lexer::~Lexer (  )  [inline, virtual]

Destructor is declared virtual, as it always should be.


Member Function Documentation

virtual int Lexer::Lex ( YYSTYPE *  lvalp  )  [virtual]

Continue parsing of the input string.

Parameters:
lvalp This is used to return the value found in the input.
Returns:
Value representing the type of token found.

virtual unsigned int Lexer::GetChar (  )  [protected, pure virtual]

Gets the next unicode character from the input.

Returns:
Unicode value as unsigned int.

Implemented in Utf8Lexer, Utf16Lexer, BeUtf32Lexer, and LeUtf32Lexer.

virtual Ustr* Lexer::GetString (  )  [protected, virtual]

Gets a string from the input.

This function assumes that the opening " has already been consumed. It will consume the closing " but not return it, returning only the contents of the string as UTF8.

Returns:
The contents of the string in UTF8.

virtual Ustr Lexer::GetNumber (  )  [protected, virtual]

Reads and consumes the next continuous string of digits.

Returns:
String containing the digits read.

virtual unsigned int Lexer::LookAhead (  )  [protected, virtual]

Returns the next unicode character, but does not consume it.

Returns:
Next unicode character as an unsigned int.

virtual unsigned int Lexer::GetHexValue (  )  [protected, virtual]

Gets a 4-hex-value unicode character value from the input.

Returns:
Unicode character value as an unsigned int.


Member Data Documentation

std::string Lexer::m_Input [protected]

The input bytes as they were received.

unsigned int Lexer::m_Pos [protected]

The current position while reading the input.


The documentation for this class was generated from the following file:
Generated on Wed Apr 18 15:50:12 2007 for JSON Parser by  doxygen 1.5.2