OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Attributes | List of all members
Compiler::Parser Class Reference

Parser base class. More...

#include <parser.hpp>

Inheritance diagram for Compiler::Parser:
Collaboration diagram for Compiler::Parser:

Public Member Functions

 Parser (ErrorHandler &errorHandler, const Context &context)
 constructor More...
 
virtual ~Parser ()
 destructor More...
 
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. More...
 
void setOptional (bool optional)
 
void start ()
 Mark parser as non-empty (at least one token has been parser). More...
 
bool isEmpty () const
 Has anything been parsed? More...
 

Protected Member Functions

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

Static Protected Member Functions

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

Private Attributes

ErrorHandlermErrorHandler
 
const ContextmContext
 
bool mOptional
 
bool mEmpty
 

Detailed Description

Parser base class.

This class defines a callback-parser.

Constructor & Destructor Documentation

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

constructor

Compiler::Parser::~Parser ( )
virtual

destructor

Member Function Documentation

const Context & Compiler::Parser::getContext ( ) const
protected

Return context.

Here is the caller graph for this function:

ErrorHandler & Compiler::Parser::getErrorHandler ( )
protected

Return error handler.

Here is the caller graph for this function:

bool Compiler::Parser::isEmpty ( ) const

Has anything been parsed?

Here is the caller graph for this function:

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.

Here is the caller graph for this function:

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

Handle EOF token.

  • Default-implementation: Report an error.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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, CSVWorld::ScriptHighlighter, Compiler::LineParser, Compiler::DiscardParser, Compiler::JunkParser, and Compiler::SkipParser.

Here is the call graph for this function:

Here is the caller graph for this function:

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, CSVWorld::ScriptHighlighter, Compiler::LineParser, Compiler::DiscardParser, Compiler::JunkParser, and Compiler::SkipParser.

Here is the call graph for this function:

Here is the caller graph for this function:

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, CSVWorld::ScriptHighlighter, Compiler::LineParser, Compiler::ControlParser, Compiler::FileParser, Compiler::StringParser, Compiler::ScriptParser, Compiler::JunkParser, Compiler::SkipParser, Compiler::DeclarationParser, and Compiler::QuickFileParser.

Here is the call graph for this function:

Here is the caller graph for this function:

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, CSVWorld::ScriptHighlighter, Compiler::LineParser, Compiler::ControlParser, Compiler::FileParser, Compiler::StringParser, Compiler::DiscardParser, Compiler::ScriptParser, Compiler::JunkParser, Compiler::SkipParser, Compiler::DeclarationParser, and Compiler::QuickFileParser.

Here is the call graph for this function:

Here is the caller graph for this function:

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, CSVWorld::ScriptHighlighter, Compiler::LineParser, Compiler::ControlParser, Compiler::FileParser, Compiler::StringParser, Compiler::ScriptParser, Compiler::DiscardParser, Compiler::JunkParser, Compiler::SkipParser, Compiler::DeclarationParser, and Compiler::QuickFileParser.

Here is the call graph for this function:

Here is the caller graph for this function:

void Compiler::Parser::reportEOF ( )
protected

Report an unexpected EOF condition.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Report the error and throw a exception.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Report the warning without throwing an exception.

Here is the call graph for this function:

Here is the caller graph for this function:

void Compiler::Parser::reset ( )
virtual

Reset parser to clean state.

Reimplemented in Compiler::ExprParser, Compiler::LineParser, Compiler::ControlParser, Compiler::FileParser, Compiler::StringParser, Compiler::ScriptParser, Compiler::DiscardParser, and Compiler::DeclarationParser.

Here is the caller graph for this function:

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).

Here is the caller graph for this function:

void Compiler::Parser::start ( )

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

Here is the caller graph for this function:

std::string Compiler::Parser::toLower ( const std::string &  name)
staticprotected

Here is the call graph for this function:

Member Data Documentation

const Context& Compiler::Parser::mContext
private
bool Compiler::Parser::mEmpty
private
ErrorHandler& Compiler::Parser::mErrorHandler
private
bool Compiler::Parser::mOptional
private

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