|
|
|
@ -13,7 +13,7 @@
|
|
|
|
|
namespace Compiler
|
|
|
|
|
{
|
|
|
|
|
StringParser::StringParser (ErrorHandler& errorHandler, const Context& context, Literals& literals)
|
|
|
|
|
: Parser (errorHandler, context), mLiterals (literals), mState (StartState), mSmashCase (false), mDiscard (false)
|
|
|
|
|
: Parser (errorHandler, context), mLiterals (literals), mSmashCase (false), mDiscard (false)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -21,23 +21,18 @@ namespace Compiler
|
|
|
|
|
bool StringParser::parseName (const std::string& name, const TokenLoc& loc,
|
|
|
|
|
Scanner& scanner)
|
|
|
|
|
{
|
|
|
|
|
if (mState==StartState || mState==CommaState)
|
|
|
|
|
{
|
|
|
|
|
start();
|
|
|
|
|
mTokenLoc = loc;
|
|
|
|
|
|
|
|
|
|
if (!mDiscard)
|
|
|
|
|
{
|
|
|
|
|
if (mSmashCase)
|
|
|
|
|
Generator::pushString (mCode, mLiterals, Misc::StringUtils::lowerCase (name));
|
|
|
|
|
else
|
|
|
|
|
Generator::pushString (mCode, mLiterals, name);
|
|
|
|
|
}
|
|
|
|
|
start();
|
|
|
|
|
mTokenLoc = loc;
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
if (!mDiscard)
|
|
|
|
|
{
|
|
|
|
|
if (mSmashCase)
|
|
|
|
|
Generator::pushString (mCode, mLiterals, Misc::StringUtils::lowerCase (name));
|
|
|
|
|
else
|
|
|
|
|
Generator::pushString (mCode, mLiterals, name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Parser::parseName (name, loc, scanner);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool StringParser::parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner)
|
|
|
|
@ -75,17 +70,6 @@ namespace Compiler
|
|
|
|
|
return Parser::parseKeyword (keyword, loc, scanner);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool StringParser::parseSpecial (int code, const TokenLoc& loc, Scanner& scanner)
|
|
|
|
|
{
|
|
|
|
|
if (code==Scanner::S_comma && mState==StartState)
|
|
|
|
|
{
|
|
|
|
|
mState = CommaState;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Parser::parseSpecial (code, loc, scanner);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool StringParser::parseInt (int value, const TokenLoc& loc, Scanner& scanner)
|
|
|
|
|
{
|
|
|
|
|
reportWarning("Treating integer argument as a string", loc);
|
|
|
|
@ -99,7 +83,6 @@ namespace Compiler
|
|
|
|
|
|
|
|
|
|
void StringParser::reset()
|
|
|
|
|
{
|
|
|
|
|
mState = StartState;
|
|
|
|
|
mCode.clear();
|
|
|
|
|
mSmashCase = false;
|
|
|
|
|
mTokenLoc = TokenLoc();
|
|
|
|
|