diff options
author | Eduardo Julian | 2014-11-29 00:03:32 -0400 |
---|---|---|
committer | Eduardo Julian | 2014-11-29 00:03:32 -0400 |
commit | 71b63cbbb858b85dd4850c4aa174cf7ec509b11c (patch) | |
tree | b1c462586b850a83f8dcd529e8216613b45c8ab7 /src/lang/compiler.clj | |
parent | 1570e819a875ac0e7f80857f0793784984db687d (diff) |
+ Added floats.
+ Added def for constants.
Diffstat (limited to '')
-rw-r--r-- | src/lang/compiler.clj | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/lang/compiler.clj b/src/lang/compiler.clj index f189e8d25..74e0ba46e 100644 --- a/src/lang/compiler.clj +++ b/src/lang/compiler.clj @@ -51,6 +51,10 @@ [::&parser/int ?int] (return ?int)) +(defcompiler compile-float + [::&parser/float ?float] + (return ?float)) + (defcompiler compile-ident [::&parser/ident ?name] (return (symbol ?name))) @@ -106,8 +110,8 @@ (defcompiler compile-def [::&parser/def ?form ?body] (match ?form - [::&parser/fn-call ?name ?args] - (exec [:let [=name (symbol (unwrap-ident ?name)) + [::&parser/fn-call [::&parser/ident ?name] ?args] + (exec [:let [=name (symbol ?name) =args (map (comp symbol unwrap-ident) ?args) fn-env (into {} (for [a =args] [a nil]))] =body (apply-m compile-form (wrap* fn-env ?body)) @@ -118,7 +122,10 @@ `(fn ~=name ~?arg ~?body)) ;; _ (prn 'fn-def fn-def) ]] - (return fn-def)))) + (return fn-def)) + + [::&parser/ident ?name] + (apply-m compile-form (wrap ?body)))) (defcompiler compile-defdata [::&parser/defdata ?form ?cases] @@ -135,6 +142,7 @@ (def compile-form (try-all-m [compile-int + compile-float compile-ident compile-tuple compile-tagged |