aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex
diff options
context:
space:
mode:
authorEduardo Julian2022-02-06 03:15:39 -0400
committerEduardo Julian2022-02-06 03:15:39 -0400
commit290de8ebcb7edc92877f2ccc333171214e5eae23 (patch)
tree7307b79865b242a057d35a3b654d8906a8b8c97e /stdlib/source/program/aedifex
parent54bb56a07e6d8f1e76bd447436fb721a74f09f66 (diff)
Finishing the meta-compiler [Part 1]
Diffstat (limited to '')
-rw-r--r--stdlib/source/program/aedifex/command/build.lux86
-rw-r--r--stdlib/source/program/aedifex/command/deps.lux2
-rw-r--r--stdlib/source/program/aedifex/format.lux51
-rw-r--r--stdlib/source/program/aedifex/parser.lux79
-rw-r--r--stdlib/source/program/aedifex/profile.lux87
5 files changed, 172 insertions, 133 deletions
diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux
index ba461d461..8570207be 100644
--- a/stdlib/source/program/aedifex/command/build.lux
+++ b/stdlib/source/program/aedifex/command/build.lux
@@ -1,6 +1,6 @@
(.using
[library
- [lux "*"
+ [lux {"-" Lux}
["[0]" ffi {"+" import:}]
[abstract
[order {"+" Order}]
@@ -20,12 +20,13 @@
["[0]" dictionary {"+" Dictionary}]
["[0]" set]]]
[math
- [number
+ [number {"+" hex}
["n" nat]
["i" int]]]
[tool
[compiler
[meta
+ ["[0]" cli]
["[0]" packager
["[0]_[1]" ruby]]]]]
[world
@@ -68,17 +69,17 @@
Name
<dependency>)]
- ["lux-jvm" jvm_compiler_name]
- ["lux-js" js_compiler_name]
- ["lux-python" python_compiler_name]
- ["lux-lua" lua_compiler_name]
- ["lux-ruby" ruby_compiler_name]
+ ["lux-jvm" jvm_lux_name]
+ ["lux-js" js_lux_name]
+ ["lux-python" python_lux_name]
+ ["lux-lua" lua_lux_name]
+ ["lux-ruby" ruby_lux_name]
)
-(exception: .public no_available_compiler)
+(exception: .public no_available_lux)
(exception: .public no_specified_program)
-(type: .public Compiler
+(type: .public Lux
(Variant
{#JVM Dependency}
{#JS Dependency}
@@ -92,27 +93,27 @@
(list.only (|>> product.left (same? dependency) not))
(dictionary.of_list ///dependency.hash)))
-(def: (compiler resolution compiler_dependency)
- (-> Resolution Dependency (Try [Resolution Compiler]))
- (let [[[compiler_group compiler_name compiler_version] compiler_type] compiler_dependency]
- (case (..dependency_finder compiler_group compiler_name resolution)
+(def: (lux resolution lux_dependency)
+ (-> Resolution Dependency (Try [Resolution Lux]))
+ (let [[[lux_group lux_name lux_version] lux_type] lux_dependency]
+ (case (..dependency_finder lux_group lux_name resolution)
{.#Some dependency}
- (case compiler_name
+ (case lux_name
(^template [<tag> <name>]
[(^ (static <name>))
{try.#Success [(..remove_dependency dependency resolution)
{<tag> dependency}]}])
- ([#JVM ..jvm_compiler_name]
- [#JS ..js_compiler_name]
- [#Python ..python_compiler_name]
- [#Lua ..lua_compiler_name]
- [#Ruby ..ruby_compiler_name])
+ ([#JVM ..jvm_lux_name]
+ [#JS ..js_lux_name]
+ [#Python ..python_lux_name]
+ [#Lua ..lua_lux_name]
+ [#Ruby ..ruby_lux_name])
_
- (exception.except ..no_available_compiler []))
+ (exception.except ..no_available_lux []))
_
- (exception.except ..no_available_compiler []))))
+ (exception.except ..no_available_lux []))))
(def: (path fs home dependency)
(All (_ !) (-> (file.System !) Path Dependency Path))
@@ -266,7 +267,7 @@
runtime)))
(def: .public (do! console program fs shell resolution)
- (-> (Console Async) (Program Async) (file.System Async) (Shell Async) Resolution (Command [Exit Compiler Path]))
+ (-> (Console Async) (Program Async) (file.System Async) (Shell Async) Resolution (Command [Exit Lux Path]))
(function (_ profile)
(let [target (value@ ///.#target profile)]
(case (value@ ///.#program profile)
@@ -279,32 +280,33 @@
.let [home (# program home)
working_directory (# program directory)]]
(do ///action.monad
- [[resolution compiler] (async#in (..compiler resolution (value@ ///.#compiler profile)))
+ [[resolution lux] (async#in (..lux resolution (value@ ///.#lux profile)))
.let [host_dependencies (..host_dependencies fs home resolution)
- [[command compiler_params] output] (case compiler
- {#JVM dependency}
- [(|> (value@ ///.#java profile)
- (with@ ///runtime.#parameters (list "program._"))
- (with_jvm_class_path {.#Item (..path fs home dependency) host_dependencies}))
- "program.jar"]
-
- (^template [<tag> <runtime> <program>]
- [{<tag> dependency}
- [(|> dependency
- (..path fs home)
- (///runtime.for (value@ <runtime> profile)))
- <program>]])
- ([#JS ///.#js "program.js"]
- [#Python ///.#java "program.py"]
- [#Lua ///.#java "program.lua"]
- [#Ruby ///.#java (file.rooted fs "program" ruby_packager.main_file)]))
+ [[command lux_params] output] (case lux
+ {#JVM dependency}
+ [(|> (value@ ///.#java profile)
+ (with@ ///runtime.#parameters (list "program._"))
+ (with_jvm_class_path {.#Item (..path fs home dependency) host_dependencies}))
+ "program.jar"]
+
+ (^template [<tag> <runtime> <program>]
+ [{<tag> dependency}
+ [(|> dependency
+ (..path fs home)
+ (///runtime.for (value@ <runtime> profile)))
+ <program>]])
+ ([#JS ///.#js "program.js"]
+ [#Python ///.#java "program.py"]
+ [#Lua ///.#java "program.lua"]
+ [#Ruby ///.#java (file.rooted fs "program" ruby_packager.main_file)]))
/ (# fs separator)
cache_directory (format working_directory / target)]
_ (console.write_line ..start console)
- .let [full_parameters (list.together (list compiler_params
+ .let [full_parameters (list.together (list lux_params
(list "build")
(..plural "--library" (..libraries fs home resolution))
(..plural "--host_dependency" host_dependencies)
+ (..plural "--compiler" (list#each cli.compiler_format (value@ ///.#compilers profile)))
(..plural "--source" (set.list (value@ ///.#sources profile)))
(..singular "--target" cache_directory)
(..singular "--module" program_module)))]
@@ -320,5 +322,5 @@
..failure)
console)]
(in [exit
- compiler
+ lux
(format cache_directory / output)])))))))
diff --git a/stdlib/source/program/aedifex/command/deps.lux b/stdlib/source/program/aedifex/command/deps.lux
index 4e32a73b1..85c6fbb57 100644
--- a/stdlib/source/program/aedifex/command/deps.lux
+++ b/stdlib/source/program/aedifex/command/deps.lux
@@ -42,7 +42,7 @@
(do async.monad
[.let [dependencies (|> (value@ ///.#dependencies profile)
set.list
- {.#Item (value@ ///.#compiler profile)})]
+ {.#Item (value@ ///.#lux profile)})]
[local_successes local_failures cache] (///dependency/resolution.all console
(list local)
new_repository
diff --git a/stdlib/source/program/aedifex/format.lux b/stdlib/source/program/aedifex/format.lux
index 8f3e63706..54e1ed57f 100644
--- a/stdlib/source/program/aedifex/format.lux
+++ b/stdlib/source/program/aedifex/format.lux
@@ -1,22 +1,26 @@
(.using
- [library
- [lux "*"
- [data
- ["[0]" text ("[1]#[0]" equivalence)]
- [collection
- ["[0]" dictionary {"+" Dictionary}]
- ["[0]" list ("[1]#[0]" monad)]
- ["[0]" set {"+" Set}]]]
- [macro
- ["[0]" code]
- ["[0]" template]]]]
- ["[0]" // "_"
- ["/" profile]
- ["[1][0]" runtime {"+" Runtime}]
- ["[1][0]" project {"+" Project}]
- ["[1][0]" dependency {"+" Dependency}]
- ["[1][0]" artifact {"+" Artifact}
- ["[1]/[0]" type]]])
+ [library
+ [lux "*"
+ [data
+ ["[0]" text ("[1]#[0]" equivalence)]
+ [collection
+ ["[0]" dictionary {"+" Dictionary}]
+ ["[0]" list ("[1]#[0]" monad)]
+ ["[0]" set {"+" Set}]]]
+ [macro
+ ["[0]" code]
+ ["[0]" template]]
+ [tool
+ [compiler
+ [meta
+ [cli {"+" Compiler}]]]]]]
+ ["[0]" // "_"
+ ["/" profile]
+ ["[1][0]" runtime {"+" Runtime}]
+ ["[1][0]" project {"+" Project}]
+ ["[1][0]" dependency {"+" Dependency}]
+ ["[1][0]" artifact {"+" Artifact}
+ ["[1]/[0]" type]]])
(type: .public (Format a)
(-> a Code))
@@ -141,6 +145,14 @@
(` [(~ (code.text program))
(~+ (list#each code.text parameters))]))
+(def: (compiler [definition parameters])
+ (Format Compiler)
+ (` [(~ (code.symbol definition))
+ (~+ (list#each code.text parameters))]))
+
+(def: .public lux_compiler_label
+ "lux")
+
(def: (profile value)
(Format /.Profile)
(`` (|> ..empty
@@ -149,7 +161,8 @@
(..on_maybe "info" (value@ /.#info value) ..info)
(..on_set "repositories" (value@ /.#repositories value) code.text)
(..on_set "dependencies" (value@ /.#dependencies value) ..dependency)
- (dictionary.has "compiler" (..dependency (value@ /.#compiler value)))
+ (dictionary.has ..lux_compiler_label (..dependency (value@ /.#lux value)))
+ (..on_list "compilers" (value@ /.#compilers value) ..compiler)
(..on_set "sources" (value@ /.#sources value) code.text)
(dictionary.has "target" (code.text (value@ /.#target value)))
(..on_maybe "program" (value@ /.#program value) code.text)
diff --git a/stdlib/source/program/aedifex/parser.lux b/stdlib/source/program/aedifex/parser.lux
index 44c16133f..52a9a292c 100644
--- a/stdlib/source/program/aedifex/parser.lux
+++ b/stdlib/source/program/aedifex/parser.lux
@@ -1,32 +1,35 @@
(.using
- [library
- [lux {"-" Module type}
- [abstract
- [monad {"+" do}]]
- [control
- ["<>" parser
- ["<[0]>" code {"+" Parser}]]]
- [data
- ["[0]" text]
- [collection
- ["[0]" dictionary {"+" Dictionary}]
- ["[0]" set {"+" Set}]]]
- [tool
- [compiler
- [meta
- [archive
- [descriptor {"+" Module}]]]]]
- [world
- [net {"+" URL}]]]]
- ["[0]" // "_"
- ["/" profile]
- ["[1][0]" runtime {"+" Runtime}]
- ["[1][0]" project {"+" Project}]
- ["[1][0]" dependency]
- ["[1][0]" repository "_"
- ["[1]" remote]]
- ["[1][0]" artifact {"+" Artifact}
- ["[1]/[0]" type]]])
+ [library
+ [lux {"-" Module type}
+ [abstract
+ [monad {"+" do}]]
+ [control
+ ["<>" parser
+ ["<[0]>" code {"+" Parser}]]]
+ [data
+ ["[0]" text]
+ [collection
+ ["[0]" dictionary {"+" Dictionary}]
+ ["[0]" set {"+" Set}]]]
+ [tool
+ [compiler
+ [meta
+ [cli {"+" Compiler}]
+ [archive
+ [module
+ [descriptor {"+" Module}]]]]]]
+ [world
+ [net {"+" URL}]]]]
+ ["[0]" // "_"
+ ["/" profile]
+ ["[1][0]" runtime {"+" Runtime}]
+ ["[1][0]" project {"+" Project}]
+ ["[1][0]" dependency]
+ ["[1][0]" format]
+ ["[1][0]" repository "_"
+ ["[1]" remote]]
+ ["[1][0]" artifact {"+" Artifact}
+ ["[1]/[0]" type]]])
(def: (as_input input)
(-> (Maybe Code) (List Code))
@@ -155,6 +158,14 @@
(<>.else //artifact/type.lux_library ..type)
)))
+(def: compiler
+ (Parser Compiler)
+ (<code>.tuple
+ ($_ <>.and
+ <code>.global_symbol
+ (<>.some <code>.text)
+ )))
+
(def: source
(Parser /.Source)
<code>.text)
@@ -203,9 +214,12 @@
(|> (..plural input "dependencies" ..dependency)
(# ! each (set.of_list //dependency.hash))
(<>.else (set.empty //dependency.hash))))
- ^compiler (|> ..dependency
- (..singular input "compiler")
- (<>.else /.default_compiler))
+ ^lux (|> ..dependency
+ (..singular input //format.lux_compiler_label)
+ (<>.else /.default_compiler))
+ ^compilers (|> ..compiler
+ (..plural input "compilers")
+ (<>.else (list)))
^sources (: (Parser (Set /.Source))
(|> (..plural input "sources" ..source)
(# ! each (set.of_list text.hash))
@@ -245,7 +259,8 @@
^info
^repositories
^dependencies
- ^compiler
+ ^lux
+ ^compilers
^sources
^target
^program
diff --git a/stdlib/source/program/aedifex/profile.lux b/stdlib/source/program/aedifex/profile.lux
index cdcfd3af5..eeabf5f82 100644
--- a/stdlib/source/program/aedifex/profile.lux
+++ b/stdlib/source/program/aedifex/profile.lux
@@ -1,40 +1,44 @@
(.using
- [library
- [lux {"-" Info Source Module}
- [abstract
- [monoid {"+" Monoid}]
- [equivalence {"+" Equivalence}]]
- [control
- ["[0]" maybe ("[1]#[0]" monoid)]
- ["[0]" exception {"+" exception:}]]
- [data
- ["[0]" product]
- ["[0]" text ("[1]#[0]" equivalence)]
- [collection
- ["[0]" dictionary {"+" Dictionary}]
- ["[0]" list ("[1]#[0]" monoid)]
- ["[0]" set {"+" Set}]]]
- [macro
- ["[0]" template]]
- [world
- [net {"+" URL}]
- [file {"+" Path}]]
- [tool
- [compiler
- [meta
- [archive
- [descriptor {"+" Module}]]]]]]]
- [//
- ["[0]" runtime {"+" Runtime} ("[1]#[0]" equivalence)]
- ["[0]" dependency {"+" Dependency} ("[1]#[0]" equivalence)]
- ["[0]" artifact {"+" Artifact}
- ["[0]" type]]
- [repository
- [remote {"+" Address}]]])
+ [library
+ [lux {"-" Info Source Module}
+ [abstract
+ [monoid {"+" Monoid}]
+ [equivalence {"+" Equivalence}]]
+ [control
+ ["[0]" maybe ("[1]#[0]" monoid)]
+ ["[0]" exception {"+" exception:}]]
+ [data
+ ["[0]" product]
+ ["[0]" text ("[1]#[0]" equivalence)]
+ [collection
+ ["[0]" dictionary {"+" Dictionary}]
+ ["[0]" list ("[1]#[0]" monoid)]
+ ["[0]" set {"+" Set}]]]
+ [macro
+ ["[0]" template]]
+ [meta
+ ["[0]" symbol]]
+ [world
+ [net {"+" URL}]
+ [file {"+" Path}]]
+ [tool
+ [compiler
+ [meta
+ ["[0]" cli {"+" Compiler}]
+ [archive
+ [module
+ [descriptor {"+" Module}]]]]]]]]
+ [//
+ ["[0]" runtime {"+" Runtime} ("[1]#[0]" equivalence)]
+ ["[0]" dependency {"+" Dependency} ("[1]#[0]" equivalence)]
+ ["[0]" artifact {"+" Artifact}
+ ["[0]" type]]
+ [repository
+ [remote {"+" Address}]]])
(def: .public default_compiler
Dependency
- [dependency.#artifact ["com.github.luxlang" "lux-jvm" "0.6.0"]
+ [dependency.#artifact ["com.github.luxlang" "lux-jvm" "0.6.5"]
dependency.#type type.jvm_library])
(type: .public Distribution
@@ -162,7 +166,8 @@
#info (Maybe Info)
#repositories (Set Address)
#dependencies (Set Dependency)
- #compiler Dependency
+ #lux Dependency
+ #compilers (List Compiler)
#sources (Set Source)
#target Target
#program (Maybe Module)
@@ -187,8 +192,10 @@
set.equivalence
... #dependencies
set.equivalence
- ... #compiler
+ ... #lux
dependency.equivalence
+ ... #compilers
+ (list.equivalence cli.compiler_equivalence)
... #sources
set.equivalence
... #target
@@ -219,7 +226,8 @@
#info {.#None}
#repositories (set.empty text.hash)
#dependencies (set.empty dependency.hash)
- #compiler default_compiler
+ #lux default_compiler
+ #compilers (list)
#sources (set.empty text.hash)
#target ..default_target
#program {.#None}
@@ -241,9 +249,10 @@
#info (maybe#composite (value@ #info override) (value@ #info baseline))
#repositories (set.union (value@ #repositories baseline) (value@ #repositories override))
#dependencies (set.union (value@ #dependencies baseline) (value@ #dependencies override))
- #compiler (if (dependency#= ..default_compiler (value@ #compiler override))
- (value@ #compiler baseline)
- (value@ #compiler override))
+ #lux (if (dependency#= ..default_compiler (value@ #lux override))
+ (value@ #lux baseline)
+ (value@ #lux override))
+ #compilers (list#composite (value@ #compilers baseline) (value@ #compilers override))
#sources (set.union (value@ #sources baseline) (value@ #sources override))
#target (if (text#= ..default_target (value@ #target baseline))
(value@ #target override)