diff options
author | Eduardo Julian | 2017-11-15 20:57:47 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-11-15 20:57:47 -0400 |
commit | b5c854fb5ac1ead274f4ae0c657da66df957f14e (patch) | |
tree | b89035466363121a58e37c62f340c75a8c7dbeb7 /new-luxc/source/luxc | |
parent | 094c0904470f85ff0d63c788e07ce1ecf355577e (diff) |
- Moved "luxc/lang/syntax" to "lux/lang/syntax".
- Minor refactoring.
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/lang.lux | 2 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/analysis/common.lux | 2 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/analysis/function.lux | 2 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/analysis/inference.lux | 2 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/analysis/procedure/common.lux | 8 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/analysis/procedure/host.jvm.lux | 14 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/analysis/structure.lux | 28 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/analysis/type.lux | 4 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/eval.lux | 2 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation.lux | 12 | ||||
-rw-r--r-- | stdlib/source/lux/lang/syntax.lux (renamed from new-luxc/source/luxc/lang/syntax.lux) | 0 |
11 files changed, 38 insertions, 38 deletions
diff --git a/new-luxc/source/luxc/lang.lux b/new-luxc/source/luxc/lang.lux index 373c6b12b..844cc6755 100644 --- a/new-luxc/source/luxc/lang.lux +++ b/new-luxc/source/luxc/lang.lux @@ -40,7 +40,7 @@ (:: meta;Monad<Meta> (~' wrap) []) (;;throw (~ exception) (~ message))))))) -(def: #export (with-expected-type expected action) +(def: #export (with-type expected action) (All [a] (-> Type (Meta a) (Meta a))) (function [compiler] (case (action (set@ #;expected (#;Some expected) compiler)) diff --git a/new-luxc/source/luxc/lang/analysis/common.lux b/new-luxc/source/luxc/lang/analysis/common.lux index 2f3e3a37d..95355d62f 100644 --- a/new-luxc/source/luxc/lang/analysis/common.lux +++ b/new-luxc/source/luxc/lang/analysis/common.lux @@ -14,7 +14,7 @@ (All [a] (-> (Meta a) (Meta [Type a]))) (do meta;Monad<Meta> [[_ varT] (&;with-type-env tc;var) - analysis (&;with-expected-type varT + analysis (&;with-type varT action) knownT (&;with-type-env (tc;clean varT))] (wrap [knownT analysis]))) diff --git a/new-luxc/source/luxc/lang/analysis/function.lux b/new-luxc/source/luxc/lang/analysis/function.lux index 5403026cb..611e5c8a4 100644 --- a/new-luxc/source/luxc/lang/analysis/function.lux +++ b/new-luxc/source/luxc/lang/analysis/function.lux @@ -77,7 +77,7 @@ ## also to themselves, through a local variable. (&scope;with-local [func-name expectedT]) (&scope;with-local [arg-name inputT]) - (&;with-expected-type outputT) + (&;with-type outputT) (analyse body)) _ diff --git a/new-luxc/source/luxc/lang/analysis/inference.lux b/new-luxc/source/luxc/lang/analysis/inference.lux index 080a6c620..cccaa774a 100644 --- a/new-luxc/source/luxc/lang/analysis/inference.lux +++ b/new-luxc/source/luxc/lang/analysis/inference.lux @@ -113,7 +113,7 @@ (function [_] (Cannot-Infer-Argument (format "Inferred Type: " (%type inputT) "\n" " Argument: " (%code argC)))) - (&;with-expected-type inputT + (&;with-type inputT (analyse argC)))] (wrap [outputT' (list& argA args'A)])) diff --git a/new-luxc/source/luxc/lang/analysis/procedure/common.lux b/new-luxc/source/luxc/lang/analysis/procedure/common.lux index be77e643c..a643cb76a 100644 --- a/new-luxc/source/luxc/lang/analysis/procedure/common.lux +++ b/new-luxc/source/luxc/lang/analysis/procedure/common.lux @@ -56,7 +56,7 @@ [_ (&;infer outputT) argsA (monad;map @ (function [[argT argC]] - (&;with-expected-type argT + (&;with-type argT (analyse argC))) (list;zip2 inputsT+ args))] (wrap (la;procedure proc argsA))) @@ -98,7 +98,7 @@ (do meta;Monad<Meta> [[var-id varT] (&;with-type-env tc;var) _ (&;infer (type (Either Text varT))) - opA (&;with-expected-type (type (io;IO varT)) + opA (&;with-type (type (io;IO varT)) (analyse opC))] (wrap (la;procedure proc (list opA)))) @@ -148,7 +148,7 @@ (^ (list valueC)) (do meta;Monad<Meta> [_ (&;infer (type Type)) - valueA (&;with-expected-type Type + valueA (&;with-type Type (analyse valueC))] (wrap valueA)) @@ -342,7 +342,7 @@ (do meta;Monad<Meta> [[var-id varT] (&;with-type-env tc;var) _ (&;infer (type (Atom varT))) - initA (&;with-expected-type varT + initA (&;with-type varT (analyse initC))] (wrap (la;procedure proc (list initA)))) diff --git a/new-luxc/source/luxc/lang/analysis/procedure/host.jvm.lux b/new-luxc/source/luxc/lang/analysis/procedure/host.jvm.lux index c6a456441..8f5382d2b 100644 --- a/new-luxc/source/luxc/lang/analysis/procedure/host.jvm.lux +++ b/new-luxc/source/luxc/lang/analysis/procedure/host.jvm.lux @@ -197,7 +197,7 @@ (do meta;Monad<Meta> [_ (&;infer Nat) [var-id varT] (&;with-type-env tc;var) - arrayA (&;with-expected-type (type (Array varT)) + arrayA (&;with-type (type (Array varT)) (analyse arrayC))] (wrap (la;procedure proc (list arrayA)))) @@ -210,7 +210,7 @@ (case args (^ (list lengthC)) (do meta;Monad<Meta> - [lengthA (&;with-expected-type Nat + [lengthA (&;with-type Nat (analyse lengthC)) expectedT meta;expected-type [level elem-class] (: (Meta [Nat Text]) @@ -303,12 +303,12 @@ (do meta;Monad<Meta> [[var-id varT] (&;with-type-env tc;var) _ (&;infer varT) - arrayA (&;with-expected-type (type (Array varT)) + arrayA (&;with-type (type (Array varT)) (analyse arrayC)) ?elemT (&;with-type-env (tc;read var-id)) [elemT elem-class] (box-array-element-type (maybe;default varT ?elemT)) - idxA (&;with-expected-type Nat + idxA (&;with-type Nat (analyse idxC))] (wrap (la;procedure proc (list (code;text elem-class) idxA arrayA)))) @@ -323,14 +323,14 @@ (do meta;Monad<Meta> [[var-id varT] (&;with-type-env tc;var) _ (&;infer (type (Array varT))) - arrayA (&;with-expected-type (type (Array varT)) + arrayA (&;with-type (type (Array varT)) (analyse arrayC)) ?elemT (&;with-type-env (tc;read var-id)) [valueT elem-class] (box-array-element-type (maybe;default varT ?elemT)) - idxA (&;with-expected-type Nat + idxA (&;with-type Nat (analyse idxC)) - valueA (&;with-expected-type valueT + valueA (&;with-type valueT (analyse valueC))] (wrap (la;procedure proc (list (code;text elem-class) idxA valueA arrayA)))) diff --git a/new-luxc/source/luxc/lang/analysis/structure.lux b/new-luxc/source/luxc/lang/analysis/structure.lux index 3048d4a4e..76b5a3a42 100644 --- a/new-luxc/source/luxc/lang/analysis/structure.lux +++ b/new-luxc/source/luxc/lang/analysis/structure.lux @@ -45,7 +45,7 @@ (case (list;nth tag flat) (#;Some variant-type) (do @ - [valueA (&;with-expected-type variant-type + [valueA (&;with-type variant-type (analyse valueC)) temp &scope;next-local] (wrap (la;sum tag type-size temp valueA))) @@ -54,7 +54,7 @@ (&common;variant-out-of-bounds-error expectedT type-size tag))) (#;Named name unnamedT) - (&;with-expected-type unnamedT + (&;with-type unnamedT (analyse-sum analyse tag valueC)) (#;Var id) @@ -63,7 +63,7 @@ (tc;read id))] (case ?expectedT' (#;Some expectedT') - (&;with-expected-type expectedT' + (&;with-type expectedT' (analyse-sum analyse tag valueC)) _ @@ -79,7 +79,7 @@ (<tag> _) (do @ [[instance-id instanceT] (&;with-type-env <instancer>)] - (&;with-expected-type (maybe;assume (type;apply (list instanceT) expectedT)) + (&;with-type (maybe;assume (type;apply (list instanceT) expectedT)) (analyse-sum analyse tag valueC)))) ([#;UnivQ tc;existential] [#;ExQ tc;var]) @@ -91,7 +91,7 @@ [?funT' (&;with-type-env (tc;read funT-id))] (case ?funT' (#;Some funT') - (&;with-expected-type (#;Apply inputT funT') + (&;with-type (#;Apply inputT funT') (analyse-sum analyse tag valueC)) _ @@ -105,7 +105,7 @@ (&;throw Not-Quantified-Type (%type funT)) (#;Some outputT) - (&;with-expected-type outputT + (&;with-type outputT (analyse-sum analyse tag valueC)))) _ @@ -123,14 +123,14 @@ ## If the tuple runs out, whatever expression is the last gets ## matched to the remaining type. [tailT (#;Cons tailC #;Nil)] - (&;with-expected-type tailT + (&;with-type tailT (analyse tailC)) ## If the type and the code are still ongoing, match each ## sub-expression to its corresponding type. [(#;Product leftT rightT) (#;Cons leftC rightC)] (do @ - [leftA (&;with-expected-type leftT + [leftA (&;with-type leftT (analyse leftC)) rightA (recur rightT rightC)] (wrap (` [(~ leftA) (~ rightA)]))) @@ -155,7 +155,7 @@ [tailT tailC] (do @ [g!tail (meta;gensym "tail")] - (&;with-expected-type tailT + (&;with-type tailT (analyse (` ("lux case" [(~@ tailC)] (~ g!tail) (~ g!tail)))))) @@ -173,7 +173,7 @@ (analyse-typed-product analyse membersC) (#;Named name unnamedT) - (&;with-expected-type unnamedT + (&;with-type unnamedT (analyse-product analyse membersC)) (#;Var id) @@ -182,7 +182,7 @@ (tc;read id))] (case ?expectedT' (#;Some expectedT') - (&;with-expected-type expectedT' + (&;with-type expectedT' (analyse-product analyse membersC)) _ @@ -199,7 +199,7 @@ (<tag> _) (do @ [[instance-id instanceT] (&;with-type-env <instancer>)] - (&;with-expected-type (maybe;assume (type;apply (list instanceT) expectedT)) + (&;with-type (maybe;assume (type;apply (list instanceT) expectedT)) (analyse-product analyse membersC)))) ([#;UnivQ tc;existential] [#;ExQ tc;var]) @@ -211,7 +211,7 @@ [?funT' (&;with-type-env (tc;read funT-id))] (case ?funT' (#;Some funT') - (&;with-expected-type (#;Apply inputT funT') + (&;with-type (#;Apply inputT funT') (analyse-product analyse membersC)) _ @@ -224,7 +224,7 @@ (&;throw Not-Quantified-Type (%type funT)) (#;Some outputT) - (&;with-expected-type outputT + (&;with-type outputT (analyse-product analyse membersC)))) _ diff --git a/new-luxc/source/luxc/lang/analysis/type.lux b/new-luxc/source/luxc/lang/analysis/type.lux index 4184dd0c0..eb3de08de 100644 --- a/new-luxc/source/luxc/lang/analysis/type.lux +++ b/new-luxc/source/luxc/lang/analysis/type.lux @@ -15,7 +15,7 @@ [actualT (eval Type type) #let [actualT (:! Type actualT)] _ (&;infer actualT)] - (&;with-expected-type actualT + (&;with-type actualT (analyse value)))) (def: #export (analyse-coerce analyse eval type value) @@ -23,5 +23,5 @@ (do meta;Monad<Meta> [actualT (eval Type type) _ (&;infer (:! Type actualT))] - (&;with-expected-type Top + (&;with-type Top (analyse value)))) diff --git a/new-luxc/source/luxc/lang/eval.lux b/new-luxc/source/luxc/lang/eval.lux index 20c3acaeb..265320dbe 100644 --- a/new-luxc/source/luxc/lang/eval.lux +++ b/new-luxc/source/luxc/lang/eval.lux @@ -11,7 +11,7 @@ (def: #export (eval type exprC) &;Eval (do meta;Monad<Meta> - [exprA (&;with-expected-type type + [exprA (&;with-type type (expressionA;analyser eval exprC)) #let [exprS (expressionS;synthesize exprA)] exprI (expressionT;translate exprS)] diff --git a/new-luxc/source/luxc/lang/translation.lux b/new-luxc/source/luxc/lang/translation.lux index e573aa3ae..88fc25d3a 100644 --- a/new-luxc/source/luxc/lang/translation.lux +++ b/new-luxc/source/luxc/lang/translation.lux @@ -9,6 +9,7 @@ (coll [dict])) [meta] (meta (type ["tc" check])) + (lang [syntax]) [host] [io] (world [file #+ File])) @@ -18,7 +19,6 @@ [";L" host] (host [";H" macro] ["$" jvm]) - ["&;" syntax] (analysis [";A" expression] [";A" common]) (synthesis [";S" expression]) @@ -41,7 +41,7 @@ (-> Code (Meta [$;Inst Code])) (do meta;Monad<Meta> [[_ annsA] (&;with-scope - (&;with-expected-type Code + (&;with-type Code (analyse annsC))) annsI (expressionT;translate (expressionS;synthesize annsA)) annsV (evalT;eval annsI)] @@ -58,7 +58,7 @@ [_ valueT valueA] (&;with-scope (if (meta;type? (:! Code annsV)) (do @ - [valueA (&;with-expected-type Type + [valueA (&;with-type Type (analyse valueC))] (wrap [Type valueA])) (commonA;with-unknown-type @@ -73,7 +73,7 @@ (^code ("lux program" (~ [_ (#;Symbol ["" program-args])]) (~ programC))) (do meta;Monad<Meta> [[_ programA] (&;with-scope - (&;with-expected-type (type (io;IO Unit)) + (&;with-type (type (io;IO Unit)) (analyse programC))) programI (expressionT;translate (expressionS;synthesize programA))] (statementT;translate-program program-args programI)) @@ -111,7 +111,7 @@ ((exhaust action) compiler') (#e;Error error) - (if (ex;match? &syntax;End-Of-File error) + (if (ex;match? syntax;End-Of-File error) (#e;Success [compiler []]) (#e;Error error))))) @@ -129,7 +129,7 @@ (def: (parse current-module) (-> Text (Meta Code)) (function [compiler] - (case (&syntax;parse current-module (get@ #;source compiler)) + (case (syntax;parse current-module (get@ #;source compiler)) (#e;Error error) (#e;Error error) diff --git a/new-luxc/source/luxc/lang/syntax.lux b/stdlib/source/lux/lang/syntax.lux index 9fe4939a2..9fe4939a2 100644 --- a/new-luxc/source/luxc/lang/syntax.lux +++ b/stdlib/source/lux/lang/syntax.lux |