aboutsummaryrefslogtreecommitdiff
path: root/luxc/src
diff options
context:
space:
mode:
authorEduardo Julian2018-08-20 23:23:02 -0400
committerEduardo Julian2018-08-20 23:23:02 -0400
commit9ccc8ea44ebe4f9a3d40c8e94b55f77c0d815099 (patch)
tree32de969d2e9567027b254718eab43c3ca792f6a9 /luxc/src
parenta1944a9d561e76b02717673647b87704118c03a6 (diff)
Some refactoring.
Diffstat (limited to '')
-rw-r--r--luxc/src/lux/lexer.clj7
-rw-r--r--luxc/src/lux/reader.clj15
2 files changed, 13 insertions, 9 deletions
diff --git a/luxc/src/lux/lexer.clj b/luxc/src/lux/lexer.clj
index f74e14dfd..0a09c0619 100644
--- a/luxc/src/lux/lexer.clj
+++ b/luxc/src/lux/lexer.clj
@@ -26,8 +26,9 @@
)
;; [Utils]
-(defn ^:private clean-line [^String raw-line]
+(defn- clean-line
"(-> Text Text)"
+ [^String raw-line]
(let [line-length (.length raw-line)
buffer (new StringBuffer line-length)]
(loop [idx 0]
@@ -61,7 +62,7 @@
(recur (+ 1 idx)))))
(.toString buffer)))))
-(defn ^:private lex-text-body [multi-line? offset]
+(defn- lex-text-body [multi-line? offset]
(|do [[_ eol? ^String pre-quotes**] (&reader/read-regex #"^([^\"]*)")
^String pre-quotes* (if multi-line?
(|do [:let [empty-line? (and eol? (= "" pre-quotes**))]
@@ -110,7 +111,7 @@
[meta _ comment] (&reader/read-regex #"^(.*)$")]
(return (&/T [meta ($Comment comment)]))))
-(defn ^:private lex-multi-line-comment [_]
+(defn- lex-multi-line-comment [_]
(|do [_ (&reader/read-text "#(")
[meta comment] (&/try-all% (&/|list (|do [[meta comment] (&reader/read-regex+ #"(?is)^(?!#\()((?!\)#).)*")]
(return (&/T [meta comment])))
diff --git a/luxc/src/lux/reader.clj b/luxc/src/lux/reader.clj
index 5f4aa8afe..14914cc2e 100644
--- a/luxc/src/lux/reader.clj
+++ b/luxc/src/lux/reader.clj
@@ -11,7 +11,7 @@
("Yes" 2))
;; [Utils]
-(defn ^:private with-line [body]
+(defn- with-line [body]
(fn [state]
(|case (&/get$ &/$source state)
(&/$Nil)
@@ -32,7 +32,7 @@
output))
)))
-(defn ^:private with-lines [body]
+(defn- with-lines [body]
(fn [state]
(|case (body (&/get$ &/$source state))
(&/$Right reader* match)
@@ -43,7 +43,7 @@
((&/fail-with-loc msg) state)
)))
-(defn ^:private re-find! [^java.util.regex.Pattern regex column ^String line]
+(defn- re-find! [^java.util.regex.Pattern regex column ^String line]
(let [matcher (doto (.matcher regex line)
(.region column (.length line))
(.useAnchoringBounds true))]
@@ -63,8 +63,9 @@
(&/T [(&/T [file-name line-num column-num*]) line]))))
($No (str "[Reader Error] Pattern failed: " regex))))))
-(defn read-regex? [regex]
+(defn read-regex?
"(-> Regex (Reader (Maybe Text)))"
+ [regex]
(with-line
(fn [file-name line-num column-num ^String line]
(if-let [^String match (re-find! regex column-num line)]
@@ -101,8 +102,9 @@
(&/T [(&/T [file-name line-num column-num]) prefix*])]))))
(&/$Left (str "[Reader Error] Pattern failed: " regex))))))))
-(defn read-text [^String text]
+(defn read-text
"(-> Text (Reader Text))"
+ [^String text]
(with-line
(fn [file-name line-num column-num ^String line]
(if (.startsWith line text column-num)
@@ -114,8 +116,9 @@
(&/T [(&/T [file-name line-num column-num*]) line]))))
($No (str "[Reader Error] Text failed: " text))))))
-(defn read-text? [^String text]
+(defn read-text?
"(-> Text (Reader (Maybe Text)))"
+ [^String text]
(with-line
(fn [file-name line-num column-num ^String line]
(if (.startsWith line text column-num)