diff options
Diffstat (limited to 'new-luxc/source/luxc/lang/extension.lux')
-rw-r--r-- | new-luxc/source/luxc/lang/extension.lux | 114 |
1 files changed, 0 insertions, 114 deletions
diff --git a/new-luxc/source/luxc/lang/extension.lux b/new-luxc/source/luxc/lang/extension.lux deleted file mode 100644 index 254dd18ca..000000000 --- a/new-luxc/source/luxc/lang/extension.lux +++ /dev/null @@ -1,114 +0,0 @@ -(.module: - lux - (lux (control [monad #+ do] - ["ex" exception #+ exception:]) - (data ["e" error] - [text] - (coll (dictionary ["dict" unordered #+ Dict]))) - [macro]) - [//] - (// ["la" analysis] - ["ls" synthesis])) - -(do-template [<name>] - [(exception: #export (<name> {message Text}) - message)] - - [Unknown-Analysis] - [Unknown-Synthesis] - [Unknown-Translation] - [Unknown-Statement] - - [Cannot-Define-Analysis-More-Than-Once] - [Cannot-Define-Synthesis-More-Than-Once] - [Cannot-Define-Translation-More-Than-Once] - [Cannot-Define-Statement-More-Than-Once] - ) - -(type: #export Analysis - (-> (-> Code (Meta Code)) - (-> Type Code (Meta Any)) - (List Code) (Meta Code))) - -(type: #export Synthesis - (-> (-> la.Analysis ls.Synthesis) (List Code) Code)) - -(type: #export Syntheses (Dict Text Synthesis)) - -(type: #export Translation - (-> (List Code) (Meta Code))) - -(type: #export Statement - (-> (List Code) (Meta Any))) - -(type: #export Extensions - {#analysis (Dict Text Analysis) - #synthesis Syntheses - #translation (Dict Text Translation) - #statement (Dict Text Statement)}) - -(def: #export fresh - Extensions - {#analysis (dict.new text.Hash<Text>) - #synthesis (dict.new text.Hash<Text>) - #translation (dict.new text.Hash<Text>) - #statement (dict.new text.Hash<Text>)}) - -(def: get - (Meta Extensions) - (function (_ compiler) - (#e.Success [compiler - (|> compiler (get@ #.extensions) (:! Extensions))]))) - -(def: (set extensions) - (-> Extensions (Meta Any)) - (function (_ compiler) - (#e.Success [(set@ #.extensions (:! Nothing extensions) compiler) - []]))) - -(do-template [<name> <type> <category> <exception>] - [(def: #export (<name> name) - (-> Text (Meta <type>)) - (do macro.Monad<Meta> - [extensions ..get] - (case (dict.get name (get@ <category> extensions)) - (#.Some extension) - (wrap extension) - - #.None - (//.throw <exception> name))))] - - [find-analysis Analysis #analysis Unknown-Analysis] - [find-synthesis Synthesis #synthesis Unknown-Synthesis] - [find-translation Translation #translation Unknown-Translation] - [find-statement Statement #statement Unknown-Statement] - ) - -(do-template [<no> <all> <type> <category> <empty>] - [(def: #export <no> - <type> - <empty>) - - (def: #export <all> - (Meta <type>) - (|> ..get - (:: macro.Monad<Meta> map (get@ <category>))))] - - [no-syntheses all-syntheses Syntheses #synthesis (dict.new text.Hash<Text>)] - ) - -(do-template [<name> <type> <category> <exception>] - [(def: #export (<name> name extension) - (-> Text <type> (Meta Any)) - (do macro.Monad<Meta> - [extensions ..get - _ (//.assert <exception> name - (not (dict.contains? name (get@ <category> extensions)))) - _ (..set (update@ <category> (dict.put name extension) extensions))] - (wrap [])))] - - [install-analysis Analysis #analysis Cannot-Define-Analysis-More-Than-Once] - [install-synthesis Synthesis #synthesis Cannot-Define-Synthesis-More-Than-Once] - [install-translation Translation #translation Cannot-Define-Translation-More-Than-Once] - [install-statement Statement #statement Cannot-Define-Statement-More-Than-Once] - ) |