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

Scanner. More...

#include <scanner.hpp>

Collaboration diagram for Compiler::Scanner:

Public Types

enum  keyword {
  K_begin, K_end, K_short, K_long,
  K_float, K_if, K_endif, K_else,
  K_elseif, K_while, K_endwhile, K_return,
  K_messagebox, K_set, K_to, K_getsquareroot,
  K_menumode, K_random, K_startscript, K_stopscript,
  K_scriptrunning, K_getdistance, K_getsecondspassed, K_enable,
  K_disable, K_getdisabled
}
 
enum  special {
  S_newline, S_open, S_close, S_cmpEQ,
  S_cmpNE, S_cmpLT, S_cmpLE, S_cmpGT,
  S_cmpGE, S_plus, S_minus, S_mult,
  S_div, S_comma, S_ref, S_member
}
 

Public Member Functions

 Scanner (ErrorHandler &errorHandler, std::istream &inputStream, const Extensions *extensions=0)
 constructor More...
 
void scan (Parser &parser)
 Scan a token and deliver it to the parser. More...
 
void putbackSpecial (int code, const TokenLoc &loc)
 put back a special token More...
 
void putbackInt (int value, const TokenLoc &loc)
 put back an integer token More...
 
void putbackFloat (float value, const TokenLoc &loc)
 put back a float token More...
 
void putbackName (const std::string &name, const TokenLoc &loc)
 put back a name token More...
 
void putbackKeyword (int keyword, const TokenLoc &loc)
 put back a keyword token More...
 
void listKeywords (std::vector< std::string > &keywords)
 Append all known keywords to keywords. More...
 
void enableIgnoreNewlines ()
 
void enableStrictKeywords ()
 
void enableTolerantNames ()
 

Private Types

enum  putback_type {
  Putback_None, Putback_Special, Putback_Integer, Putback_Float,
  Putback_Name, Putback_Keyword
}
 

Private Member Functions

 Scanner (const Scanner &)
 
Scanneroperator= (const Scanner &)
 
bool get (char &c)
 
void putback (char c)
 
bool scanToken (Parser &parser)
 
bool scanInt (char c, Parser &parser, bool &cont)
 
bool scanFloat (const std::string &intValue, Parser &parser, bool &cont)
 
bool scanName (char c, Parser &parser, bool &cont)
 
bool scanName (std::string &name)
 
bool scanSpecial (char c, Parser &parser, bool &cont)
 
bool isStringCharacter (char c, bool lookAhead=true)
 

Static Private Member Functions

static bool isWhitespace (char c)
 

Private Attributes

ErrorHandlermErrorHandler
 
TokenLoc mLoc
 
TokenLoc mPrevLoc
 
std::istream & mStream
 
const ExtensionsmExtensions
 
putback_type mPutback
 
int mPutbackCode
 
int mPutbackInteger
 
float mPutbackFloat
 
std::string mPutbackName
 
TokenLoc mPutbackLoc
 
bool mStrictKeywords
 
bool mTolerantNames
 
bool mIgnoreNewline
 

Detailed Description

Scanner.

This class translate a char-stream to a token stream (delivered via parser-callbacks).

Member Enumeration Documentation

Enumerator
K_begin 
K_end 
K_short 
K_long 
K_float 
K_if 
K_endif 
K_else 
K_elseif 
K_while 
K_endwhile 
K_return 
K_messagebox 
K_set 
K_to 
K_getsquareroot 
K_menumode 
K_random 
K_startscript 
K_stopscript 
K_scriptrunning 
K_getdistance 
K_getsecondspassed 
K_enable 
K_disable 
K_getdisabled 
Enumerator
Putback_None 
Putback_Special 
Putback_Integer 
Putback_Float 
Putback_Name 
Putback_Keyword 
Enumerator
S_newline 
S_open 
S_close 
S_cmpEQ 
S_cmpNE 
S_cmpLT 
S_cmpLE 
S_cmpGT 
S_cmpGE 
S_plus 
S_minus 
S_mult 
S_div 
S_comma 
S_ref 
S_member 

Constructor & Destructor Documentation

Compiler::Scanner::Scanner ( const Scanner )
private
Compiler::Scanner::Scanner ( ErrorHandler errorHandler,
std::istream &  inputStream,
const Extensions extensions = 0 
)

constructor

Member Function Documentation

void Compiler::Scanner::enableIgnoreNewlines ( )

Treat newline character as a part of script command.

Attention
This mode lasts only until the next keyword is reached.

