OpenMW
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Attributes
Compiler::Parser Class Reference

Parser base class. More...

#include <parser.hpp>

List of all members.

Public Member Functions

 Parser (ErrorHandler &errorHandler, Context &context)
 constructor
virtual ~Parser ()
 destructor
virtual bool parseInt (int value, const TokenLoc &loc, Scanner &scanner)
virtual bool parseFloat (float value, const TokenLoc &loc, Scanner &scanner)
virtual bool parseName (const std::string &name, const TokenLoc &loc, Scanner &scanner)
virtual bool parseKeyword (int keyword, const TokenLoc &loc, Scanner &scanner)
virtual bool parseSpecial (int code, const TokenLoc &loc, Scanner &scanner)
virtual bool parseComment (const std::string &comment, const TokenLoc &loc, Scanner &scanner)
virtual void parseEOF (Scanner &scanner)
virtual void reset ()
 Reset parser to clean state.
void setOptional (bool optional)
void start ()
 Mark parser as non-empty (at least one token has been parser).
bool isEmpty () const
 Has anything been parsed?

Protected Member Functions

void reportSeriousError (const std::string &message, const TokenLoc &loc)
 Report the error and throw a exception.
void reportError (const std::string &message, const TokenLoc &loc)
 Report the error.
void reportWarning (const std::string &message, const TokenLoc &loc)
 Report the warning without throwing an exception.
void reportEOF ()
 Report an unexpected EOF condition.
ErrorHandlergetErrorHandler ()
 Return error handler.
ContextgetContext ()
 Return context.

Static Protected Member Functions

static std::string toLower (const std::string &name)

Private Attributes

ErrorHandlermErrorHandler
ContextmContext
bool mOptional
bool mEmpty

Detailed Description

Parser base class.

This class defines a callback-parser.


Constructor & Destructor Documentation

Compiler::Parser::Parser ( ErrorHandler errorHandler,
Context context 
)

constructor

destructor


Member Function Documentation

Return context.

Return error handler.

bool Compiler::Parser::isEmpty ( ) const

Has anything been parsed?

bool Compiler::Parser::parseComment ( const std::string &  comment,
const TokenLoc loc,
Scanner scanner 
) [virtual]

Handle comment token.

Returns:
fetch another token?
  • Default-implementation: ignored (and return true).

Reimplemented in CSVWorld::ScriptHighlighter.

void Compiler::Parser::parseEOF ( Scanner scanner) [virtual]

Handle EOF token.

  • Default-implementation: Report an error.

Reimplemented in CSVWorld::ScriptHighlighter, Compiler::FileParser, and Compiler::ScriptParser.

bool Compiler::Parser::parseFloat ( float  value,
const TokenLoc loc,
Scanner scanner 
) [virtual]

Handle a float token.

Returns:
fetch another token?
  • Default-implementation: Report an error.

Reimplemented in Compiler::ExprParser, Compiler::LineParser, CSVWorld::ScriptHighlighter, and Compiler::SkipParser.

bool Compiler::Parser::parseInt ( int  value,
const TokenLoc loc,
Scanner scanner 
) [virtual]

Handle an int token.

Returns:
fetch another token?
  • Default-implementation: Report an error.

Reimplemented in Compiler::ExprParser, Compiler::LineParser, CSVWorld::ScriptHighlighter, and Compiler::SkipParser.

bool Compiler::Parser::parseKeyword ( int  keyword,
const TokenLoc loc,
Scanner scanner 
) [virtual]

Handle a keyword token.

Returns:
fetch another token?
  • Default-implementation: Report an error.

Reimplemented in Compiler::ExprParser, Compiler::LineParser, Compiler::ControlParser, CSVWorld::ScriptHighlighter, Compiler::FileParser, Compiler::ScriptParser, and Compiler::SkipParser.

bool Compiler::Parser::parseName ( const std::string &  name,
const TokenLoc loc,
Scanner scanner 
) [virtual]

Handle a name token.

Returns:
fetch another token?
  • Default-implementation: Report an error.

Reimplemented in Compiler::ExprParser, Compiler::LineParser, Compiler::ControlParser, CSVWorld::ScriptHighlighter, Compiler::FileParser, Compiler::ScriptParser, Compiler::StringParser, and Compiler::SkipParser.

bool Compiler::Parser::parseSpecial ( int  code,
const TokenLoc loc,
Scanner scanner 
) [virtual]

Handle a special character token.

Returns:
fetch another token?
  • Default-implementation: Report an error.

Reimplemented in Compiler::ExprParser, Compiler::LineParser, Compiler::ControlParser, CSVWorld::ScriptHighlighter, Compiler::FileParser, Compiler::ScriptParser, Compiler::SkipParser, and Compiler::StringParser.

void Compiler::Parser::reportEOF ( ) [protected]

Report an unexpected EOF condition.

void Compiler::Parser::reportError ( const std::string &  message,
const TokenLoc loc 
) [protected]

Report the error.

void Compiler::Parser::reportSeriousError ( const std::string &  message,
const TokenLoc loc 
) [protected]

Report the error and throw a exception.

void Compiler::Parser::reportWarning ( const std::string &  message,
const TokenLoc loc 
) [protected]

Report the warning without throwing an exception.

void Compiler::Parser::reset ( ) [virtual]
void Compiler::Parser::setOptional ( bool  optional)

Optional mode: If nothign has been parsed yet and an unexpected token is delivered, stop parsing without raising an exception (after a reset the parser is in non-optional mode).

Mark parser as non-empty (at least one token has been parser).

std::string Compiler::Parser::toLower ( const std::string &  name) [static, protected]

Member Data Documentation

Reimplemented in CSVWorld::ScriptHighlighter.

bool Compiler::Parser::mEmpty [private]

Reimplemented in CSVWorld::ScriptHighlighter.


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