mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 12:58:00 +03:00
Merge branch 'boat_closer_to_todd' into 'master'
Ignore special characters preceding script commands Closes #6807 See merge request OpenMW/openmw!2555
This commit is contained in:
commit
80e2cd79ec
5 changed files with 53 additions and 8 deletions
|
@ -94,16 +94,10 @@ namespace Compiler
|
|||
|
||||
bool FileParser::parseSpecial(int code, const TokenLoc& loc, Scanner& scanner)
|
||||
{
|
||||
// Ignore any junk special characters
|
||||
if (mState == BeginState)
|
||||
{
|
||||
if (code != Scanner::S_newline)
|
||||
reportWarning("Stray special character before begin statement", loc);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (code == Scanner::S_newline)
|
||||
{
|
||||
if (mState == BeginState)
|
||||
return true;
|
||||
if (mState == BeginCompleteState)
|
||||
{
|
||||
// parse the script body
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace Compiler
|
|||
mLoc.mColumn = 0;
|
||||
++mLoc.mLine;
|
||||
mLoc.mLiteral.clear();
|
||||
mIgnoreSpecial = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -119,6 +120,7 @@ namespace Compiler
|
|||
}
|
||||
else if (c.isAlpha() || c == '_' || c == '"')
|
||||
{
|
||||
mIgnoreSpecial = false;
|
||||
bool cont = false;
|
||||
|
||||
if (scanName(c, parser, cont))
|
||||
|
@ -129,6 +131,7 @@ namespace Compiler
|
|||
}
|
||||
else if (c.isDigit())
|
||||
{
|
||||
mIgnoreSpecial = false;
|
||||
bool cont = false;
|
||||
|
||||
bool scanned = mExpectName ? scanName(c, parser, cont) : scanInt(c, parser, cont);
|
||||
|
@ -402,6 +405,23 @@ namespace Compiler
|
|||
|
||||
if (c == '\n')
|
||||
special = S_newline;
|
||||
else if (mIgnoreSpecial)
|
||||
{
|
||||
// Ignore junk special characters
|
||||
TokenLoc loc = mLoc;
|
||||
while (get(c))
|
||||
{
|
||||
if (c.isAlpha() || c == '_' || c == '"' || c.isDigit() || c == ';' || c == '\n')
|
||||
{
|
||||
putback(c);
|
||||
break;
|
||||
}
|
||||
c.appendTo(loc.mLiteral);
|
||||
}
|
||||
mErrorHandler.warning("Stray special character at start of line", loc);
|
||||
cont = true;
|
||||
return true;
|
||||
}
|
||||
else if (c == '(' || c == '[') /// \todo option to disable the use of [ as alias for (
|
||||
special = S_open;
|
||||
else if (c == ')' || c == ']') /// \todo option to disable the use of ] as alias for )
|
||||
|
@ -598,6 +618,7 @@ namespace Compiler
|
|||
, mTolerantNames(false)
|
||||
, mIgnoreNewline(false)
|
||||
, mExpectName(false)
|
||||
, mIgnoreSpecial(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -195,6 +195,7 @@ namespace Compiler
|
|||
bool mTolerantNames;
|
||||
bool mIgnoreNewline;
|
||||
bool mExpectName;
|
||||
bool mIgnoreSpecial;
|
||||
|
||||
public:
|
||||
enum keyword
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue