add mod operator
This commit is contained in:
parent
a0ff144686
commit
a94831beac
@ -341,6 +341,7 @@ class HyASTCompiler(object):
|
|||||||
col_offset=e.start_column)
|
col_offset=e.start_column)
|
||||||
|
|
||||||
@builds("+")
|
@builds("+")
|
||||||
|
@builds("%")
|
||||||
@builds("-")
|
@builds("-")
|
||||||
@builds("/")
|
@builds("/")
|
||||||
@builds("*")
|
@builds("*")
|
||||||
@ -352,7 +353,8 @@ class HyASTCompiler(object):
|
|||||||
ops = {"+": ast.Add,
|
ops = {"+": ast.Add,
|
||||||
"/": ast.Div,
|
"/": ast.Div,
|
||||||
"*": ast.Mult,
|
"*": ast.Mult,
|
||||||
"-": ast.Sub}
|
"-": ast.Sub,
|
||||||
|
"%": ast.Mod}
|
||||||
|
|
||||||
inv = expression.pop(0)
|
inv = expression.pop(0)
|
||||||
op = ops[inv]
|
op = ops[inv]
|
||||||
|
@ -28,3 +28,7 @@
|
|||||||
(def test_div (fn []
|
(def test_div (fn []
|
||||||
"NATIVE: Test division"
|
"NATIVE: Test division"
|
||||||
(assert (= 25 (/ 100 2 2)))))
|
(assert (= 25 (/ 100 2 2)))))
|
||||||
|
|
||||||
|
(defn test-modulo []
|
||||||
|
"NATIVE: test mod"
|
||||||
|
(assert (= (% 10 2) 0)))
|
||||||
|
Loading…
Reference in New Issue
Block a user