mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Added some more classes for ScriptErrors;
Added split_text function, which is the 'opposite' of break_text; Script code "f\n(stuff)" now parses as "f;stuff" instead of a function call, "f(stuff)"; Fixed bug in cursor movement, which caused the closing > of a tag at end of input to be overwritten. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1175 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -625,7 +625,7 @@ void parseExpr(TokenIterator& input, Script& script, Precedence minPrec) {
|
||||
void parseOper(TokenIterator& input, Script& script, Precedence minPrec, InstructionType closeWith, int closeWithData) {
|
||||
size_t added = script.getInstructions().size(); // number of instructions added
|
||||
parseExpr(input, script, minPrec); // first argument
|
||||
added -= script.getInstructions().size();
|
||||
added = script.getInstructions().size() - added;
|
||||
// read any operators after an expression
|
||||
// EBNF: expr = expr | expr oper expr
|
||||
// without left recursion: expr = expr (oper expr)*
|
||||
@@ -649,7 +649,7 @@ void parseOper(TokenIterator& input, Script& script, Precedence minPrec, Instruc
|
||||
// We made a mistake, the part before the := should be a variable name,
|
||||
// not an expression. Remove that instruction.
|
||||
Instruction& instr = script.getInstructions().back();
|
||||
if (added == 1 && instr.instr != I_GET_VAR) {
|
||||
if (added != 1 || instr.instr != I_GET_VAR) {
|
||||
input.add_error(_("Can only assign to variables"));
|
||||
}
|
||||
script.getInstructions().pop_back();
|
||||
@@ -695,9 +695,9 @@ void parseOper(TokenIterator& input, Script& script, Precedence minPrec, Instruc
|
||||
} else {
|
||||
input.expected(_("name"));
|
||||
}
|
||||
} else if (minPrec <= PREC_FUN && token==_("[")) { // get member by expr
|
||||
} else if (minPrec <= PREC_FUN && token==_("[") && !token.newline) { // get member by expr
|
||||
size_t before = script.getInstructions().size();
|
||||
parseOper(input, script, PREC_ALL);
|
||||
parseOper(input, script, PREC_SET);
|
||||
if (script.getInstructions().size() == before + 1 && script.getInstructions().back().instr == I_PUSH_CONST) {
|
||||
// optimize:
|
||||
// PUSH_CONST x
|
||||
@@ -709,7 +709,7 @@ void parseOper(TokenIterator& input, Script& script, Precedence minPrec, Instruc
|
||||
script.addInstruction(I_BINARY, I_MEMBER);
|
||||
}
|
||||
expectToken(input, _("]"), &token);
|
||||
} else if (minPrec <= PREC_FUN && token==_("(")) {
|
||||
} else if (minPrec <= PREC_FUN && token==_("(") && !token.newline) {
|
||||
// function call, read arguments
|
||||
vector<Variable> arguments;
|
||||
parseCallArguments(input, script, arguments);
|
||||
|
||||
Reference in New Issue
Block a user