Fixed prefix operator precedence bug. Added collate(?), zip_with, and zip

This commit is contained in:
Jonathan Turner
2009-07-03 12:13:29 +00:00
parent ca8337a41d
commit 9c7f63e8b2
2 changed files with 58 additions and 41 deletions

View File

@@ -1044,7 +1044,7 @@ namespace chaiscript
if (Symbol("-")) {
retval = true;
if (!Additive()) {
if (!Dot_Access()) {
throw Parse_Error("Incomplete negation expression", File_Position(line, col), filename);
}
@@ -1053,7 +1053,7 @@ namespace chaiscript
else if (Symbol("!")) {
retval = true;
if (!Expression()) {
if (!Dot_Access()) {
throw Parse_Error("Incomplete '!' expression", File_Position(line, col), filename);
}
@@ -1062,7 +1062,7 @@ namespace chaiscript
if (Symbol("++", true)) {
retval = true;
if (!Expression()) {
if (!Dot_Access()) {
throw Parse_Error("Incomplete '++' expression", File_Position(line, col), filename);
}
@@ -1071,7 +1071,7 @@ namespace chaiscript
else if (Symbol("--", true)) {
retval = true;
if (!Expression()) {
if (!Dot_Access()) {
throw Parse_Error("Incomplete '--' expression", File_Position(line, col), filename);
}

View File

@@ -58,6 +58,23 @@ def join(container, delim) { \n\
} \n\
} \n\
retval \n\
}";
} \n\
def collate(x, y) { \n\
[x, y] \n\
} \n\
def zip_with(f, x, y) : call_exists(range, x) && call_exists(range, y) { \n\
var r_x = range(x); \n\
var r_y = range(y); \n\
var retval = Vector(); \n\
while (!r_x.empty() && !r_y.empty()) { \n\
retval.push_back(f(r_x.front(), r_y.front())); \n\
r_x.pop_front(); \n\
r_y.pop_front(); \n\
} \n\
retval \n\
} \n\
def zip(x, y) { \n\
zip_with(collate, x, y) \n\
}\n";
#endif /* CHAISCRIPT_PRELUDE_HPP_ */