Commit 981fbedf authored by twanvl's avatar twanvl

Improved position reporting of script errors

parent 52454bf4
......@@ -399,6 +399,7 @@ label:
mode: Mode
uses: Uses
reminder: Reminder text
rules: Additional rules
standard keyword:
This is a standard %s keyword, you can not edit it.
If you make a copy of the keyword your copy will take precedent.
......@@ -691,6 +692,9 @@ error:
in function %s
in parameter:
Parameter %s: %s
in keyword reminder:
%s
in reminder text of keyword '%s'
# Image stuff
coordinates for blending overlap: Coordinates for blending overlap
......
......@@ -59,20 +59,20 @@ KeywordsPanel::KeywordsPanel(Window* parent, int id)
sp = new wxBoxSizer(wxVERTICAL);
sp->Add(fixed, 0, wxEXPAND); sp->Show(fixed,false);
wxSizer* s1 = new wxBoxSizer(wxVERTICAL);
s1->Add(new wxStaticText(panel, wxID_ANY, _("Keyword:")), 0);
s1->Add(new wxStaticText(panel, wxID_ANY, _LABEL_("keyword")+_(":")), 0);
s1->Add(keyword, 0, wxEXPAND | wxTOP, 2);
s1->Add(new wxStaticText(panel, wxID_ANY, _("Mode:")), 0, wxTOP, 2);
s1->Add(new wxStaticText(panel, wxID_ANY, _LABEL_("mode")+_(":")), 0, wxTOP, 2);
s1->Add(mode, 0, wxEXPAND | wxTOP, 2);
sp->Add(s1, 0, wxEXPAND | wxLEFT, 2);
sp->Add(new wxStaticLine(panel), 0, wxEXPAND | wxTOP | wxBOTTOM, 8);
wxSizer* s2 = new wxBoxSizer(wxVERTICAL);
s2->Add(new wxStaticText(panel, wxID_ANY, _("Match:")), 0);
s2->Add(new wxStaticText(panel, wxID_ANY, _LABEL_("match")+_(":")), 0);
s2->Add(match, 0, wxEXPAND | wxTOP, 2);
s2->Add(add_param, 0, wxALIGN_LEFT | wxTOP, 2);
sp->Add(s2, 0, wxEXPAND | wxLEFT, 2);
sp->Add(new wxStaticLine(panel), 0, wxEXPAND | wxTOP | wxBOTTOM, 8);
wxSizer* s3 = new wxBoxSizer(wxVERTICAL);
s3->Add(new wxStaticText(panel, wxID_ANY, _("Reminder:")), 0);
s3->Add(new wxStaticText(panel, wxID_ANY, _LABEL_("reminder")+_(":")), 0);
s3->Add(reminder, 1, wxEXPAND | wxTOP, 2);
s3->Add(ref_param, 0, wxALIGN_LEFT | wxTOP, 2);
s3->Add(errors, 0, wxEXPAND | wxTOP, 4);
......@@ -80,7 +80,7 @@ KeywordsPanel::KeywordsPanel(Window* parent, int id)
sp->Add(s3, 1, wxEXPAND | wxLEFT, 2);
sp->Add(new wxStaticLine(panel), 0, wxEXPAND | wxTOP | wxBOTTOM, 8);
wxSizer* s4 = new wxBoxSizer(wxVERTICAL);
s4->Add(new wxStaticText(panel, wxID_ANY, _("Rules:")), 0);
s4->Add(new wxStaticText(panel, wxID_ANY, _LABEL_("rules")+_(":")), 0);
s4->Add(rules, 1, wxEXPAND | wxTOP, 2);
sp->Add(s4, 1, wxEXPAND | wxLEFT, 2);
panel->SetSizer(sp);
......
# This file contains the keys expected to be in MSE locales
# It was automatically generated by tools/locale/locale.pl
# Generated on Sat May 31 21:42:09 2008
# Generated on Sun Jun 1 02:54:59 2008
action:
add control point: 0
......@@ -104,6 +104,7 @@ error:
has no member value: 2
images used for blending must have the same size: 0
in function: 2
in keyword reminder: 2
in parameter: 2
install packages successful: 1
installing updates: 0
......@@ -291,6 +292,7 @@ label:
reminder: 0
remove package: 0
result: 0
rules: 0
save changes: 1
select cards print: 0
select columns: 0
......
......@@ -41,6 +41,7 @@ struct Token {
TokenType type;
String value;
bool newline; ///< Is there a newline between this token and the previous one?
size_t pos; ///< Start position of the token
inline bool operator == (TokenType t) const { return type == t; }
inline bool operator != (TokenType t) const { return type != t; }
......@@ -92,7 +93,7 @@ class TokenIterator {
stack<MoreInput> more; ///< Read tokens from here when we are done with the current input
/// Add a token to the buffer, with the current newline value, resets newline
void addToken(TokenType type, const String& value);
void addToken(TokenType type, const String& value, size_t start);
/// Read the next token, and add it to the buffer
void readToken();
/// Read the next token which is a string (after the opening ")
......@@ -154,8 +155,8 @@ void TokenIterator::putBack() {
buffer.insert(buffer.begin(), t);
}
void TokenIterator::addToken(TokenType type, const String& value) {
Token t = {type, value, newline};
void TokenIterator::addToken(TokenType type, const String& value, size_t start) {
Token t = {type, value, newline, start};
buffer.push_back(t);
newline = false;
}
......@@ -170,7 +171,7 @@ void TokenIterator::readToken() {
more.pop();
} else {
// EOF
addToken(TOK_EOF, _("end of input"));
addToken(TOK_EOF, _("end of input"), input.size());
}
return;
}
......@@ -200,7 +201,7 @@ void TokenIterator::readToken() {
// name
size_t start = pos - 1;
while (pos < input.size() && isAlnum_(input.GetChar(pos))) ++pos;
addToken(TOK_NAME, cannocial_name_form(input.substr(start, pos-start))); // convert name to cannocial form
addToken(TOK_NAME, cannocial_name_form(input.substr(start, pos-start)), start); // convert name to cannocial form
} else if (isDigit(c)) {
// number
size_t start = pos - 1;
......@@ -208,16 +209,16 @@ void TokenIterator::readToken() {
String num = input.substr(start, pos-start);
addToken(
num.find_first_of('.') == String::npos ? TOK_INT : TOK_DOUBLE,
num
num, start
);
} else if (isOper(c)) {
// operator
if (pos < input.size() && isLongOper(input.substr(pos - 1, 2))) {
// long operator
addToken(TOK_OPER, input.substr(pos - 1, 2));
addToken(TOK_OPER, input.substr(pos - 1, 2), pos-1);
pos += 1;
} else {
addToken(TOK_OPER, input.substr(pos - 1, 1));
addToken(TOK_OPER, input.substr(pos - 1, 1), pos-1);
}
} else if (c==_('"')) {
// string
......@@ -226,16 +227,16 @@ void TokenIterator::readToken() {
} else if (c == _('}') && !open_braces.empty() && open_braces.top() != BRACE_PAREN) {
// closing smart string, resume to string parsing
// "a{e}b" --> "a" "{ e }" "b"
addToken(TOK_RPAREN, _("}\""));
addToken(TOK_RPAREN, _("}\""), pos-1);
readStringToken();
} else if (isLparen(c)) {
// paranthesis/brace
open_braces.push(BRACE_PAREN);
addToken(TOK_LPAREN, String(1,c));
addToken(TOK_LPAREN, String(1,c), pos-1);
} else if (isRparen(c)) {
// paranthesis/brace
if (!open_braces.empty()) open_braces.pop();
addToken(TOK_RPAREN, String(1,c));
addToken(TOK_RPAREN, String(1,c), pos-1);
} else if(c==_('#')) {
// comment untill end of line
while (pos < input.size() && input[pos] != _('\n')) ++pos;
......@@ -246,17 +247,18 @@ void TokenIterator::readToken() {
}
void TokenIterator::readStringToken() {
size_t start = max((size_t)1, pos) - 1;
String str;
while (true) {
if (pos >= input.size()) {
if (!open_braces.empty() && open_braces.top() == BRACE_STRING_MODE) {
// in string mode: end of input = end of string
addToken(TOK_STRING, str);
addToken(TOK_STRING, str, start);
return;
} else {
add_error(_("Unexpected end of input in string constant"));
// fix up
addToken(TOK_STRING, str);
addToken(TOK_STRING, str, start);
return;
}
}
......@@ -264,7 +266,7 @@ void TokenIterator::readStringToken() {
// parse the string constant
if (c == _('"') && !open_braces.empty() && open_braces.top() == BRACE_STRING) {
// end of string
addToken(TOK_STRING, str);
addToken(TOK_STRING, str, start);
open_braces.pop();
return;
} else if (c == _('\\')) {
......@@ -272,7 +274,7 @@ void TokenIterator::readStringToken() {
if (pos >= input.size()) {
add_error(_("Unexpected end of input in string constant"));
// fix up
addToken(TOK_STRING, str);
addToken(TOK_STRING, str, start);
return;
}
c = input.GetChar(pos++);
......@@ -282,8 +284,8 @@ void TokenIterator::readStringToken() {
} else if (c == _('{')) {
// smart string
// "a{e}b" --> "a" "{ e }" "b"
addToken(TOK_STRING, str);
addToken(TOK_LPAREN, _("\"{"));
addToken(TOK_STRING, str, start);
addToken(TOK_LPAREN, _("\"{"), pos-1);
return;
} else {
str += c;
......@@ -302,7 +304,7 @@ void TokenIterator::add_error(const String& message) {
errors.push_back(ScriptParseError(pos, line, filename, message));
}
void TokenIterator::expected(const String& expected) {
size_t error_pos = pos - peek(0).value.size();
size_t error_pos = peek(0).pos;
if (!errors.empty() && errors.back().start == pos) return; // already an error here
// find line number
int line = 1;
......
......@@ -173,6 +173,7 @@ Source: "data/en.mse-locale/*"; DestDir: "{app}/data/en.mse-locale/";
#emit Package(1, 'magic', 'future', 'style', 'mtg/future/base')
#emit Package(1, 'magic', 'future-textless', 'style', 'mtg/future/textless')
#emit Font (0, 'ModMatrix.ttf', 'ModMatrix', 'mtg')
#emit Font (0, 'matrixb.ttf', 'Matrix', 'mtg style/yugioh')
#emit Font (0, 'matrixbsc.ttf', 'MatrixBoldSmallCaps', 'mtg')
#emit Font (0, 'magmed.ttf', 'MagicMedieval', 'mtg/old')
......@@ -212,6 +213,8 @@ Source: "data/en.mse-locale/*"; DestDir: "{app}/data/en.mse-locale/";
#emit FontNoReg (0, 'MatrixRegularSmallCaps.pfm', 'MatrixRegularSmallCaps', 'yugioh')
#emit FontNoReg (0, 'MatrixRegularSmallCaps.pfb', 'MatrixRegularSmallCaps', 'yugioh')
#emit Font (0, 'pala.ttf', 'Palatino Linotype', 'yugioh')
#emit Font (0, 'palab.ttf', 'Palatino Linotype Bold', 'yugioh')
#emit Font (0, 'MatriBoo.ttf', 'MatrixBook', 'yugioh')
; ------------------------------------------------------------------------- : Rest of installer
......@@ -228,7 +231,7 @@ Name: "{commonprograms}\Magic Set Editor"; Filename: "{app}\mse.exe"; WorkingDir
#emit Association('.mse-set', 'Set', '2')
#emit Association('.mse-symbol', 'Symbol', '3')
;#emit Association('.mse-installer', 'Installer', '1')
#emit Association('.mse-installer', 'Installer', '1')
[Run]
Filename: "{app}\mse.exe"; Description: "Start Magic Set Editor"; Flags: postinstall nowait skipifsilent unchecked
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment