Added function guards

This commit is contained in:
Jonathan Turner
2009-07-02 17:22:12 +00:00
parent f6342ef2a8
commit 6d4f2146b8
2 changed files with 38 additions and 9 deletions

View File

@@ -682,6 +682,13 @@ namespace chaiscript
while (Eol());
if (Char(':')) {
if (!Expression()) {
throw Parse_Error("Missing guard expression for function", File_Position(line, col), filename);
}
}
while (Eol());
if (!Block()) {
throw Parse_Error("Incomplete function definition", File_Position(line, col), filename);
}
@@ -870,7 +877,7 @@ namespace chaiscript
std::string::iterator prev_pos = input_pos;
unsigned int prev_stack_top = match_stack.size();
if (Id(true)) {
if (Id(true) || Id_Literal()) {
retval = true;
bool has_more = true;
@@ -1021,7 +1028,7 @@ namespace chaiscript
bool Value() {
if (Var_Decl() || Lambda() || Id_Fun_Array() || Num(true) || Prefix() || Quoted_String(true) || Single_Quoted_String(true) ||
Paren_Expression() || Inline_Container() || Id_Literal()) {
Paren_Expression() || Inline_Container()) {
return true;
}
else {