Here is the caller graph for this function:

void Compiler::Scanner::enableStrictKeywords ( )

Do not accept keywords in quotation marks anymore.

Attention
This mode lasts only until the next newline is reached.

Here is the caller graph for this function:

void Compiler::Scanner::enableTolerantNames ( )

Continue parsing a name when hitting a '.' or a '-'

Attention
This mode lasts only until the next newline is reached.

Here is the caller graph for this function:

bool Compiler::Scanner::get ( char &  c)
private
bool Compiler::Scanner::isStringCharacter ( char  c,
bool  lookAhead = true 
)
private
Todo:
disable this when doing more stricter compiling
Todo:
disable this when doing more stricter compiling. Also, find out who is responsible for allowing it in the first place and meet up with that person in a dark alley.

Here is the caller graph for this function:

bool Compiler::Scanner::isWhitespace ( char  c)
staticprivate

Here is the caller graph for this function:

void Compiler::Scanner::listKeywords ( std::vector< std::string > &  keywords)

Append all known keywords to keywords.

Here is the call graph for this function:

Here is the caller graph for this function:

Scanner& Compiler::Scanner::operator= ( const Scanner )
private
void Compiler::Scanner::putback ( char  c)
private

Here is the caller graph for this function:

void Compiler::Scanner::putbackFloat ( float  value,
const TokenLoc loc 
)

put back a float token

Here is the caller graph for this function:

void Compiler::Scanner::putbackInt ( int  value,
const TokenLoc loc 
)

put back an integer token

Here is the caller graph for this function:

void Compiler::Scanner::putbackKeyword ( int  keyword,
const TokenLoc loc 
)

put back a keyword token

Here is the caller graph for this function:

void Compiler::Scanner::putbackName ( const std::string &  name,
const TokenLoc loc 
)

put back a name token

Here is the caller graph for this function:

void Compiler::Scanner::putbackSpecial ( int  code,
const TokenLoc loc 
)

put back a special token

Here is the caller graph for this function:

void Compiler::Scanner::scan ( Parser parser)

Scan a token and deliver it to the parser.

Here is the call graph for this function:

Here is the caller graph for this function:

bool Compiler::Scanner::scanFloat ( const std::string &  intValue,
Parser parser,
bool cont 
)
private

Here is the call graph for this function:

Here is the caller graph for this function:

bool Compiler::Scanner::scanInt ( char  c,
Parser parser,
bool cont 
)
private

workaround that allows names to begin with digits

Todo:
disable

Here is the call graph for this function:

Here is the caller graph for this function:

bool Compiler::Scanner::scanName ( char  c,
Parser parser,
bool cont 
)
private
Todo:
optionally disable

Here is the call graph for this function:

Here is the caller graph for this function:

bool Compiler::Scanner::scanName ( std::string &  name)
private
Parameters
nameMay contain the start of the name (one or more characters)

Here is the call graph for this function:

bool Compiler::Scanner::scanSpecial ( char  c,
Parser parser,
bool cont 
)
private
Todo:
option to disable the use of [ as alias for (
Todo:
option to disable the use of ] as alias for )
Todo:
hack to allow a space in comparison operators (add option to disable)

Allow = as synonym for ==.

Todo:
optionally disable for post-1.0 scripting improvements.
Todo:
hack to allow a space in comparison operators (add option to disable)

Workaround for some translator who apparently can't keep his minus in order

Todo:
disable for later script formats
Todo:
hack to allow a space in comparison operators (add option to disable)
Todo:
hack to allow a space in comparison operators (add option to disable)

Here is the call graph for this function:

Here is the caller graph for this function:

bool Compiler::Scanner::scanToken ( Parser parser)
private

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

ErrorHandler& Compiler::Scanner::mErrorHandler
private
const Extensions* Compiler::Scanner::mExtensions
private
bool Compiler::Scanner::mIgnoreNewline
private
TokenLoc Compiler::Scanner::mLoc
private
TokenLoc Compiler::Scanner::mPrevLoc
private
putback_type Compiler::Scanner::mPutback
private
int Compiler::Scanner::mPutbackCode
private
float Compiler::Scanner::mPutbackFloat
private
int Compiler::Scanner::mPutbackInteger
private
TokenLoc Compiler::Scanner::mPutbackLoc
private
std::string Compiler::Scanner::mPutbackName
private
std::istream& Compiler::Scanner::mStream
private
bool Compiler::Scanner::mStrictKeywords
private
bool Compiler::Scanner::mTolerantNames
private

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