Fix to disallow mixing inline map and array elements

This commit is contained in:
Jonathan Turner
2010-10-02 23:39:17 +00:00
parent 3ab91356e5
commit 5a92146d28

View File

@@ -1098,6 +1098,19 @@ namespace chaiscript
}
build_match(AST_NodePtr(new Arg_List_AST_Node()), prev_stack_top);
}
else if (Operator()) {
retval = true;
while (Eol()) {}
if (Char(',')) {
do {
while (Eol()) {}
if (!Operator()) {
throw Eval_Error("Unexpected value in container", File_Position(line, col), filename);
}
} while (retval && Char(','));
}
build_match(AST_NodePtr(new Arg_List_AST_Node()), prev_stack_top);
}
return retval;
@@ -1745,19 +1758,26 @@ namespace chaiscript
bool Map_Pair() {
bool retval = false;
int prev_stack_top = match_stack.size();
size_t prev_stack_top = match_stack.size();
std::string::const_iterator prev_pos = input_pos;
int prev_col = col;
if (Operator()) {
retval = true;
if (Symbol(":")) {
do {
if (!Operator()) {
throw Eval_Error("Incomplete map pair", File_Position(line, col), filename);
}
} while (retval && Symbol(":"));
retval = true;
if (!Operator()) {
throw Eval_Error("Incomplete map pair", File_Position(line, col), filename);
}
build_match(AST_NodePtr(new Map_Pair_AST_Node()), prev_stack_top);
}
else {
input_pos = prev_pos;
col = prev_col;
while (prev_stack_top != match_stack.size()) {
match_stack.pop_back();
}
}
}
return retval;