aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compatibility/compatibility.nom38
-rw-r--r--nomsu_compiler.lua1
-rw-r--r--nomsu_compiler.moon1
-rw-r--r--tools/autoformat.nom6
-rw-r--r--tools/upgrade.nom10
5 files changed, 56 insertions, 0 deletions
diff --git a/compatibility/compatibility.nom b/compatibility/compatibility.nom
new file mode 100644
index 0000000..303c05b
--- /dev/null
+++ b/compatibility/compatibility.nom
@@ -0,0 +1,38 @@
+#!/usr/bin/env nomsu -V1
+use "core"
+use "lib/os.nom"
+
+%UPGRADES <- {}
+
+action [upgrade to %version via %upgrade_fn]
+ %UPGRADES.%version <- %upgrade_fn
+
+parse [upgrade %tree to %version as %body] as
+ upgrade to %version via ([%] -> (% with %tree -> %body))
+
+action [%tree upgraded from %start_version to %end_version, %tree upgraded to %end_version from %start_version]
+ local action [%ver as list]
+ (% as number) for % where %ver matches "[0-9]+"
+
+ %versions <-: (keys in %UPGRADES) sorted by % -> (% as list)
+ for %ver in %versions
+ if: (%ver as list) <= (%start_version as list)
+ do next %ver
+ if: (%ver as list) > (%end_version as list)
+ stop %ver
+ %tree <- (call %UPGRADES.%ver with [%tree])
+ return %tree
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+parse [%tree upgraded from %start_version] as: %tree upgraded from %start_version to (Nomsu version)
+parse [%tree upgraded to %end_version] as: %tree upgraded from %tree.version to %end_version
+parse [%tree upgraded] as: %tree upgraded from %tree.version to (Nomsu version)
+
+action [use %path from version %version]
+ for file %filename in %path
+ if (=lua "LOADED[\%filename]")
+ do next %filename
+ %file <-: read file %filename
+ %tree <-: parse %file from %filename
+ %tree <-: upgrade %tree from %version
+ run tree %tree
diff --git a/nomsu_compiler.lua b/nomsu_compiler.lua
index b096659..4f181f2 100644
--- a/nomsu_compiler.lua
+++ b/nomsu_compiler.lua
@@ -962,6 +962,7 @@ do
if j > 1 then
nomsu:append("\n")
end
+ line = gsub(line, "\\", "\\\\")
if #line > 1.25 * MAX_LINE then
local remainder = line
while #remainder > 0 do
diff --git a/nomsu_compiler.moon b/nomsu_compiler.moon
index e89dffa..1c69707 100644
--- a/nomsu_compiler.moon
+++ b/nomsu_compiler.moon
@@ -634,6 +634,7 @@ with NomsuCompiler
bit_lines = files.get_lines(bit)
for j, line in ipairs bit_lines
if j > 1 then nomsu\append "\n"
+ line = gsub(line, "\\", "\\\\")
if #line > 1.25*MAX_LINE
remainder = line
while #remainder > 0
diff --git a/tools/autoformat.nom b/tools/autoformat.nom
new file mode 100644
index 0000000..a755b09
--- /dev/null
+++ b/tools/autoformat.nom
@@ -0,0 +1,6 @@
+use "core"
+use "lib/os.nom"
+
+for %path in (=lua "arg"):
+ for file %filename in %path:
+ say ((parse (read file %filename) from %filename) as nomsu)
diff --git a/tools/upgrade.nom b/tools/upgrade.nom
new file mode 100644
index 0000000..e55d835
--- /dev/null
+++ b/tools/upgrade.nom
@@ -0,0 +1,10 @@
+use "core"
+use "compatibility"
+use "lib/os.nom"
+
+for %path in (=lua "arg"):
+ for file %filename in %path:
+ %tree <- (parse (read file %filename) from %filename)
+ %tree <- (%tree upgraded from %tree.version to (Nomsu version))
+ say "#!/usr/bin/env nomsu -V\(Nomsu version)\n\(%tree as nomsu)"
+