diff options
Diffstat (limited to '')
-rw-r--r-- | src/lux/analyser.clj | 22 | ||||
-rw-r--r-- | src/lux/analyser/lux.clj | 16 | ||||
-rw-r--r-- | src/lux/analyser/module.clj | 24 | ||||
-rw-r--r-- | src/lux/host.clj | 8 | ||||
-rw-r--r-- | src/lux/lexer.clj | 13 | ||||
-rw-r--r-- | src/lux/reader.clj | 2 | ||||
-rw-r--r-- | src/lux/type.clj | 2 |
7 files changed, 36 insertions, 51 deletions
diff --git a/src/lux/analyser.clj b/src/lux/analyser.clj index 31b665c49..f3292ad49 100644 --- a/src/lux/analyser.clj +++ b/src/lux/analyser.clj @@ -232,35 +232,35 @@ (&&host/analyse-jvm-new analyse ?class ?classes ?args) [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ["" "jvm-getstatic"]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?class]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;Text" ?field]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ["" ?class]]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ["" ?field]]]] ["lux;Nil" _]]]]]]]]]]] (&&host/analyse-jvm-getstatic analyse ?class ?field) [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ["" "jvm-getfield"]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?class]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;Text" ?field]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ["" ?class]]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ["" ?field]]]] ["lux;Cons" [?object ["lux;Nil" _]]]]]]]]]]]]] (&&host/analyse-jvm-getfield analyse ?class ?field ?object) [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ["" "jvm-putstatic"]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?class]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;Text" ?field]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ["" ?class]]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ["" ?field]]]] ["lux;Cons" [?value ["lux;Nil" _]]]]]]]]]]]]] (&&host/analyse-jvm-putstatic analyse ?class ?field ?value) [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ["" "jvm-putfield"]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?class]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;Text" ?field]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ["" ?class]]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ["" ?field]]]] ["lux;Cons" [?object ["lux;Cons" [?value ["lux;Nil" _]]]]]]]]]]]]]]] (&&host/analyse-jvm-putfield analyse ?class ?field ?object ?value) [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ["" "jvm-invokestatic"]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?class]]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ["" ?class]]]] ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ["" ?method]]]] ["lux;Cons" [["lux;Meta" [_ ["lux;Tuple" ?classes]]] ["lux;Cons" [["lux;Meta" [_ ["lux;Tuple" ?args]]] @@ -268,7 +268,7 @@ (&&host/analyse-jvm-invokestatic analyse ?class ?method ?classes ?args) [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ["" "jvm-invokevirtual"]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?class]]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ["" ?class]]]] ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ["" ?method]]]] ["lux;Cons" [["lux;Meta" [_ ["lux;Tuple" ?classes]]] ["lux;Cons" [?object @@ -286,7 +286,7 @@ (&&host/analyse-jvm-invokeinterface analyse ?class ?method ?classes ?object ?args) [["lux;Meta" [meta ["lux;Form" ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ["" "jvm-invokespecial"]]]] - ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" [_ ?class]]]] + ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ["" ?class]]]] ["lux;Cons" [["lux;Meta" [_ ["lux;Symbol" ["" ?method]]]] ["lux;Cons" [["lux;Meta" [_ ["lux;Tuple" ?classes]]] ["lux;Cons" [?object diff --git a/src/lux/analyser/lux.clj b/src/lux/analyser/lux.clj index 59f3fbb1f..62b99a5b7 100644 --- a/src/lux/analyser/lux.clj +++ b/src/lux/analyser/lux.clj @@ -262,16 +262,12 @@ [["global" [?module ?name]]] (|do [$def (&&module/find-def ?module ?name)] (matchv ::M/objects [$def] - [["lux;MacroD" _macro]] - (matchv ::M/objects [_macro] - [["lux;Some" macro]] - (|do [macro-expansion #(-> macro (.apply ?args) (.apply %))] - (do (when (= "type`" ?name) - (prn 'macro-expansion (str ?module ";" ?name) (->> macro-expansion (&/|map &/show-ast) (&/|interpose " ") (&/fold str "")))) - (&/flat-map% (partial analyse exo-type) macro-expansion))) - - [["lux;None" _]] - (fail (str "[Analyser Error] Macro has yet to be compiled: " (str ?module ";" ?name)))) + [["lux;MacroD" macro]] + (|do [macro-expansion #(-> macro (.apply ?args) (.apply %))] + (do (when (or (= "type`" ?name) + (= "deftype" ?name)) + (prn 'macro-expansion (str ?module ";" ?name) (->> macro-expansion (&/|map &/show-ast) (&/|interpose " ") (&/fold str "")))) + (&/flat-map% (partial analyse exo-type) macro-expansion))) [_] (|do [output (analyse-apply* analyse exo-type =fn ?args)] diff --git a/src/lux/analyser/module.clj b/src/lux/analyser/module.clj index b9a92c120..921417c17 100644 --- a/src/lux/analyser/module.clj +++ b/src/lux/analyser/module.clj @@ -70,7 +70,7 @@ (fn [state*] (return* (&/update$ &/$MODULES (fn [$modules] - (&/|put module (&/|put name (&/V "lux;MacroD" (&/V "lux;Some" macro)) $module) + (&/|put module (&/|put name (&/V "lux;MacroD" macro) $module) $modules)) state*) nil))) @@ -83,25 +83,3 @@ (fail* (str "[Analyser Error] Definition doesn't have macro type: " module ";" name))) (fail* (str "[Analyser Error] Definition doesn't exist: " (str module &/+name-separator+ name)))) (fail* (str "[Analyser Error] Module doesn't exist: " module))))) - -(defn install-macro [module name macro] - (fn [state] - (if-let [$module (->> state (&/get$ &/$MODULES) (&/|get module))] - (if-let [$def (&/|get name $module)] - (matchv ::M/objects [$def] - [["lux;MacroD" ["lux;None" _]]] - (return* (&/update$ &/$MODULES - (fn [$modules] - (&/|put module (&/|put name (&/V "lux;MacroD" (&/V "lux;Some" macro)) $module) - $modules)) - state) - nil) - - [["lux;MacroD" ["lux;Some" _]]] - (fail* (str "[Analyser Error] Can't re-install a macro: " (str module &/+name-separator+ name))) - - [_] - (fail* (str "[Analyser Error] Can't install a non-macro: " (str module &/+name-separator+ name)))) - (fail* (str "[Analyser Error] Definition doesn't exist: " (str module &/+name-separator+ name)))) - (fail* (str "[Analyser Error] Module doesn't exist: " module))) - )) diff --git a/src/lux/host.clj b/src/lux/host.clj index 26a270199..9d6f72fab 100644 --- a/src/lux/host.clj +++ b/src/lux/host.clj @@ -79,7 +79,13 @@ (->type-signature ?name) [["lux;LambdaT" [_ _]]] - (->type-signature function-class))) + (->type-signature function-class) + + [["lux;VariantT" ["lux;Nil" _]]] + "V" + + [_] + (assert false (prn-str '->java-sig (aget type 0))))) (defn extract-jvm-param [token] (matchv ::M/objects [token] diff --git a/src/lux/lexer.clj b/src/lux/lexer.clj index 38fe77264..983d94dc9 100644 --- a/src/lux/lexer.clj +++ b/src/lux/lexer.clj @@ -6,6 +6,7 @@ ;; [Utils] (defn ^:private escape-char [escaped] + ;; (prn 'escape-char escaped) (condp = escaped "\\t" (return "\t") "\\b" (return "\b") @@ -17,10 +18,14 @@ ;; else (fail (str "[Lexer Error] Unknown escape character: " escaped)))) -(defn ^:private lex-text-body [_____] +(defn ^:private lex-text-body [_] (&/try-all% (&/|list (|do [[_ [_ [prefix escaped]]] (&reader/read-regex2 #"(?s)^([^\"\\]*)(\\.)") - unescaped (escape-char escaped) - [_ [_ postfix]] (lex-text-body nil)] + ;; :let [_ (prn '[prefix escaped] [prefix escaped])] + unescaped (escape-char escaped) + ;; :let [_ (prn 'unescaped unescaped)] + postfix (lex-text-body nil) + ;; :let [_ (prn 'postfix postfix)] + ] (return (str prefix unescaped postfix))) (|do [[_ [_ body]] (&reader/read-regex #"(?s)^([^\"\\]*)")] (return body))))) @@ -37,7 +42,7 @@ [_ [_ comment]] (&reader/read-regex #"^(.*)$")] (return (&/V "lux;Meta" (&/T meta (&/V "Comment" comment)))))) -(defn ^:private lex-multi-line-comment [___] +(defn ^:private lex-multi-line-comment [_] (|do [_ (&reader/read-text "#(") [meta comment] (&/try-all% (&/|list (|do [[_ [meta comment]] (&reader/read-regex #"(?is)^((?!#\().)*?(?=\)#)")] (return comment)) diff --git a/src/lux/reader.clj b/src/lux/reader.clj index 2eacdafcc..d163bcae3 100644 --- a/src/lux/reader.clj +++ b/src/lux/reader.clj @@ -52,7 +52,7 @@ line* (.substring line match-length) ;; _ (prn 'with-line line*) ] - (&/V "Yes" (&/T (&/V "lux;Meta" (&/T (&/T file-name line-num column-num) [tok1 tok2])) + (&/V "Yes" (&/T (&/V "lux;Meta" (&/T (&/T file-name line-num column-num) (&/T tok1 tok2))) (if (empty? line*) (&/V "lux;None" nil) (&/V "lux;Some" (&/V "lux;Meta" (&/T (&/T file-name line-num (+ column-num match-length)) line*))))))) diff --git a/src/lux/type.clj b/src/lux/type.clj index caa210d2a..766e28a39 100644 --- a/src/lux/type.clj +++ b/src/lux/type.clj @@ -813,7 +813,7 @@ [["lux;VariantT" ?cases]] (if-let [case-type (&/|get case ?cases)] (return case-type) - (fail (str "[Type Error] Variant lacks case: " case))) + (fail (str "[Type Error] Variant lacks case: " case " | " (show-type type)))) [_] (fail (str "[Type Error] Type is not a variant: " (show-type type))))) |