|
|
@ -47,9 +47,6 @@ 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:
|
|
|
@ -114,7 +111,6 @@ 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==':')
|
|
|
@ -123,7 +119,7 @@ namespace Compiler
|
|
|
|
mLoc.mLiteral.clear();
|
|
|
|
mLoc.mLiteral.clear();
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (std::isalpha (c) || c=='_' || c=='"' || (allowDigit && std::isdigit (c)))
|
|
|
|
else if (std::isalpha (c) || c=='_' || c=='"')
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool cont = false;
|
|
|
|
bool cont = false;
|
|
|
|
|
|
|
|
|
|
|
@ -179,10 +175,18 @@ namespace Compiler
|
|
|
|
{
|
|
|
|
{
|
|
|
|
value += c;
|
|
|
|
value += c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (std::isalpha (c) || c=='_')
|
|
|
|
else if (isStringCharacter (c))
|
|
|
|
|
|
|
|
{
|
|
|
|
error = true;
|
|
|
|
error = true;
|
|
|
|
else if (c=='.' && !error)
|
|
|
|
value += c;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (c=='.')
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
putback (c);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
return scanFloat (value, parser, cont);
|
|
|
|
return scanFloat (value, parser, cont);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -193,7 +197,15 @@ namespace Compiler
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
if (error)
|
|
|
|
return false;
|
|
|
|
{
|
|
|
|
|
|
|
|
/// workaround that allows names to begin with digits
|
|
|
|
|
|
|
|
/// \todo disable
|
|
|
|
|
|
|
|
TokenLoc loc (mLoc);
|
|
|
|
|
|
|
|
mLoc.mLiteral.clear();
|
|
|
|
|
|
|
|
cont = parser.parseName (value, loc, *this);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TokenLoc loc (mLoc);
|
|
|
|
TokenLoc loc (mLoc);
|
|
|
|
mLoc.mLiteral.clear();
|
|
|
|
mLoc.mLiteral.clear();
|
|
|
@ -555,8 +567,7 @@ 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)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -608,9 +619,4 @@ namespace Compiler
|
|
|
|
if (mExtensions)
|
|
|
|
if (mExtensions)
|
|
|
|
mExtensions->listKeywords (keywords);
|
|
|
|
mExtensions->listKeywords (keywords);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Scanner::allowNameStartingwithDigit()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mNameStartingWithDigit = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|