aboutsummaryrefslogtreecommitdiff
path: root/compatibility
diff options
context:
space:
mode:
Diffstat (limited to 'compatibility')
-rw-r--r--compatibility/2.3.nom4
-rw-r--r--compatibility/2.4.nom32
-rw-r--r--compatibility/2.5.nom9
-rw-r--r--compatibility/2.nom17
-rw-r--r--compatibility/compatibility.nom39
5 files changed, 73 insertions, 28 deletions
diff --git a/compatibility/2.3.nom b/compatibility/2.3.nom
index d405181..7b49a26 100644
--- a/compatibility/2.3.nom
+++ b/compatibility/2.3.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V2.3
+#!/usr/bin/env nomsu -V2.5.4.3
use "core"
use "compatibility/compatibility.nom"
@@ -13,4 +13,4 @@ upgrade action (%a *<- %b) to "2.3" as (%a *= %b)
upgrade action (%a /<- %b) to "2.3" as (%a /= %b)
upgrade action (%a ^<- %b) to "2.3" as (%a ^= %b)
upgrade action (%a and<- %b) to "2.3" as (%a and= %b)
-upgrade action (%a or<- %b) to "2.3" as (%a or= %b)
+upgrade action (%a or<- %b) to "2.3" as (%a or= %b) \ No newline at end of file
diff --git a/compatibility/2.4.nom b/compatibility/2.4.nom
index ae0cfba..479d1d2 100644
--- a/compatibility/2.4.nom
+++ b/compatibility/2.4.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V2.4
+#!/usr/bin/env nomsu -V2.5.4.3
use "core"
use "compatibility/compatibility.nom"
@@ -8,49 +8,69 @@ upgrade %tree to "2.4" as:
"when %":
%conditions = []
%new_lines = []
- %body = ((%tree.2 upgraded) if (%tree.2 is "Block" syntax tree) else [%tree.2 upgraded])
+ %body = (..)
+ (%tree.2 upgraded) if (%tree.2 is "Block" syntax tree) else [%tree.2 upgraded]
+
for %line in %body:
if:
(not (%line is syntax tree)):
compile error at %tree.source "WUT: %s"
+
(not (%line is "Action" syntax tree)):
add %line to %new_lines
+
(%line.stub is "* %"):
add %line.2 to %conditions
+
(%line.stub == "* else %"):
add (\(else %block) with vars {block:%line.3}) to %new_lines
+
(%line.stub != "* % %"):
add %line to %new_lines
+
else:
add %line.2 to %conditions
%action = %line.3
unless (%action is "Block" syntax tree):
%action = (=lua "Block(\%action.source, \%action)")
+
add %action to %conditions
add (=lua "Action(\%conditions[1].source, unpack(\%conditions))") to %new_lines
%conditions = []
- return (\(if %body) with vars {body:=lua "Block(\%tree[2].source, unpack(\%new_lines))"})
-
+
+ return (..)
+ \(if %body) with vars {body:=lua "Block(\%tree[2].source, unpack(\%new_lines))"}
+
"when % is ? %" "when % = ? %":
%values = []
%new_lines = []
- %body = ((%tree.5 upgraded) if (%tree.5 is "Block" syntax tree) else [%tree.5 upgraded])
+ %body = (..)
+ (%tree.5 upgraded) if (%tree.5 is "Block" syntax tree) else [%tree.5 upgraded]
+
for %line in %body:
if:
(not (%line is "Action" syntax tree)):
add %line to %new_lines
+
(%line.stub is "* %"):
add %line.2 to %values
+
(%line.stub == "* else %"):
add (\(else %block) with vars {block:%line.3}) to %new_lines
+
(%line.stub != "* % %"):
add %line to %new_lines
+
else:
add %line.2 to %values
%action = %line.3
unless (%action is "Block" syntax tree):
%action = (=lua "Block(\%action.source, \%action)")
+
add %action to %values
add (=lua "Action(\%values[1].source, unpack(\%values))") to %new_lines
%values = []
- return (\(if %var is %body) with vars {var: %tree.2 upgraded, body:=lua "Block(\%tree[5].source, unpack(\%new_lines))"})
+
+ return (..)
+ \(if %var is %body) with vars {..}
+ var:%tree.2 upgraded, body:=lua "Block(\%tree[5].source, unpack(\%new_lines))" \ No newline at end of file
diff --git a/compatibility/2.5.nom b/compatibility/2.5.nom
index 68bd8dd..b2786f4 100644
--- a/compatibility/2.5.nom
+++ b/compatibility/2.5.nom
@@ -1,6 +1,9 @@
-#!/usr/bin/env nomsu -V2.5
+#!/usr/bin/env nomsu -V2.5.4.3
use "core"
use "compatibility/compatibility.nom"
-upgrade action (for %1 where %2 matches %3 %4) to "2.5" as (for %1 in %2 matching %3 %4)
-upgrade action (%1 for %2 where %3 matches %4) to "2.5" as (%1 for %2 in %3 matching %4)
+upgrade action (for %1 where %2 matches %3 %4) to "2.5" as (..)
+ for %1 in %2 matching %3 %4
+
+upgrade action (%1 for %2 where %3 matches %4) to "2.5" as (..)
+ %1 for %2 in %3 matching %4 \ No newline at end of file
diff --git a/compatibility/2.nom b/compatibility/2.nom
index a93730c..36917b1 100644
--- a/compatibility/2.nom
+++ b/compatibility/2.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V2.3.4.3
+#!/usr/bin/env nomsu -V2.5.4.3
use "core"
use "compatibility/compatibility.nom"
@@ -8,23 +8,26 @@ upgrade %tree to "2" as:
%true_body = (%tree.3 upgraded)
unless (%true_body is "Block" syntax tree):
%true_body = (=lua "Block(\%true_body.source, \%true_body)")
+
%false_body = (%tree.5 upgraded)
unless (%false_body is "Block" syntax tree):
%false_body = (=lua "Block(\%false_body.source, \%false_body)")
+
return (..)
- \(if %cond %true_body else %false_body)
- ..with vars {..}
+ \(if %cond %true_body else %false_body) with vars {..}
cond:%tree.2 upgraded, true_body:%true_body, false_body:%false_body
%need_blocks = [..]
"if % %", "unless % %", "for % in % %", "for % = % in % %", "repeat while % %"
- "repeat % times %", "repeat %", "repeat until % %", "for % in % to % by % %",
- "for % in % to % via % %", "for % in % to % %", "for % % in % %", "do %"
- "for % in recursive % %", "test %", "with % %", "result of %"
+ "repeat % times %", "repeat %", "repeat until % %", "for % in % to % by % %"
+ "for % in % to % via % %", "for % in % to % %", "for % % in % %"
+ "do %", "for % in recursive % %", "test %", "with % %", "result of %"
+
for %n in %need_blocks:
if (%tree.stub is %n):
%bits = (((% upgraded) if (% is syntax tree) else %) for % in %tree)
unless ((last in %bits) is "Block" syntax tree):
%body = (last in %bits)
%bits.(length of %bits) = (=lua "Block(\%body.source, \%body)")
- return (=lua "Action(\%tree.source, unpack(\%bits))")
+
+ return (=lua "Action(\%tree.source, unpack(\%bits))") \ No newline at end of file
diff --git a/compatibility/compatibility.nom b/compatibility/compatibility.nom
index b63357a..109b4e9 100644
--- a/compatibility/compatibility.nom
+++ b/compatibility/compatibility.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V2.5
+#!/usr/bin/env nomsu -V2.5.4.3
use "core"
use "lib/os.nom"
@@ -8,7 +8,9 @@ action [upgrade to %version via %upgrade_fn]:
%ACTION_UPGRADES = {}
action [upgrade action %stub to %version via %upgrade_fn]:
- unless (%ACTION_UPGRADES.%version): %ACTION_UPGRADES.%version = []
+ unless %ACTION_UPGRADES.%version:
+ %ACTION_UPGRADES.%version = []
+
%ACTION_UPGRADES.%version.%stub = %upgrade_fn
parse [upgrade %tree to %version as %body] as (..)
@@ -19,21 +21,31 @@ compile [upgrade action %action to %version as %body] to:
for %i in 1 to (length of %action):
if (%action.%i.type is "Var"):
%replacements.(%action.%i.1) = "\(\%tree as lua id)[\%i]"
+
local action [make tree %t]:
when:
(%t is "Var" syntax tree):
- if (%replacements.(%t.1)):
+ if %replacements.(%t.1):
return %replacements.(%t.1)
..else:
- return "\(%t.type)(\(quote "\(%t.source)"), \(quote "\(%t.1) \0\(=lua "string.format('%X', __MANGLE_INDEX)")"))"
+ return ".."
+ \(%t.type)(\(quote "\(%t.source)"), \(..)
+ quote "\(%t.1) \000\(=lua "string.format('%X', __MANGLE_INDEX)")"
+ ..)
+
(%t is syntax tree):
%args = ((make tree %) for % in %t)
add "\(\%tree as lua id).source" to %args at index 1
return "\(%t.type)(\(%args joined with ", "))"
- else: return (quote "\%t")
+
+ else:
+ return (quote "\%t")
+
return (..)
Lua ".."
- A_upgrade_action_1_to_2_via_3(\(quote %action.stub), \(%version as lua expr), function(\(\%tree as lua id))
+ A_upgrade_action_1_to_2_via_3(\(quote %action.stub), \(%version as lua expr), function(\(..)
+ \%tree as lua id
+ ..)
__MANGLE_INDEX = (__MANGLE_INDEX or 0) + 1
return \(make tree %body)
end)
@@ -44,8 +56,12 @@ action [..]
..:
local action [%ver as list] ((% as number) for % in %ver matching "[0-9]+")
%versions = {}
- for %v = % in %UPGRADES: %versions.%v = (yes)
- for %v = % in %ACTION_UPGRADES: %versions.%v = (yes)
+ for %v = % in %UPGRADES:
+ %versions.%v = (yes)
+
+ for %v = % in %ACTION_UPGRADES:
+ %versions.%v = (yes)
+
%versions = ((keys in %versions) sorted by % -> (% as list))
for %ver in %versions:
if ((%ver as list) <= (%start_version as list)): do next %ver
@@ -55,6 +71,7 @@ action [..]
%tree with % -> (..)
if ((% is "Action" syntax tree) and %ACTION_UPGRADES.%ver.(%.stub)):
return (call %ACTION_UPGRADES.%ver.(%.stub) with [%])
+
if %UPGRADES.%ver:
%tree = (call %UPGRADES.%ver with [%tree])
@@ -68,11 +85,13 @@ parse [%tree upgraded from %start_version] as (..)
parse [%tree upgraded to %end_version] as (..)
%tree upgraded from (%tree.version or (Nomsu version)) to %end_version
-parse [%tree upgraded] as (%tree upgraded from (%tree.version or (Nomsu version)) to (Nomsu version))
+parse [%tree upgraded] as (..)
+ %tree upgraded from (%tree.version or (Nomsu 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
+ run tree %tree \ No newline at end of file