|
|
@ -48,6 +48,9 @@ namespace Compiler
|
|
|
|
|
|
|
|
|
|
|
|
bool Scanner::scanToken (Parser& parser)
|
|
|
|
bool Scanner::scanToken (Parser& parser)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
bool allowDigit = mNameStartingWithDigit;
|
|
|
|
|
|
|
|
mNameStartingWithDigit = false;
|
|
|
|
|
|
|
|
|
|
|
|
switch (mPutback)
|
|
|
|
switch (mPutback)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case Putback_Special:
|
|
|
|
case Putback_Special:
|
|
|
@ -112,6 +115,7 @@ namespace Compiler
|
|
|
|
else if (isWhitespace (c))
|
|
|
|
else if (isWhitespace (c))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mLoc.mLiteral.clear();
|
|
|
|
mLoc.mLiteral.clear();
|
|
|
|
|
|
|
|
mNameStartingWithDigit = allowDigit;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (c==':')
|
|
|
|
else if (c==':')
|
|
|
@ -120,21 +124,21 @@ namespace Compiler
|
|
|
|
mLoc.mLiteral.clear();
|
|
|
|
mLoc.mLiteral.clear();
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (std::isdigit (c))
|
|
|
|
else if (std::isalpha (c) || c=='_' || c=='"' || (allowDigit && std::isdigit (c)))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool cont = false;
|
|
|
|
bool cont = false;
|
|
|
|
|
|
|
|
|
|
|
|
if (scanInt (c, parser, cont))
|
|
|
|
if (scanName (c, parser, cont))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mLoc.mLiteral.clear();
|
|
|
|
mLoc.mLiteral.clear();
|
|
|
|
return cont;
|
|
|
|
return cont;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (std::isalpha (c) || c=='_' || c=='"')
|
|
|
|
else if (std::isdigit (c))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool cont = false;
|
|
|
|
bool cont = false;
|
|
|
|
|
|
|
|
|
|
|
|
if (scanName (c, parser, cont))
|
|
|
|
if (scanInt (c, parser, cont))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mLoc.mLiteral.clear();
|
|
|
|
mLoc.mLiteral.clear();
|
|
|
|
return cont;
|
|
|
|
return cont;
|
|
|
@ -516,7 +520,8 @@ namespace Compiler
|
|
|
|
Scanner::Scanner (ErrorHandler& errorHandler, std::istream& inputStream,
|
|
|
|
Scanner::Scanner (ErrorHandler& errorHandler, std::istream& inputStream,
|
|
|
|
const Extensions *extensions)
|
|
|
|
const Extensions *extensions)
|
|
|
|
: mErrorHandler (errorHandler), mStream (inputStream), mExtensions (extensions),
|
|
|
|
: mErrorHandler (errorHandler), mStream (inputStream), mExtensions (extensions),
|
|
|
|
mPutback (Putback_None), mPutbackCode(0), mPutbackInteger(0), mPutbackFloat(0)
|
|
|
|
mPutback (Putback_None), mPutbackCode(0), mPutbackInteger(0), mPutbackFloat(0),
|
|
|
|
|
|
|
|
mNameStartingWithDigit (false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -568,4 +573,9 @@ namespace Compiler
|
|
|
|
if (mExtensions)
|
|
|
|
if (mExtensions)
|
|
|
|
mExtensions->listKeywords (keywords);
|
|
|
|
mExtensions->listKeywords (keywords);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Scanner::allowNameStartingwithDigit()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mNameStartingWithDigit = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|