aboutsummaryrefslogtreecommitdiff
path: root/luxc
diff options
context:
space:
mode:
authorEduardo Julian2018-01-28 12:55:27 -0400
committerEduardo Julian2018-01-28 12:55:27 -0400
commit04ec239d095b0e1f62a9f1261587b5bfbc6fb457 (patch)
tree819ef38ab8786f3c7f8aa28e188146aeb7317646 /luxc
parentfb14b2eb168377820b3af399c44dc2c4b6973f5a (diff)
- Fixed some parsing errors affecting JVM interface analysis/compilation.
Diffstat (limited to '')
-rw-r--r--luxc/src/lux/analyser/parser.clj21
-rw-r--r--luxc/src/lux/reader.clj14
2 files changed, 29 insertions, 6 deletions
diff --git a/luxc/src/lux/analyser/parser.clj b/luxc/src/lux/analyser/parser.clj
index 04172fcf9..90eb23164 100644
--- a/luxc/src/lux/analyser/parser.clj
+++ b/luxc/src/lux/analyser/parser.clj
@@ -40,6 +40,10 @@
(|do [[_ _ =name] (&reader/read-regex #"^([a-zA-Z0-9_\.]+)")]
(return =name)))
+(def ^:private parse-name?
+ (|do [[_ _ =name] (&reader/read-regex? #"^([a-zA-Z0-9_\.]+)")]
+ (return =name)))
+
(def ^:private parse-ident
(|do [[_ _ =name] (&reader/read-regex &lexer/+ident-re+)]
(return =name)))
@@ -164,12 +168,17 @@
(return (&/T [=arg-name =gclass])))))
(def ^:private parse-gvars
- (|do [=head parse-name
- [_ _ ?] (&reader/read-text? " ")]
- (if ?
- (|do [=tail parse-gvars]
- (return (&/$Cons =head =tail)))
- (return (&/|list =head)))))
+ (|do [?=head parse-name?]
+ (|case ?=head
+ (&/$Some =head)
+ (|do [[_ _ ?] (&reader/read-text? " ")]
+ (if ?
+ (|do [=tail parse-gvars]
+ (return (&/$Cons =head =tail)))
+ (return (&/|list =head))))
+
+ (&/$None)
+ (return (&/|list)))))
(def ^:private parse-method-decl
(with-parens
diff --git a/luxc/src/lux/reader.clj b/luxc/src/lux/reader.clj
index 6fea32c16..5f4aa8afe 100644
--- a/luxc/src/lux/reader.clj
+++ b/luxc/src/lux/reader.clj
@@ -63,6 +63,20 @@
(&/T [(&/T [file-name line-num column-num*]) line]))))
($No (str "[Reader Error] Pattern failed: " regex))))))
+(defn read-regex? [regex]
+ "(-> Regex (Reader (Maybe Text)))"
+ (with-line
+ (fn [file-name line-num column-num ^String line]
+ (if-let [^String match (re-find! regex column-num line)]
+ (let [match-length (.length match)
+ column-num* (+ column-num match-length)]
+ (if (= column-num* (.length line))
+ ($Done (&/T [(&/T [file-name line-num column-num]) true (&/$Some match)]))
+ ($Yes (&/T [(&/T [file-name line-num column-num]) false (&/$Some match)])
+ (&/T [(&/T [file-name line-num column-num*]) line]))))
+ ($Yes (&/T [(&/T [file-name line-num column-num]) false &/$None])
+ (&/T [(&/T [file-name line-num column-num]) line]))))))
+
(defn read-regex+ [regex]
(with-lines
(fn [reader]