mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Fixed bug in script parser/compiler: "x[if a then b else c]" was incorrectly optimized;
Sciript parse errors in include files now get reported for the right file and line number. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@458 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -48,13 +48,20 @@ void OptionalScript::parse(Reader& reader, bool string_mode) {
|
||||
vector<ScriptParseError> errors;
|
||||
script = ::parse(unparsed, string_mode, errors);
|
||||
// show parse errors as warnings
|
||||
FOR_EACH(e, errors) {
|
||||
// find line number
|
||||
int line = 0;
|
||||
for (size_t i = 0 ; i < unparsed.size() && i < e.start ; ++i) {
|
||||
if (unparsed.GetChar(i) == _('\n')) line++;
|
||||
String include_warnings;
|
||||
for (size_t i = 0 ; i < errors.size() ; ++i) {
|
||||
const ScriptParseError& e = errors[i];
|
||||
if (!e.filename.empty()) {
|
||||
// error in an include file
|
||||
include_warnings += String::Format(_("\n On line %d:\t "), e.line) + e.ParseError::what();
|
||||
if (i + 1 >= errors.size() || errors[i+1].filename != e.filename) {
|
||||
reader.warning(_("In include file '") + e.filename + _("'") + include_warnings);
|
||||
include_warnings.clear();
|
||||
}
|
||||
} else {
|
||||
// use ParseError::what because we don't want e.start in the error message
|
||||
reader.warning(e.ParseError::what(), e.line - 1);
|
||||
}
|
||||
reader.warning(e.ParseError::what(), line); // use ParseError::what because we don't want e.start in the error message
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user