allowing foo-bar
This commit is contained in:
parent
b648aa858d
commit
821ca442aa
@ -159,8 +159,8 @@ class HyASTCompiler(object):
|
|||||||
@builds(">=")
|
@builds(">=")
|
||||||
@builds("is")
|
@builds("is")
|
||||||
@builds("in")
|
@builds("in")
|
||||||
@builds("is-not")
|
@builds("is_not")
|
||||||
@builds("not-in")
|
@builds("not_in")
|
||||||
def compile_compare_op_expression(self, expression):
|
def compile_compare_op_expression(self, expression):
|
||||||
ops = {"=": ast.Eq,
|
ops = {"=": ast.Eq,
|
||||||
"!=": ast.NotEq,
|
"!=": ast.NotEq,
|
||||||
@ -169,9 +169,9 @@ class HyASTCompiler(object):
|
|||||||
">": ast.Gt,
|
">": ast.Gt,
|
||||||
">=": ast.GtE,
|
">=": ast.GtE,
|
||||||
"is": ast.Is,
|
"is": ast.Is,
|
||||||
"is-not": ast.IsNot,
|
"is_not": ast.IsNot,
|
||||||
"in": ast.In,
|
"in": ast.In,
|
||||||
"not-in": ast.NotIn}
|
"not_in": ast.NotIn}
|
||||||
|
|
||||||
inv = expression.pop(0)
|
inv = expression.pop(0)
|
||||||
op = ops[inv]
|
op = ops[inv]
|
||||||
|
@ -60,6 +60,9 @@ def _resolve_atom(obj):
|
|||||||
if obj in table:
|
if obj in table:
|
||||||
return HySymbol(table[obj])
|
return HySymbol(table[obj])
|
||||||
|
|
||||||
|
if "-" in obj and obj != "-":
|
||||||
|
obj = obj.replace("-", "_")
|
||||||
|
|
||||||
return HySymbol(obj)
|
return HySymbol(obj)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
(defn test_lists []
|
(defn test-lists []
|
||||||
"NATIVE: test lists work right"
|
"NATIVE: test lists work right"
|
||||||
(assert (= [1 2 3 4] (+ [1 2] [3 4]))))
|
(assert (= [1 2 3 4] (+ [1 2] [3 4]))))
|
||||||
|
|
||||||
|
|
||||||
(defn test_for_loop []
|
(defn test-for-loop []
|
||||||
"NATIVE: test for loops?"
|
"NATIVE: test for loops?"
|
||||||
(def count 0)
|
(def count 0)
|
||||||
(for [x [1 2 3 4 5]]
|
(for [x [1 2 3 4 5]]
|
||||||
@ -14,18 +14,18 @@
|
|||||||
(assert (= count 15)))
|
(assert (= count 15)))
|
||||||
|
|
||||||
|
|
||||||
(defn test_in []
|
(defn test-in []
|
||||||
"NATIVE: test in"
|
"NATIVE: test in"
|
||||||
(assert (in "a" ["a" "b" "c" "d"]))
|
(assert (in "a" ["a" "b" "c" "d"]))
|
||||||
(assert (not-in "f" ["a" "b" "c" "d"])))
|
(assert (not-in "f" ["a" "b" "c" "d"])))
|
||||||
|
|
||||||
|
|
||||||
(defn test_noteq []
|
(defn test-noteq []
|
||||||
"NATIVE: not eq"
|
"NATIVE: not eq"
|
||||||
(assert (!= 2 3)))
|
(assert (!= 2 3)))
|
||||||
|
|
||||||
|
|
||||||
(defn test_numops []
|
(defn test-numops []
|
||||||
"NATIVE: test numpos"
|
"NATIVE: test numpos"
|
||||||
(assert (> 5 4 3 2 1))
|
(assert (> 5 4 3 2 1))
|
||||||
(assert (< 1 2 3 4 5))
|
(assert (< 1 2 3 4 5))
|
||||||
@ -33,21 +33,21 @@
|
|||||||
(assert (>= 5 5 5 5 )))
|
(assert (>= 5 5 5 5 )))
|
||||||
|
|
||||||
|
|
||||||
(defn test_is []
|
(defn test-is []
|
||||||
"NATIVE: test is can deal with None"
|
"NATIVE: test is can deal with None"
|
||||||
(def a null)
|
(def a null)
|
||||||
(assert (is a null))
|
(assert (is a null))
|
||||||
(assert (is-not a "b")))
|
(assert (is-not a "b")))
|
||||||
|
|
||||||
|
|
||||||
(defn test_branching []
|
(defn test-branching []
|
||||||
"NATIVE: test if branching"
|
"NATIVE: test if branching"
|
||||||
(if true
|
(if true
|
||||||
(assert (= 1 1))
|
(assert (= 1 1))
|
||||||
(assert (= 2 1))))
|
(assert (= 2 1))))
|
||||||
|
|
||||||
|
|
||||||
(defn test_branching_with_do []
|
(defn test-branching-with-do []
|
||||||
"NATIVE: test if branching (multiline)"
|
"NATIVE: test if branching (multiline)"
|
||||||
(if false
|
(if false
|
||||||
(assert (= 2 1))
|
(assert (= 2 1))
|
||||||
@ -57,20 +57,20 @@
|
|||||||
(assert (= 1 1)))))
|
(assert (= 1 1)))))
|
||||||
|
|
||||||
|
|
||||||
(defn test_cond []
|
(defn test-cond []
|
||||||
"NATIVE: test if cond sorta works."
|
"NATIVE: test if cond sorta works."
|
||||||
(cond
|
(cond
|
||||||
(= 1 2) (assert (= true false))
|
(= 1 2) (assert (= true false))
|
||||||
(is null null) (assert (= true true))))
|
(is null null) (assert (= true true))))
|
||||||
|
|
||||||
|
|
||||||
(defn test_index []
|
(defn test-index []
|
||||||
"NATIVE: Test that dict access works"
|
"NATIVE: Test that dict access works"
|
||||||
(assert (get {"one" "two"} "one") "two")
|
(assert (get {"one" "two"} "one") "two")
|
||||||
(assert (= (get [1 2 3 4 5] 1) 2)))
|
(assert (= (get [1 2 3 4 5] 1) 2)))
|
||||||
|
|
||||||
|
|
||||||
(defn test_lambda []
|
(defn test-lambda []
|
||||||
"NATIVE: test lambda operator"
|
"NATIVE: test lambda operator"
|
||||||
(def square (lambda [x] (* x x)))
|
(def square (lambda [x] (* x x)))
|
||||||
(assert (= 4 (square 2))))
|
(assert (= 4 (square 2))))
|
||||||
|
Loading…
Reference in New Issue
Block a user