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

#include <exprparser.hpp>

Inheritance diagram for Compiler::ExprParser:
Collaboration diagram for Compiler::ExprParser:

Public Member Functions

 ExprParser (ErrorHandler &errorHandler, const Context &context, Locals &locals, Literals &literals, bool argument=false)
 
char getType () const
 Return type of parsed expression ('l' integer, 'f' float) 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)
 
void reset ()
 Reset parser to clean state. More...
 
char append (std::vector< Interpreter::Type_Code > &code)
 
int parseArguments (const std::string &arguments, Scanner &scanner, std::vector< Interpreter::Type_Code > &code, int ignoreKeyword=-1)
 
const TokenLocgetTokenLoc () const
 
- Public Member Functions inherited from Compiler::Parser
 Parser (ErrorHandler &errorHandler, const Context &context)
 constructor More...
 
virtual ~Parser ()
 destructor More...
 
virtual bool parseComment (const std::string &comment, const TokenLoc &loc, Scanner &scanner)
 
virtual void parseEOF (Scanner &scanner)
 
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...
 

Private Member Functions

int getPriority (char op) const
 
char getOperandType (int Index=0) const
 
char getOperator () const
 
bool isOpen () const
 
void popOperator ()
 
void popOperand ()
 
void replaceBinaryOperands ()
 
void pop ()
 
void pushIntegerLiteral (int value)
 
void pushFloatLiteral (float value)
 
void pushBinaryOperator (char c)
 
void close ()
 
int parseArguments (const std::string &arguments, Scanner &scanner)
 
bool handleMemberAccess (const std::string &name)
 

Private Attributes

LocalsmLocals
 
LiteralsmLiterals
 
std::vector< char > mOperands
 
std::vector< char > mOperators
 
bool mNextOperand
 
TokenLoc mTokenLoc
 
std::vector
< Interpreter::Type_Code
mCode
 
bool mFirst
 
bool mArgument
 
std::string mExplicit
 
bool mRefOp
 
bool mMemberOp
 

Additional Inherited Members

- Protected Member Functions inherited from Compiler::Parser
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 inherited from Compiler::Parser
static std::string toLower (const std::string &name)
 

Constructor & Destructor Documentation

Compiler::ExprParser::ExprParser ( ErrorHandler errorHandler,
const Context context,
Locals locals,
Literals literals,
bool  argument = false 
)

constructor

Parameters
argumentParser is used to parse function- or instruction- arguments (this influences the precedence rules).

Member Function Documentation

char Compiler::ExprParser::append ( std::vector< Interpreter::Type_Code > &  code)

Generate code for parsed expression.

Returns
Type ('l': integer, 'f': float)

Here is the call graph for this function:

Here is the caller graph for this function:

void Compiler::ExprParser::close ( )
private

Here is the call graph for this function:

Here is the caller graph for this function:

char Compiler::ExprParser::getOperandType ( int  Index = 0) const
private

Here is the caller graph for this function:

char Compiler::ExprParser::getOperator ( ) const
private

Here is the caller graph for this function:

int Compiler::ExprParser::getPriority ( char  op) const
private

Here is the caller graph for this function:

const TokenLoc & Compiler::ExprParser::getTokenLoc ( ) const

Here is the caller graph for this function:

char Compiler::ExprParser::getType ( ) const

Return type of parsed expression ('l' integer, 'f' float)

bool Compiler::ExprParser::handleMemberAccess ( const std::string &  name)
private

Here is the call graph for this function:

Here is the caller graph for this function:

bool Compiler::ExprParser::isOpen ( ) const
private

Here is the caller graph for this function:

int Compiler::ExprParser::parseArguments ( const std::string &  arguments,
Scanner scanner 
)
private

Here is the caller graph for this function:

int Compiler::ExprParser::parseArguments ( const std::string &  arguments,
Scanner scanner,
std::vector< Interpreter::Type_Code > &  code,
int  ignoreKeyword = -1 
)

Parse sequence of arguments specified by arguments.

Parameters
argumentsUses ScriptArgs typedef
See Also
Compiler::ScriptArgs
Parameters
invertStore arguments in reverted order.
ignoreKeywordA keyword that is seen as junk
Returns
number of optional arguments
Todo:
disable this when operating in strict mode

Here is the call graph for this function:

bool Compiler::ExprParser::parseFloat ( float  value,
const TokenLoc loc,
Scanner scanner 
)
virtual

Handle a float token.

Returns
fetch another token?

Reimplemented from Compiler::Parser.

Here is the call graph for this function:

bool Compiler::ExprParser::parseInt ( int  value,
const TokenLoc loc,
Scanner scanner 
)
virtual

Handle an int token.

Returns
fetch another token?

Reimplemented from Compiler::Parser.

Here is the call graph for this function:

bool Compiler::ExprParser::parseKeyword ( int  keyword,
const TokenLoc loc,
Scanner scanner 
)
virtual

Handle a keyword token.

Returns
fetch another token?

Reimplemented from Compiler::Parser.

Here is the call graph for this function:

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

Handle a name token.

Returns
fetch another token?

Reimplemented from Compiler::Parser.

Here is the call graph for this function:

Here is the caller graph for this function:

bool Compiler::ExprParser::parseSpecial ( int  code,
const TokenLoc loc,
Scanner scanner 
)
virtual

Handle a special character token.

Returns
fetch another token?
Todo:
add option to disable this workaround

Reimplemented from Compiler::Parser.

Here is the call graph for this function:

Here is the caller graph for this function:

void Compiler::ExprParser::pop ( )
private

Here is the call graph for this function:

Here is the caller graph for this function:

void Compiler::ExprParser::popOperand ( )
private

Here is the caller graph for this function:

void Compiler::ExprParser::popOperator ( )
private

Here is the caller graph for this function:

void Compiler::ExprParser::pushBinaryOperator ( char  c)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void Compiler::ExprParser::pushFloatLiteral ( float  value)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void Compiler::ExprParser::pushIntegerLiteral ( int  value)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void Compiler::ExprParser::replaceBinaryOperands ( )
private

Here is the call graph for this function:

Here is the caller graph for this function:

void Compiler::ExprParser::reset ( )
virtual

Reset parser to clean state.

Reimplemented from Compiler::Parser.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

bool Compiler::ExprParser::mArgument
private
std::vector<Interpreter::Type_Code> Compiler::ExprParser::mCode
private
std::string Compiler::ExprParser::mExplicit
private
bool Compiler::ExprParser::mFirst
private
Literals& Compiler::ExprParser::mLiterals
private
Locals& Compiler::ExprParser::mLocals
private
bool Compiler::ExprParser::mMemberOp
private
bool Compiler::ExprParser::mNextOperand
private
std::vector<char> Compiler::ExprParser::mOperands
private
std::vector<char> Compiler::ExprParser::mOperators
private
bool Compiler::ExprParser::mRefOp
private
TokenLoc Compiler::ExprParser::mTokenLoc
private

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