Added prefix increment and decrement. Debugging: off

This commit is contained in:
Jonathan Turner
2009-06-08 15:49:44 +00:00
parent b76b1b8c21
commit 23c1908917
3 changed files with 17 additions and 3 deletions

View File

@@ -107,6 +107,18 @@ P1 &subtractsequal(P1 &p1, const P2 &p2)
return (p1 -= p2); return (p1 -= p2);
} }
template<typename P1>
P1 &prefixincrement(P1 &p1)
{
return (++p1);
}
template<typename P1>
P1 &prefixdecrement(P1 &p1)
{
return (--p1);
}
//Add canonical forms of operators //Add canonical forms of operators
template<typename T> template<typename T>
void add_oper_equals(BoxedCPP_System &s) void add_oper_equals(BoxedCPP_System &s)
@@ -210,6 +222,8 @@ void add_opers_arithmetic_overload(BoxedCPP_System &s)
register_function(s, &dividesequal<T, R>, "/="); register_function(s, &dividesequal<T, R>, "/=");
register_function(s, &subtractsequal<T, R>, "-="); register_function(s, &subtractsequal<T, R>, "-=");
register_function(s, &addsequal<T, R>, "+="); register_function(s, &addsequal<T, R>, "+=");
register_function(s, &prefixincrement<T>, "++");
register_function(s, &prefixdecrement<T>, "--");
} }
template<typename T> template<typename T>

View File

@@ -1,4 +1,4 @@
for (var i = 0; i < 10; i += 1) { for (var i = 0; i < 10; ++i) {
print(i) print(i)
} }
@@ -8,6 +8,6 @@ for (i = 10; i >= 0; i -= 2) {
i = 0 i = 0
for (; i < 5; i += 1) { for (; i < 5; ++i) {
print(i) print(i)
} }

View File

@@ -554,7 +554,7 @@ TokenPtr parse(Rule &rule, std::vector<TokenPtr> &tokens, const char *filename)
std::pair<Token_Iterator, bool> results = rule(iter, end, parent); std::pair<Token_Iterator, bool> results = rule(iter, end, parent);
if (results.second) { if (results.second) {
debug_print(parent, ""); //debug_print(parent, "");
return parent; return parent;
} }
else { else {