Add modulus operator to parser

This commit is contained in:
Jonathan Turner
2009-07-04 02:17:50 +00:00
parent 310dd030ac
commit b2a99d4105
2 changed files with 3 additions and 3 deletions

View File

@@ -1132,12 +1132,12 @@ namespace chaiscript
if (Dot_Access()) { if (Dot_Access()) {
retval = true; retval = true;
if (Symbol("*", true) || Symbol("/", true)) { if (Symbol("*", true) || Symbol("/", true) || Symbol("%", true)) {
do { do {
if (!Dot_Access()) { if (!Dot_Access()) {
throw Parse_Error("Incomplete math expression", File_Position(line, col), filename); throw Parse_Error("Incomplete math expression", File_Position(line, col), filename);
} }
} while (retval && (Symbol("*", true) || Symbol("/", true))); } while (retval && (Symbol("*", true) || Symbol("/", true) || Symbol("%", true)));
build_match(Token_Type::Multiplicative, prev_stack_top); build_match(Token_Type::Multiplicative, prev_stack_top);
} }

View File

@@ -8,7 +8,7 @@ const char *chaiscript_prelude = " \
def to_string(x) : call_exists(first, x) && call_exists(second, x) { \n\ def to_string(x) : call_exists(first, x) && call_exists(second, x) { \n\
\"<\" + x.first.to_string() + \", \" + x.second.to_string() + \">\"\n\ \"<\" + x.first.to_string() + \", \" + x.second.to_string() + \">\"\n\
}\n\ }\n\
def to_string(x) : !is_type(\"string\", x) && call_exists(range, x) { \n\ def to_string(x) : call_exists(range, x) && !is_type(\"string\", x){ \n\
\"[\" + x.join(\", \") + \"]\"\n\ \"[\" + x.join(\", \") + \"]\"\n\
}\n\ }\n\
def to_string(x) { \n\ def to_string(x) { \n\