aboutsummaryrefslogtreecommitdiff
path: root/src/lang/interpreter.clj
diff options
context:
space:
mode:
authorEduardo Julian2014-11-27 02:03:19 -0400
committerEduardo Julian2014-11-27 02:03:19 -0400
commit1a2b6841604558266f2cbf5bcf1373ea257183c9 (patch)
treeda5cbb9a4c330a6790a06f0e081784807a496381 /src/lang/interpreter.clj
parenta96bb768a5f02c2dc9c0de1e50dc14376d2e7f35 (diff)
+ Added some very basic pattern-matching with destructuring.
Diffstat (limited to 'src/lang/interpreter.clj')
-rw-r--r--src/lang/interpreter.clj21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/lang/interpreter.clj b/src/lang/interpreter.clj
index 19fe71106..ba370ac2e 100644
--- a/src/lang/interpreter.clj
+++ b/src/lang/interpreter.clj
@@ -63,7 +63,8 @@
;; (prn "output#" output#)
output#)
_#
- (fail* (str "Unknown syntax: " (pr-str ~'*token*))))))))
+ (do ;; (println "Unknown syntax: " (pr-str ~'*token*))
+ (fail* (str "Unknown syntax: " (pr-str ~'*token*)))))))))
(defeval eval-ident
[::&parser/ident ?ident]
@@ -103,8 +104,11 @@
[::&parser/fn-call ?fn ?args]
(exec [state &util/get-state
=fn (apply-m eval-form (wrap-in state ?fn))
- =args (map-m (fn [arg] (apply-m eval-form (wrap arg)))
- ?args)]
+ ;; :let [_ (prn '=fn ?fn =fn)]
+ =args (map-m (fn [arg] (apply-m eval-form (wrap-in state arg)))
+ ?args)
+ ;; :let [_ (prn '=args =args)]
+ ]
(fn-call =fn =args)))
(def eval-form
@@ -133,13 +137,14 @@
(comment
(let [source-code (slurp "src/example/test1.lang")
tokens (&lexer/lex source-code)
- _ (prn 'tokens tokens)
+ ;; _ (prn 'tokens tokens)
syntax (&parser/parse tokens)
- _ (prn 'syntax syntax)]
+ ;; _ (prn 'syntax syntax)
+ ]
(eval (update-in +state+ [:forms] concat syntax)))
-
+
;; (clojure.core/fn [base exp] (fold * 1 (repeat exp base)))
@@ -163,5 +168,7 @@
;; (def (** base exp)
;; (fold * 1 (repeat exp base)))
-
+ ;; Syntax for single-line comments ##
+ ;; Syntax for multi-line comments #( YOLO )#
+ ;; Syntax for chars: #"a"
)