aboutsummaryrefslogtreecommitdiff
path: root/compatibility
diff options
context:
space:
mode:
Diffstat (limited to 'compatibility')
-rw-r--r--compatibility/2.3.nom2
-rw-r--r--compatibility/3.5.5.6.nom4
-rw-r--r--compatibility/3.nom2
-rw-r--r--compatibility/4.10.12.7.nom38
-rw-r--r--compatibility/4.11.nom24
-rw-r--r--compatibility/4.8.10.nom8
-rw-r--r--compatibility/4.9.nom2
-rw-r--r--compatibility/compatibility.nom4
8 files changed, 57 insertions, 27 deletions
diff --git a/compatibility/2.3.nom b/compatibility/2.3.nom
index 7d8fae0..a07729c 100644
--- a/compatibility/2.3.nom
+++ b/compatibility/2.3.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11
#
This file defines upgrades from Nomsu <2.3 to Nomsu 2.3
diff --git a/compatibility/3.5.5.6.nom b/compatibility/3.5.5.6.nom
index db7b3a0..aebd0a5 100644
--- a/compatibility/3.5.5.6.nom
+++ b/compatibility/3.5.5.6.nom
@@ -7,7 +7,7 @@ use "compatibility/compatibility.nom"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
upgrade action "traceback" to "3.5.5.6" via (..)
- [%] -> (barf "'traceback' has been deprecated")
+ -> (barf "'traceback' has been deprecated")
upgrade action "traceback 1" to "3.5.5.6" via (..)
- [%] -> (barf "'traceback 1' has been deprecated")
+ -> (barf "'traceback 1' has been deprecated")
diff --git a/compatibility/3.nom b/compatibility/3.nom
index 1f23897..69f8d25 100644
--- a/compatibility/3.nom
+++ b/compatibility/3.nom
@@ -10,4 +10,4 @@ upgrade action (method %spec %body) to "3" as (my action %spec %body)
upgrade action (me) to "3" as %me
upgrade action (@) to "3" as %me
upgrade action "as" to "3" via (..)
- [] -> (barf "Object API has changed. Use (%obj::action ...) instead of (as %obj: action ...)")
+ -> (barf "Object API has changed. Use (%obj::action ...) instead of (as %obj: action ...)")
diff --git a/compatibility/4.10.12.7.nom b/compatibility/4.10.12.7.nom
index 56cdb1e..2e42bdc 100644
--- a/compatibility/4.10.12.7.nom
+++ b/compatibility/4.10.12.7.nom
@@ -44,24 +44,32 @@ upgrade action (% as lua statements) to "4.10.12.7" as (% as lua)
upgrade action (compile error at %pos %err hint %hint) to "4.10.12.7" as (..)
compile error at %pos %err %hint
+# In old code, it was okay to have imports at the top of the file in the same chunk,
+ but changes to the API now require imports to be in their own file chunk in order
+ for compilation to work properly.
upgrade %tree to "4.10.12.7" as:
if (%tree.type == "FileChunks"):
%first_chunk = %tree.1
- %first_has_use = (no)
%i = 1
- repeat while (%i < (size of %first_chunk)):
- if %first_has_use:
- if ((%first_chunk.%i.type != "Action") or (%first_chunk.%i.stub != "use")):
- %chunk2 = (%SyntaxTree {type: "Block"})
- for %j in %i to (size of %first_chunk.%i):
- %chunk2.((size of %chunk2) + 1) = %first_chunk.%i.%j
-
- for %j in %i to (size of %first_chunk.%i):
- %first_chunk.%i.%j = (nil)
-
- %table.insert %tree 2 %chunk2
- return %tree
+ %has_use = (no)
+ repeat while (%i <= (size of %first_chunk)):
+ if ((%first_chunk.%i.type == "Action") and (%first_chunk.%i.stub == "use")):
+ %has_use = (yes)
..else:
- if ((%first_chunk.type == "Action") and (%first_chunk.stub == "use")):
- %first_has_use = (yes)
+ if %has_use: go to (insert chunk)
%i += 1
+ return
+
+ === (insert chunk) ===
+ [%chunk1, %chunk2] = [..]
+ SyntaxTree {type: "Block", source: %first_chunk.source}
+ SyntaxTree {type: "Block", source: %first_chunk.source}
+ for %j in 1 to (%i - 1):
+ %chunk1.%j = %first_chunk.%j
+ for %j in %i to (size of %first_chunk):
+ %chunk2.(%j - %i + 1) = %first_chunk.%j
+
+ %new_tree = (SyntaxTree {source: %tree.source, type: "FileChunks", 1: %chunk1, 2: %chunk2})
+ for %i in 2 to (size of %tree):
+ %new_tree.(%i + 1) = %tree.%i
+ return %new_tree
diff --git a/compatibility/4.11.nom b/compatibility/4.11.nom
index 320fe5e..fdf6660 100644
--- a/compatibility/4.11.nom
+++ b/compatibility/4.11.nom
@@ -1,12 +1,34 @@
#!/usr/bin/env nomsu -V4.11
#
This file defines upgrades from Nomsu <4.11 to Nomsu 4.11
- (deleting (if all of ...), etc. shorthand)
+ (overhaul of function literals, deleting (if all of ...), etc. shorthand)
use "compatibility/compatibility.nom"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# Overhaul of function literals:
+upgrade action "call 1 with" to "4.11" via (..)
+ for (%tree %end_version):
+ %tree2 = {type: "Action", source: %tree.source, 1: %tree.2}
+ for %arg in %tree.4 at %i:
+ %tree2.(%i + 1) = %arg
+ return (SyntaxTree %tree2)
+
+upgrade action (-> %yield_value) to "4.11" as (yield %yield_value)
+
+# Replace set {%x:1, %y:2} with [%x, %y] = [1, 2]
+upgrade action "set" to "4.11" via (..)
+ for (%tree %end_version):
+ [%lhs, %rhs] = [\[], \[]]
+ %lhs.source = %tree.(2).source
+ %rhs.source = %tree.(2).source
+ for %entry in %tree.2 at %i:
+ %lhs.%i = %entry.1
+ %rhs.%i = %entry.2
+ return (SyntaxTree {type: "Action", source: %tree.source, 1: %lhs, 2: "=", 3: %rhs})
+
+# Deprecating shorthand functions:
upgrade action [if all of %items %body, if all of %items then %body] to "4.11" as (..)
if (all of %items) %body
diff --git a/compatibility/4.8.10.nom b/compatibility/4.8.10.nom
index c0c17dc..9049830 100644
--- a/compatibility/4.8.10.nom
+++ b/compatibility/4.8.10.nom
@@ -6,7 +6,7 @@ use "compatibility/compatibility.nom"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
upgrade action "local action" to "4.8.10" via (..)
- [%tree, %end_version] ->:
+ for (%tree %end_version):
%spec = %tree.3
%body = %tree.4
if %spec.type is:
@@ -20,7 +20,7 @@ upgrade action "local action" to "4.8.10" via (..)
return \(%spec means %body)
upgrade action "action" to "4.8.10" via (..)
- [%tree, %end_version] ->:
+ for (%tree %end_version):
%spec = %tree.2
%body = %tree.3
if %body:
@@ -37,7 +37,7 @@ upgrade action "action" to "4.8.10" via (..)
return \(%spec's meaning)
upgrade action "compile 1 to" to "4.8.10" via (..)
- [%tree, %end_version] ->:
+ for (%tree %end_version):
%spec = %tree.2
%body = %tree.4
if %spec.type is:
@@ -51,7 +51,7 @@ upgrade action "compile 1 to" to "4.8.10" via (..)
return \(%spec compiles to %body)
upgrade action "parse 1 as" to "4.8.10" via (..)
- [%tree, %end_version] ->:
+ for (%tree %end_version):
%spec = %tree.2
%body = %tree.4
if %spec.type is:
diff --git a/compatibility/4.9.nom b/compatibility/4.9.nom
index e72b159..ab58a86 100644
--- a/compatibility/4.9.nom
+++ b/compatibility/4.9.nom
@@ -6,6 +6,6 @@ use "compatibility/compatibility.nom"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
upgrade action "if" to "4.9" via (..)
- [%tree, %end_version] ->:
+ for (%tree %end_version):
if ((size of %tree) > 2): return %tree
return \(when %tree.2)
diff --git a/compatibility/compatibility.nom b/compatibility/compatibility.nom
index 65e75fc..c7895e0 100644
--- a/compatibility/compatibility.nom
+++ b/compatibility/compatibility.nom
@@ -15,7 +15,7 @@ externally (upgrade action %stub to %version via %upgrade_fn) means:
%ACTION_UPGRADES.%version.%stub = %upgrade_fn
(upgrade %tree to %version as %body) parses as (..)
- upgrade to %version via ([%, %end_version] -> (% with %tree -> %body))
+ upgrade to %version via ((% %end_version) -> (% with %tree -> %body))
(upgrade action %actions to %version as %body) compiles to:
if (%actions is "Action" syntax tree):
@@ -91,7 +91,7 @@ externally [..]
for %k = %v in %tree:
add %k = (%v upgraded from %start_version to %end_version)
set %with_upgraded_args's metatable to (%tree's metatable)
- %tree = (call %UPGRADES.%ver with [%with_upgraded_args, %end_version])
+ %tree = (%UPGRADES.%ver %with_upgraded_args %end_version)
%tree.shebang = "#!/usr/bin/env nomsu -V\%end_version\n"
return %tree