Merge branch 'scriptfixes'

moveref
Marc Zinnschlag 10 years ago
commit 057d0913d6

@ -436,7 +436,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
} }
if (mCompileAllDialogue) if (mCompileAllDialogue)
{ {
std::pair<int, int> result = MWDialogue::ScriptTest::compileAll(&mExtensions); std::pair<int, int> result = MWDialogue::ScriptTest::compileAll(&mExtensions, mWarningsMode);
if (result.first) if (result.first)
std::cout std::cout
<< "compiled " << result.second << " of " << result.first << " dialogue script/actor combinations a(" << "compiled " << result.second << " of " << result.first << " dialogue script/actor combinations a("

@ -21,7 +21,7 @@
namespace namespace
{ {
void test(const MWWorld::Ptr& actor, int &compiled, int &total, const Compiler::Extensions* extensions) void test(const MWWorld::Ptr& actor, int &compiled, int &total, const Compiler::Extensions* extensions, int warningsMode)
{ {
MWDialogue::Filter filter(actor, 0, false); MWDialogue::Filter filter(actor, 0, false);
@ -29,6 +29,7 @@ void test(const MWWorld::Ptr& actor, int &compiled, int &total, const Compiler::
compilerContext.setExtensions(extensions); compilerContext.setExtensions(extensions);
std::ostream errorStream(std::cout.rdbuf()); std::ostream errorStream(std::cout.rdbuf());
Compiler::StreamErrorHandler errorHandler(errorStream); Compiler::StreamErrorHandler errorHandler(errorStream);
errorHandler.setWarningsMode (warningsMode);
const MWWorld::Store<ESM::Dialogue>& dialogues = MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>(); const MWWorld::Store<ESM::Dialogue>& dialogues = MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>();
for (MWWorld::Store<ESM::Dialogue>::iterator it = dialogues.begin(); it != dialogues.end(); ++it) for (MWWorld::Store<ESM::Dialogue>::iterator it = dialogues.begin(); it != dialogues.end(); ++it)
@ -100,21 +101,21 @@ namespace MWDialogue
namespace ScriptTest namespace ScriptTest
{ {
std::pair<int, int> compileAll(const Compiler::Extensions *extensions) std::pair<int, int> compileAll(const Compiler::Extensions *extensions, int warningsMode)
{ {
int compiled = 0, total = 0; int compiled = 0, total = 0;
const MWWorld::Store<ESM::NPC>& npcs = MWBase::Environment::get().getWorld()->getStore().get<ESM::NPC>(); const MWWorld::Store<ESM::NPC>& npcs = MWBase::Environment::get().getWorld()->getStore().get<ESM::NPC>();
for (MWWorld::Store<ESM::NPC>::iterator it = npcs.begin(); it != npcs.end(); ++it) for (MWWorld::Store<ESM::NPC>::iterator it = npcs.begin(); it != npcs.end(); ++it)
{ {
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), it->mId); MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), it->mId);
test(ref.getPtr(), compiled, total, extensions); test(ref.getPtr(), compiled, total, extensions, warningsMode);
} }
const MWWorld::Store<ESM::Creature>& creatures = MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>(); const MWWorld::Store<ESM::Creature>& creatures = MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>();
for (MWWorld::Store<ESM::Creature>::iterator it = creatures.begin(); it != creatures.end(); ++it) for (MWWorld::Store<ESM::Creature>::iterator it = creatures.begin(); it != creatures.end(); ++it)
{ {
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), it->mId); MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), it->mId);
test(ref.getPtr(), compiled, total, extensions); test(ref.getPtr(), compiled, total, extensions, warningsMode);
} }
return std::make_pair(total, compiled); return std::make_pair(total, compiled);
} }

@ -11,7 +11,7 @@ namespace ScriptTest
/// Attempt to compile all dialogue scripts, use for verification purposes /// Attempt to compile all dialogue scripts, use for verification purposes
/// @return A pair containing <total number of scripts, number of successfully compiled scripts> /// @return A pair containing <total number of scripts, number of successfully compiled scripts>
std::pair<int, int> compileAll(const Compiler::Extensions* extensions); std::pair<int, int> compileAll(const Compiler::Extensions* extensions, int warningsMode);
} }

@ -661,7 +661,7 @@ namespace Compiler
else else
{ {
// no comma was used between arguments // no comma was used between arguments
scanner.putbackKeyword (code, loc); scanner.putbackSpecial (code, loc);
return false; return false;
} }
} }

@ -489,6 +489,13 @@ namespace Compiler
bool LineParser::parseSpecial (int code, const TokenLoc& loc, Scanner& scanner) bool LineParser::parseSpecial (int code, const TokenLoc& loc, Scanner& scanner)
{ {
if (mState==EndState && code==Scanner::S_open)
{
getErrorHandler().warning ("stray '[' or '(' at the end of the line (ignoring it)",
loc);
return true;
}
if (code==Scanner::S_newline && if (code==Scanner::S_newline &&
(mState==EndState || mState==BeginState || mState==PotentialEndState)) (mState==EndState || mState==BeginState || mState==PotentialEndState))
return false; return false;

@ -314,7 +314,7 @@ namespace Compiler
bool Scanner::scanName (char c, std::string& name) bool Scanner::scanName (char c, std::string& name)
{ {
bool first = false; bool first = true;
bool error = false; bool error = false;
name.clear(); name.clear();
@ -554,8 +554,7 @@ namespace Compiler
bool Scanner::isWhitespace (char c) bool Scanner::isWhitespace (char c)
{ {
return c==' ' || c=='\t' return c==' ' || c=='\t';
|| c=='['; ///< \todo disable this when doing more strict compiling
} }
// constructor // constructor

Loading…
Cancel
Save