aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEduardo Julian2015-08-29 23:17:27 -0400
committerEduardo Julian2015-08-29 23:17:27 -0400
commit196f56b83ed357169efb75b864f81f26c10641f1 (patch)
tree33a17c9f3e2058e14b08f10ab700990447b510ac /src
parent253d5a4a3f7ef5d42c467733e394a28d18a4d9b3 (diff)
- Remove the (unnec) "All'" and "->'" macros.
- Improved the "struct" macro so that (once again) it doesn't ask for the prefixes of the members. - Added tests for the lux.reader namespace.
Diffstat (limited to 'src')
-rw-r--r--src/lux/compiler.clj2
-rw-r--r--src/lux/reader.clj27
2 files changed, 14 insertions, 15 deletions
diff --git a/src/lux/compiler.clj b/src/lux/compiler.clj
index b8ffa825f..694c6bfc4 100644
--- a/src/lux/compiler.clj
+++ b/src/lux/compiler.clj
@@ -421,7 +421,7 @@
(fn [state]
(|case ((&/with-writer =class
(&/exhaust% compiler-step))
- (&/set$ &/$source (&reader/from file-name file-content) state))
+ (&/set$ &/$source (&reader/from name file-content) state))
(&/$Right ?state _)
(&/run-state (|do [defs &a-module/defs
imports &a-module/imports
diff --git a/src/lux/reader.clj b/src/lux/reader.clj
index 0fcb5097b..af6c1ecc3 100644
--- a/src/lux/reader.clj
+++ b/src/lux/reader.clj
@@ -48,7 +48,6 @@
(fail* msg)
)))
-;; [Exports]
(defn ^:private re-find! [^java.util.regex.Pattern regex column ^String line]
(let [matcher (doto (.matcher regex line)
(.region column (.length line))
@@ -72,6 +71,7 @@
(.group matcher 1)
(.group matcher 2)))))
+;; [Exports]
(defn read-regex [regex]
(with-line
(fn [file-name line-num column-num ^String line]
@@ -125,7 +125,6 @@
(defn read-text [^String text]
(with-line
(fn [file-name line-num column-num ^String line]
- ;; (prn 'read-text [file-name line-num column-num text line])
(if (.startsWith line text column-num)
(let [match-length (.length text)
column-num* (+ column-num match-length)]
@@ -135,15 +134,15 @@
(&/T (&/T file-name line-num column-num*) line)))))
(&/V $No (str "[Reader Error] Text failed: " text))))))
-(def ^:private ^String +source-dir+ "input/")
-(defn from [^String file-name ^String file-content]
- (let [lines (&/->list (string/split-lines file-content))
- file-name (.substring file-name (.length +source-dir+))]
- (&/|map (fn [line+line-num]
- (|let [[line-num line] line+line-num]
- (&/T (&/T file-name (inc line-num) 0)
- line)))
- (&/|filter (fn [line+line-num]
- (|let [[line-num line] line+line-num]
- (not= "" line)))
- (&/enumerate lines)))))
+(defn from [^String name ^String source-code]
+ (->> source-code
+ (string/split-lines)
+ (&/->list)
+ (&/enumerate)
+ (&/|filter (fn [line+line-num]
+ (|let [[line-num line] line+line-num]
+ (not= "" line))))
+ (&/|map (fn [line+line-num]
+ (|let [[line-num line] line+line-num]
+ (&/T (&/T name (inc line-num) 0)
+ line))))))