adding in yielding
This commit is contained in:
parent
4172ca2db7
commit
3c288519ac
@ -204,6 +204,18 @@ class HyASTCompiler(object):
|
||||
kw_defaults=[]),
|
||||
body=self.compile(body))
|
||||
|
||||
@builds("pass")
|
||||
def compile_pass_expression(self, expr):
|
||||
return ast.Pass(lineno=expr.start_line, col_offset=expr.start_column)
|
||||
|
||||
@builds("yield")
|
||||
def compile_yield_expression(self, expr):
|
||||
expr.pop(0)
|
||||
return ast.Yield(
|
||||
value=self.compile(expr.pop(0)),
|
||||
lineno=expr.start_line,
|
||||
col_offset=expr.start_column)
|
||||
|
||||
@builds("import")
|
||||
def compile_import_expression(self, expr):
|
||||
expr.pop(0) # index
|
||||
|
@ -151,3 +151,17 @@
|
||||
(def vals {"one" "two"})
|
||||
(assoc vals "two" "three")
|
||||
(assert (= (get vals "two") "three")))
|
||||
|
||||
|
||||
(defn test-pass []
|
||||
"NATIVE: Test pass worksish"
|
||||
(if true (pass) (pass))
|
||||
(assert (= 1 1)))
|
||||
|
||||
|
||||
(defn test-yield []
|
||||
"NATIVE: test yielding"
|
||||
(defn gen [] (for [x [1 2 3 4]] (yield x)))
|
||||
(def ret 0)
|
||||
(for [y (gen)] (def ret (+ ret y)))
|
||||
(assert (= ret 10)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user