Change 'elseif' to 'else if' to better support C++ expectations
This commit is contained in:
@@ -525,13 +525,13 @@ namespace chaiscript
|
||||
retval = eval_token(ss, node->children[i+1]);
|
||||
cond = true;
|
||||
}
|
||||
else if (node->children[i]->text == "elseif") {
|
||||
else if (node->children[i]->text == "else if") {
|
||||
retval = eval_token(ss, node->children[i+1]);
|
||||
try {
|
||||
cond = dispatchkit::boxed_cast<bool &>(retval);
|
||||
}
|
||||
catch (const dispatchkit::bad_boxed_cast &) {
|
||||
throw Eval_Error("Elseif condition not boolean", node->children[i+1]);
|
||||
throw Eval_Error("'else if' condition not boolean", node->children[i+1]);
|
||||
}
|
||||
if (cond) {
|
||||
retval = eval_token(ss, node->children[i+2]);
|
||||
|
@@ -846,23 +846,25 @@ namespace chaiscript
|
||||
while (has_matches) {
|
||||
while (Eol());
|
||||
has_matches = false;
|
||||
if (Keyword("elseif", true)) {
|
||||
if (Keyword("else", true)) {
|
||||
if (Keyword("if")) {
|
||||
match_stack.back()->text = "else if";
|
||||
if (!Char('(')) {
|
||||
throw Eval_Error("Incomplete 'elseif' expression", File_Position(line, col), filename);
|
||||
throw Eval_Error("Incomplete 'else if' expression", File_Position(line, col), filename);
|
||||
}
|
||||
|
||||
if (!(Expression() && Char(')'))) {
|
||||
throw Eval_Error("Incomplete 'elseif' expression", File_Position(line, col), filename);
|
||||
throw Eval_Error("Incomplete 'else if' expression", File_Position(line, col), filename);
|
||||
}
|
||||
|
||||
while (Eol());
|
||||
|
||||
if (!Block()) {
|
||||
throw Eval_Error("Incomplete 'elseif' block", File_Position(line, col), filename);
|
||||
throw Eval_Error("Incomplete 'else if' block", File_Position(line, col), filename);
|
||||
}
|
||||
has_matches = true;
|
||||
}
|
||||
else if (Keyword("else", true)) {
|
||||
else {
|
||||
while (Eol());
|
||||
|
||||
if (!Block()) {
|
||||
@@ -871,6 +873,7 @@ namespace chaiscript
|
||||
has_matches = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
build_match(Token_Type::If, prev_stack_top);
|
||||
}
|
||||
|
@@ -2,10 +2,10 @@ var i = 3
|
||||
if (i == 2) {
|
||||
print("2")
|
||||
}
|
||||
elseif (i == 4) {
|
||||
else if (i == 4) {
|
||||
print("4")
|
||||
}
|
||||
elseif (i == 3) {
|
||||
else if (i == 3) {
|
||||
print("3")
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,7 @@ var i = 3
|
||||
if (i == 2) {
|
||||
print("2")
|
||||
}
|
||||
elseif (i == 4) {
|
||||
else if (i == 4) {
|
||||
print("4")
|
||||
}
|
||||
else {
|
||||
|
Reference in New Issue
Block a user