mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-13 21:40:11 +00:00
Merge branch 'ellipsis' into 'master'
Allow unquoted string arguments to start with . and - Closes #3846 See merge request OpenMW/openmw!943
This commit is contained in:
commit
f2ab1913e3
@ -1,7 +1,7 @@
|
|||||||
0.48.0
|
0.48.0
|
||||||
------
|
------
|
||||||
|
|
||||||
|
Bug #3846: Strings starting with "-" fail to compile if not enclosed in quotes
|
||||||
|
|
||||||
0.47.0
|
0.47.0
|
||||||
------
|
------
|
||||||
|
@ -669,6 +669,7 @@ namespace Compiler
|
|||||||
|
|
||||||
if (argument=='c') stringParser.smashCase();
|
if (argument=='c') stringParser.smashCase();
|
||||||
if (argument=='x') stringParser.discard();
|
if (argument=='x') stringParser.discard();
|
||||||
|
scanner.enableExpectName();
|
||||||
scanner.scan (stringParser);
|
scanner.scan (stringParser);
|
||||||
|
|
||||||
if ((optional || argument=='x') && stringParser.isEmpty())
|
if ((optional || argument=='x') && stringParser.isEmpty())
|
||||||
|
@ -22,6 +22,7 @@ namespace Compiler
|
|||||||
{
|
{
|
||||||
mStrictKeywords = false;
|
mStrictKeywords = false;
|
||||||
mTolerantNames = false;
|
mTolerantNames = false;
|
||||||
|
mExpectName = false;
|
||||||
mLoc.mColumn = 0;
|
mLoc.mColumn = 0;
|
||||||
++mLoc.mLine;
|
++mLoc.mLine;
|
||||||
mLoc.mLiteral.clear();
|
mLoc.mLiteral.clear();
|
||||||
@ -416,12 +417,13 @@ namespace Compiler
|
|||||||
special = S_close;
|
special = S_close;
|
||||||
else if (c=='.')
|
else if (c=='.')
|
||||||
{
|
{
|
||||||
|
MultiChar next;
|
||||||
// check, if this starts a float literal
|
// check, if this starts a float literal
|
||||||
if (get (c))
|
if (get (next))
|
||||||
{
|
{
|
||||||
putback (c);
|
putback (next);
|
||||||
|
|
||||||
if (c.isDigit())
|
if (next.isDigit())
|
||||||
return scanFloat ("", parser, cont);
|
return scanFloat ("", parser, cont);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -476,13 +478,14 @@ namespace Compiler
|
|||||||
}
|
}
|
||||||
else if (c.isMinusSign())
|
else if (c.isMinusSign())
|
||||||
{
|
{
|
||||||
if (get (c))
|
MultiChar next;
|
||||||
|
if (get (next))
|
||||||
{
|
{
|
||||||
if (c=='>')
|
if (next=='>')
|
||||||
special = S_ref;
|
special = S_ref;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
putback (c);
|
putback (next);
|
||||||
special = S_minus;
|
special = S_minus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -558,6 +561,15 @@ namespace Compiler
|
|||||||
|
|
||||||
if (special==S_newline)
|
if (special==S_newline)
|
||||||
mLoc.mLiteral = "<newline>";
|
mLoc.mLiteral = "<newline>";
|
||||||
|
else if (mExpectName && (special == S_member || special == S_minus))
|
||||||
|
{
|
||||||
|
mExpectName = false;
|
||||||
|
bool tolerant = mTolerantNames;
|
||||||
|
mTolerantNames = true;
|
||||||
|
bool out = scanName(c, parser, cont);
|
||||||
|
mTolerantNames = tolerant;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
TokenLoc loc (mLoc);
|
TokenLoc loc (mLoc);
|
||||||
mLoc.mLiteral.clear();
|
mLoc.mLiteral.clear();
|
||||||
@ -590,13 +602,14 @@ namespace Compiler
|
|||||||
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),
|
||||||
mStrictKeywords (false), mTolerantNames (false), mIgnoreNewline(false)
|
mStrictKeywords (false), mTolerantNames (false), mIgnoreNewline(false), mExpectName(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scanner::scan (Parser& parser)
|
void Scanner::scan (Parser& parser)
|
||||||
{
|
{
|
||||||
while (scanToken (parser));
|
while (scanToken (parser));
|
||||||
|
mExpectName = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scanner::putbackSpecial (int code, const TokenLoc& loc)
|
void Scanner::putbackSpecial (int code, const TokenLoc& loc)
|
||||||
@ -657,4 +670,9 @@ namespace Compiler
|
|||||||
{
|
{
|
||||||
mTolerantNames = true;
|
mTolerantNames = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Scanner::enableExpectName()
|
||||||
|
{
|
||||||
|
mExpectName = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,6 +193,7 @@ namespace Compiler
|
|||||||
bool mStrictKeywords;
|
bool mStrictKeywords;
|
||||||
bool mTolerantNames;
|
bool mTolerantNames;
|
||||||
bool mIgnoreNewline;
|
bool mIgnoreNewline;
|
||||||
|
bool mExpectName;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -286,6 +287,11 @@ namespace Compiler
|
|||||||
///
|
///
|
||||||
/// \attention This mode lasts only until the next newline is reached.
|
/// \attention This mode lasts only until the next newline is reached.
|
||||||
void enableTolerantNames();
|
void enableTolerantNames();
|
||||||
|
|
||||||
|
/// Treat '.' and '-' as the start of a name.
|
||||||
|
///
|
||||||
|
/// \attention This mode lasts only until the next newline is reached or the call to scan ends.
|
||||||
|
void enableExpectName();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user