Change 'elseif' to 'else if' to better support C++ expectations

This commit is contained in:
Jonathan Turner
2009-07-17 14:16:27 +00:00
parent 689143aba5
commit ac817ff33a
4 changed files with 25 additions and 22 deletions

View File

@@ -531,7 +531,7 @@ namespace chaiscript
cond = dispatchkit::boxed_cast<bool &>(retval); cond = dispatchkit::boxed_cast<bool &>(retval);
} }
catch (const dispatchkit::bad_boxed_cast &) { 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) { if (cond) {
retval = eval_token(ss, node->children[i+2]); retval = eval_token(ss, node->children[i+2]);

View File

@@ -846,7 +846,9 @@ namespace chaiscript
while (has_matches) { while (has_matches) {
while (Eol()); while (Eol());
has_matches = false; has_matches = false;
if (Keyword("elseif", true)) { if (Keyword("else", true)) {
if (Keyword("if")) {
match_stack.back()->text = "else if";
if (!Char('(')) { if (!Char('(')) {
throw Eval_Error("Incomplete 'else if' expression", File_Position(line, col), filename); throw Eval_Error("Incomplete 'else if' expression", File_Position(line, col), filename);
} }
@@ -862,7 +864,7 @@ namespace chaiscript
} }
has_matches = true; has_matches = true;
} }
else if (Keyword("else", true)) { else {
while (Eol()); while (Eol());
if (!Block()) { if (!Block()) {
@@ -871,6 +873,7 @@ namespace chaiscript
has_matches = true; has_matches = true;
} }
} }
}
build_match(Token_Type::If, prev_stack_top); build_match(Token_Type::If, prev_stack_top);
} }