aboutsummaryrefslogtreecommitdiff
path: root/compatibility
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-07-18 01:27:56 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-07-18 01:28:17 -0700
commitd5cfaa37be9e278c44a25ef448a071390597306e (patch)
tree7fbe78b5153bb9c761c283533943ab80da3a1844 /compatibility
parentc7c657d38f999901225b33482ef3a15994526feb (diff)
Upgrading to version 2.3 (main change: "=" instead of "<-" for
assignment)
Diffstat (limited to 'compatibility')
-rw-r--r--compatibility/2.3.nom16
-rw-r--r--compatibility/2.nom18
-rw-r--r--compatibility/compatibility.nom36
3 files changed, 43 insertions, 27 deletions
diff --git a/compatibility/2.3.nom b/compatibility/2.3.nom
new file mode 100644
index 0000000..d405181
--- /dev/null
+++ b/compatibility/2.3.nom
@@ -0,0 +1,16 @@
+#!/usr/bin/env nomsu -V2.3
+use "core"
+use "compatibility/compatibility.nom"
+
+upgrade action (%a = %b) to "2.3" as (%a == %b)
+upgrade action (<- %) to "2.3" as (set %)
+upgrade action (assign %) to "2.3" as (set %)
+upgrade action (%a <- %b) to "2.3" as (%a = %b)
+upgrade action (external %a <- %b) to "2.3" as (external %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 *<- %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)
diff --git a/compatibility/2.nom b/compatibility/2.nom
index 409f374..9903ddd 100644
--- a/compatibility/2.nom
+++ b/compatibility/2.nom
@@ -1,30 +1,30 @@
-#!/usr/bin/env nomsu -V2
+#!/usr/bin/env nomsu -V2.3.4.3
use "core"
use "compatibility/compatibility.nom"
upgrade %tree to "2" as:
unless (%tree is "Action" syntax tree): return
if (all[%tree.stub is "if % % else %", not (%tree.3 is "Var" syntax tree), not (%tree.5 is "Var" syntax tree)]):
- %true_body <- (%tree.3 upgraded from "1.2")
+ %true_body = (%tree.3 upgraded from "1.2")
unless (%true_body is "Block" syntax tree):
- %true_body <- (=lua "Block(\%true_body.source, \%true_body)")
- %false_body <- (%tree.5 upgraded from "1.2")
+ %true_body = (=lua "Block(\%true_body.source, \%true_body)")
+ %false_body = (%tree.5 upgraded from "1.2")
unless (%false_body is "Block" syntax tree):
- %false_body <- (=lua "Block(\%false_body.source, \%false_body)")
+ %false_body = (=lua "Block(\%false_body.source, \%false_body)")
return (..)
\(if %cond %true_body else %false_body)
..with vars {..}
cond:%tree.2 upgraded from "1.2", true_body:%true_body, false_body:%false_body
- %need_blocks <- [..]
+ %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 %"
for %n in %need_blocks:
if ((%tree.stub is %n) and (not ((last in %tree) is "Var" syntax tree))):
- %bits <- (((% upgraded from "1.2") if (% is syntax tree) else %) for % in %tree)
+ %bits = (((% upgraded from "1.2") 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)")
+ %body = (last in %bits)
+ %bits.(length of %bits) = (=lua "Block(\%body.source, \%body)")
return (=lua "Action(\%tree.source, unpack(\%bits))")
diff --git a/compatibility/compatibility.nom b/compatibility/compatibility.nom
index 1e68f35..9482e32 100644
--- a/compatibility/compatibility.nom
+++ b/compatibility/compatibility.nom
@@ -1,24 +1,24 @@
-#!/usr/bin/env nomsu -V2.2.4.3
+#!/usr/bin/env nomsu -V2.3.4.3
use "core"
use "lib/os.nom"
-%UPGRADES <- {}
+%UPGRADES = {}
action [upgrade to %version via %upgrade_fn]:
- %UPGRADES.%version <- %upgrade_fn
+ %UPGRADES.%version = %upgrade_fn
-%ACTION_UPGRADES <- {}
+%ACTION_UPGRADES = {}
action [upgrade action %stub to %version via %upgrade_fn]:
- unless (%ACTION_UPGRADES.%version): %ACTION_UPGRADES.%version <- []
- %ACTION_UPGRADES.%version.%stub <- %upgrade_fn
+ unless (%ACTION_UPGRADES.%version): %ACTION_UPGRADES.%version = []
+ %ACTION_UPGRADES.%version.%stub = %upgrade_fn
parse [upgrade %tree to %version as %body] as (..)
upgrade to %version via ([%] -> (% with %tree -> %body))
compile [upgrade action %action to %version as %body] to:
- %replacements <- {}
+ %replacements = {}
for %i in 1 to (length of %action):
if (%action.%i.type is "Var"):
- %replacements.(%action.%i.1) <- "\(\%tree as lua id)[\%i]"
+ %replacements.(%action.%i.1) = "\(\%tree as lua id)[\%i]"
local action [make tree %t]:
when:
* (%t is "Var" syntax tree):
@@ -27,7 +27,7 @@ compile [upgrade action %action to %version as %body] to:
..else:
return "\(%t.type)(\(quote "\(%t.source)"), \(quote "\(%t.1) \0\(=lua "string.format('%X', __MANGLE_INDEX)")"))"
* (%t is syntax tree):
- %args <- ((make tree %) for % in %t)
+ %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")
@@ -43,20 +43,20 @@ action [..]
%tree upgraded to %end_version from %start_version
..:
local action [%ver as list] ((% as number) for % where %ver matches "[0-9]+")
- %versions <- {}
- for %v = % in %UPGRADES: %versions.%v <- (yes)
- for %v = % in %ACTION_UPGRADES: %versions.%v <- (yes)
- %versions <- ((keys in %versions) sorted by % -> (% as list))
+ %versions = {}
+ 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
if ((%ver as list) > (%end_version as list)): stop %ver
if %ACTION_UPGRADES.%ver:
- %tree <- (..)
+ %tree = (..)
%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])
+ %tree = (call %UPGRADES.%ver with [%tree])
return %tree
@@ -72,7 +72,7 @@ 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)
+ %file = (read file %filename)
+ %tree = (parse %file from %filename)
+ %tree = (upgrade %tree from %version)
run tree %tree