Skip to content

Commit

Permalink
Merge pull request OpenMW#1929 from Capostrophic/elseif
Browse files Browse the repository at this point in the history
Ignore the rest of the line after else operator (bug OpenMW#3006)
  • Loading branch information
psi29a authored Mar 24, 2019
2 parents 8f8bba6 + cbce1a1 commit 6cbf128
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

Bug #2969: Scripted items can stack
Bug #2987: Editor: some chance and AI data fields can overflow
Bug #3006: 'else if' operator breaks script compilation
Bug #3282: Unintended behaviour when assigning F3 and Windows keys
Bug #3623: Fix HiDPI on Windows
Bug #3733: Normal maps are inverted on mirrored UVs
Expand Down
22 changes: 19 additions & 3 deletions components/compiler/controlparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ namespace Compiler
scanner.scan (mLineParser);
return true;
}
else if (mState==IfElseJunkState)
{
getErrorHandler().warning ("Ignoring extra text after else", loc);
SkipParser skip (getErrorHandler(), getContext());
scanner.scan (skip);
mState = IfElseBodyState;
return true;
}

return Parser::parseName (name, loc, scanner);
}
Expand Down Expand Up @@ -207,8 +215,7 @@ namespace Compiler
return true;
}
}
else if (mState==IfBodyState || mState==IfElseifBodyState || mState==IfElseBodyState ||
mState==IfElseJunkState)
else if (mState==IfBodyState || mState==IfElseifBodyState || mState==IfElseBodyState)
{
if (parseIfBody (keyword, loc, scanner))
return true;
Expand All @@ -218,6 +225,14 @@ namespace Compiler
if ( parseWhileBody (keyword, loc, scanner))
return true;
}
else if (mState==IfElseJunkState)
{
getErrorHandler().warning ("Ignoring extra text after else", loc);
SkipParser skip (getErrorHandler(), getContext());
scanner.scan (skip);
mState = IfElseBodyState;
return true;
}

return Parser::parseKeyword (keyword, loc, scanner);
}
Expand Down Expand Up @@ -250,8 +265,9 @@ namespace Compiler
default: ;
}
}
else if (code==Scanner::S_open && mState==IfElseJunkState)
else if (mState==IfElseJunkState)
{
getErrorHandler().warning ("Ignoring extra text after else", loc);
SkipParser skip (getErrorHandler(), getContext());
scanner.scan (skip);
mState = IfElseBodyState;
Expand Down

0 comments on commit 6cbf128

Please sign in to comment.