OpenMW
|
#include <scanner.hpp>
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 | enableStrictKeywords () |
Private Types | |
enum | putback_type { Putback_None, Putback_Special, Putback_Integer, Putback_Float, Putback_Name, Putback_Keyword } |
Private Member Functions | |
Scanner (const Scanner &) | |
Scanner & | operator= (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 | |
ErrorHandler & | mErrorHandler |
TokenLoc | mLoc |
TokenLoc | mPrevLoc |
std::istream & | mStream |
const Extensions * | mExtensions |
putback_type | mPutback |
int | mPutbackCode |
int | mPutbackInteger |
float | mPutbackFloat |
std::string | mPutbackName |
TokenLoc | mPutbackLoc |
bool | mStrictKeywords |
This class translate a char-stream to a token stream (delivered via parser-callbacks).
|
private |
|
private |
Compiler::Scanner::Scanner | ( | ErrorHandler & | errorHandler, |
std::istream & | inputStream, | ||
const Extensions * | extensions = 0 |
||
) |
constructor
void Compiler::Scanner::enableStrictKeywords | ( | ) |
Do not accept keywords in quotation marks anymore.
|
private |
|
staticprivate |
void Compiler::Scanner::listKeywords | ( | std::vector< std::string > & | keywords | ) |
Append all known keywords to keywords.
|
private |
void Compiler::Scanner::putbackFloat | ( | float | value, |
const TokenLoc & | loc | ||
) |
put back a float token
put back an integer token
put back a keyword token
void Compiler::Scanner::putbackName | ( | const std::string & | name, |
const TokenLoc & | loc | ||
) |
put back a name token
put back a special token
void Compiler::Scanner::scan | ( | Parser & | parser | ) |
Scan a token and deliver it to the parser.
|
private |
workaround that allows names to begin with digits
|
private |
name | May contain the start of the name (one or more characters) |
Allow = as synonym for ==.
Workaround for some translator who apparently can't keep his minus in order
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |