mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-19 20:23:54 +00:00
Merge pull request #2178 from Capostrophic/declaration
Ignore extra text after a local variable declaration (bug #4867)
This commit is contained in:
commit
8f8bba66d9
2 changed files with 27 additions and 12 deletions
|
@ -38,6 +38,7 @@
|
|||
Bug #4828: Potion looping effects VFX are not shown for NPCs
|
||||
Bug #4837: CTD when a mesh with NiLODNode root node with particles is loaded
|
||||
Bug #4860: Actors outside of processing range visible for one frame after spawning
|
||||
Bug #4867: Arbitrary text after local variable declarations breaks script compilation
|
||||
Bug #4876: AI ratings handling inconsistencies
|
||||
Bug #4877: Startup script executes only on a new game start
|
||||
Bug #4888: Global variable stray explicit reference calls break script compilation
|
||||
|
|
|
@ -22,20 +22,20 @@ bool Compiler::DeclarationParser::parseName (const std::string& name, const Toke
|
|||
char type = mLocals.getType (name2);
|
||||
|
||||
if (type!=' ')
|
||||
{
|
||||
/// \todo add option to make re-declared local variables an error
|
||||
getErrorHandler().warning ("ignoring local variable re-declaration",
|
||||
loc);
|
||||
|
||||
mState = State_End;
|
||||
return true;
|
||||
}
|
||||
|
||||
mLocals.declare (mType, name2);
|
||||
getErrorHandler().warning ("ignoring local variable re-declaration", loc);
|
||||
else
|
||||
mLocals.declare (mType, name2);
|
||||
|
||||
mState = State_End;
|
||||
return true;
|
||||
}
|
||||
else if (mState==State_End)
|
||||
{
|
||||
getErrorHandler().warning ("Ignoring extra text after local variable declaration", loc);
|
||||
SkipParser skip (getErrorHandler(), getContext());
|
||||
scanner.scan (skip);
|
||||
return false;
|
||||
}
|
||||
|
||||
return Parser::parseName (name, loc, scanner);
|
||||
}
|
||||
|
@ -61,17 +61,31 @@ bool Compiler::DeclarationParser::parseKeyword (int keyword, const TokenLoc& loc
|
|||
else if (mState==State_Name)
|
||||
{
|
||||
// allow keywords to be used as local variable names. MW script compiler, you suck!
|
||||
/// \todo option to disable this atrocity.
|
||||
return parseName (loc.mLiteral, loc, scanner);
|
||||
}
|
||||
else if (mState==State_End)
|
||||
{
|
||||
getErrorHandler().warning ("Ignoring extra text after local variable declaration", loc);
|
||||
SkipParser skip (getErrorHandler(), getContext());
|
||||
scanner.scan (skip);
|
||||
return false;
|
||||
}
|
||||
|
||||
return Parser::parseKeyword (keyword, loc, scanner);
|
||||
}
|
||||
|
||||
bool Compiler::DeclarationParser::parseSpecial (int code, const TokenLoc& loc, Scanner& scanner)
|
||||
{
|
||||
if (code==Scanner::S_newline && mState==State_End)
|
||||
if (mState==State_End)
|
||||
{
|
||||
if (code!=Scanner::S_newline)
|
||||
{
|
||||
getErrorHandler().warning ("Ignoring extra text after local variable declaration", loc);
|
||||
SkipParser skip (getErrorHandler(), getContext());
|
||||
scanner.scan (skip);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return Parser::parseSpecial (code, loc, scanner);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue