added MOD operator, converting operands to ints
git-svn-id: svn://anubis/fart/trunk@351 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
c4d8327665
commit
fc33024b28
@ -74,6 +74,9 @@ NodeRef BinOpNode::evaluate()
|
||||
case '-':
|
||||
r = o - t;
|
||||
break;
|
||||
case '%':
|
||||
r = (int) o % (int) t;
|
||||
break;
|
||||
default:
|
||||
cerr << "Error: BinOpNode created with op '" << m_op << "'" << endl;
|
||||
exit(-3);
|
||||
@ -162,10 +165,6 @@ NodeRef ForNode::evaluate()
|
||||
}
|
||||
}
|
||||
|
||||
/* clear out all child nodes so that evaluateChildren() doesn't
|
||||
* attempt to evaluate them */
|
||||
m_children.clear();
|
||||
|
||||
return eval;
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ refptr<Scope> parser_scope;
|
||||
|
||||
%right ASSIGN
|
||||
%left PLUS MINUS
|
||||
%left TIMES DIVIDE
|
||||
%left TIMES DIVIDE MOD
|
||||
%left UMINUS
|
||||
|
||||
%%
|
||||
@ -587,6 +587,7 @@ vector3: LESS expression COMMA expression COMMA expression GREATER {
|
||||
expression: term { $$ = $1; }
|
||||
| expression TIMES term { $$ = new BinOpNode('*', $1, $3); }
|
||||
| expression DIVIDE term { $$ = new BinOpNode('/', $1, $3); }
|
||||
| expression MOD term { $$ = new BinOpNode('%', $1, $3); }
|
||||
| MINUS expression %prec UMINUS {
|
||||
$$ = new BinOpNode('-', new NumberNode(0.0), $2);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user