From 8a3c32408733a2f5e14f8a2dbafa3f980b2f73a1 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 30 Dec 2018 19:04:34 -0800 Subject: Update to new syntax. --- compatibility/2.3.nom | 2 +- compatibility/2.4.nom | 58 ++++++++++++++++++++-------------- compatibility/2.5.5.5.nom | 11 ++++--- compatibility/2.5.nom | 6 ++-- compatibility/2.nom | 18 ++++++----- compatibility/3.5.5.6.nom | 4 +-- compatibility/3.6.nom | 37 ++++++++++++---------- compatibility/3.7.nom | 41 ++++++++++++++---------- compatibility/3.8.nom | 28 ++++++++--------- compatibility/3.nom | 6 ++-- compatibility/4.10.12.7.nom | 50 ++++++++++++++++++----------- compatibility/4.11.nom | 69 ++++++++++++++++++++++------------------- compatibility/4.12.nom | 10 +++--- compatibility/4.8.10.nom | 10 +++--- compatibility/4.9.nom | 4 +-- compatibility/compatibility.nom | 37 ++++++++++++---------- 16 files changed, 219 insertions(+), 172 deletions(-) (limited to 'compatibility') diff --git a/compatibility/2.3.nom b/compatibility/2.3.nom index daf3c36..75a5c2c 100644 --- a/compatibility/2.3.nom +++ b/compatibility/2.3.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V5.12.12.8 +#!/usr/bin/env nomsu -V6.12.12.8 # This file defines upgrades from Nomsu <2.3 to Nomsu 2.3 diff --git a/compatibility/2.4.nom b/compatibility/2.4.nom index 1d5463b..1279968 100644 --- a/compatibility/2.4.nom +++ b/compatibility/2.4.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V5.12.12.8 +#!/usr/bin/env nomsu -V6.12.12.8 # This file defines upgrades from Nomsu <2.4 to Nomsu 2.4 @@ -13,58 +13,68 @@ upgrade $tree to "2.4" as: if ((size of $tree) == 3): return $tree $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: when: - (not ($line is "Action" syntax tree)): $new_lines|add $line + (not ($line is "Action" syntax tree)): + $new_lines, add $line + ($line.stub is "*"): if ((size of $line) == 2): - $conditions|add $line.2 + $conditions, add $line.2 ..else: - $new_lines|add $line + $new_lines, add $line ($line.stub == "* else"): - $new_lines|add (\(else $block) with vars {block: $line.3}) + $new_lines, add (\(else $block) with vars {.block = $line.3}) else: - $conditions|add $line.2 + $conditions, add $line.2 $action = $line.3 unless ($action is "Block" syntax tree): $action = (=lua "SyntaxTree{type='Block', source=\$action.source, \$action}") - $conditions|add $action - $new_lines| - add (=lua "SyntaxTree{type='Action', source=\$conditions[1].source, unpack(\$conditions)}") + $conditions, add $action + $new_lines, add + =lua "SyntaxTree{type='Action', source=\$conditions[1].source, unpack(\$conditions)}" $conditions = [] - return (..) - \(when $body) with vars {..} - body: =lua "SyntaxTree{type='Block', source=\$tree[2].source, unpack(\$new_lines)}" + return + \(when $body) with vars { + .body = (=lua "SyntaxTree{type='Block', source=\$tree[2].source, unpack(\$new_lines)}") + } "if 1 is ?" "if 1 = ?": $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: when: - (not ($line is "Action" syntax tree)): $new_lines|add $line + (not ($line is "Action" syntax tree)): + $new_lines, add $line + ($line.stub is "*"): if ((size of $line) == 2): - $values|add $line.2 + $values, add $line.2 ..else: - $new_lines|add $line + $new_lines, add $line ($line.stub == "* else"): - $new_lines|add (\(else $block) with vars {block: $line.3}) + $new_lines, add (\(else $block) with vars {.block = $line.3}) else: - $values|add $line.2 + $values, add $line.2 $action = $line.3 unless ($action is "Block" syntax tree): $action = \(: $action) - $values|add $action - $new_lines| + $values, add $action + $new_lines, add (=lua "SyntaxTree{type='Action', source=\$values[1].source, unpack(\$values)}") $values = [] - return (..) - \(if $var is $body) with vars {..} - var: $tree.2 upgraded, body: =lua "SyntaxTree{type='Block', source=\$tree[5].source, unpack(\$new_lines)}" + return + \(if $var is $body) with vars { + .var = ($tree.2 upgraded), .body = (=lua "SyntaxTree{type='Block', source=\$tree[5].source, unpack(\$new_lines)}") + } diff --git a/compatibility/2.5.5.5.nom b/compatibility/2.5.5.5.nom index aff4b78..05bf705 100644 --- a/compatibility/2.5.5.5.nom +++ b/compatibility/2.5.5.5.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V5.12.12.8 +#!/usr/bin/env nomsu -V6.12.12.8 # This file defines upgrades from Nomsu <2.5.5.5 to Nomsu 2.5.5.5 @@ -6,9 +6,10 @@ use "compatibility/compatibility.nom" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -upgrade action [hash $, sha1 $] to "2.5.5.5" as (..) +upgrade action [hash $, sha1 $] to "2.5.5.5" as =lua "\(base64 decode (hash $)):gsub('.', function(c) return ('%x02'):format(c) end)" -upgrade action [file with hash $] to "2.5.5.5" as (..) - file with hash (..) - base64 (=lua "\$:gsub('..', function(xx) return string.char(tonumber(xx, 16)) end)") +upgrade action [file with hash $] to "2.5.5.5" as + file with hash + base64 + =lua "\$:gsub('..', function(xx) return string.char(tonumber(xx, 16)) end)" diff --git a/compatibility/2.5.nom b/compatibility/2.5.nom index b83f156..77fb228 100644 --- a/compatibility/2.5.nom +++ b/compatibility/2.5.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V5.12.12.8 +#!/usr/bin/env nomsu -V6.12.12.8 # This file defines upgrades from Nomsu <2.5 to Nomsu 2.5 @@ -6,8 +6,8 @@ use "compatibility/compatibility.nom" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -upgrade action (for $1 where $2 matches $3 $4) to "2.5" as (..) +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 (..) +upgrade action ($1 for $2 where $3 matches $4) to "2.5" as $1 for $2 in $3 matching $4 diff --git a/compatibility/2.nom b/compatibility/2.nom index 03e2db7..b4b0efd 100644 --- a/compatibility/2.nom +++ b/compatibility/2.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V5.12.12.8 +#!/usr/bin/env nomsu -V6.12.12.8 # This file defines upgrades from Nomsu 1 to Nomsu 2 @@ -16,21 +16,23 @@ upgrade $tree to "2" as: 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 {..} - cond: $tree.2 upgraded, true_body: $true_body, false_body: $false_body + return + \(if $cond $true_body else $false_body) with vars { + .cond = ($tree.2 upgraded), .true_body = $true_body, .false_body = $false_body + } - $need_blocks = [..] + $need_blocks = [ "if", "unless", "for 1 in", "for 1 = 2 in", "repeat while 1", "repeat 1 times" "repeat", "repeat until 1", "for 1 in 2 to 3 by", "for 1 in 2 to 3 via" "for 1 in 2 to", "for 1 2 in", "do", "for 1 in recursive", "test", "with", "result of" "when" + ] for $n in $need_blocks: if ($tree.stub is $n): $bits = [: for $ in $tree: add (($ upgraded) if ($ is syntax tree) else $)] - unless (($bits|last) is "Block" syntax tree): - $body = ($bits|last) - $bits.(size of $bits) = (..) + unless (($bits, last) is "Block" syntax tree): + $body = ($bits, last) + $bits.(size of $bits) = =lua "SyntaxTree{type='Block', source=\$body.source, \$body}" return (=lua "SyntaxTree{type='Action', source=\$tree.source, unpack(\$bits)}") diff --git a/compatibility/3.5.5.6.nom b/compatibility/3.5.5.6.nom index 0d5f307..b3ee67e 100644 --- a/compatibility/3.5.5.6.nom +++ b/compatibility/3.5.5.6.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V5.12.12.8 +#!/usr/bin/env nomsu -V6.12.12.8 # This file defines upgrades from Nomsu <3.5.5.6 to Nomsu 3.5.5.6 @@ -6,6 +6,6 @@ use "compatibility/compatibility.nom" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -upgrade action "traceback" to "3.5.5.6" via (..) +upgrade action "traceback" to "3.5.5.6" via for $tree: compile error at $tree "'traceback' has been deprecated." diff --git a/compatibility/3.6.nom b/compatibility/3.6.nom index d2f9bb6..8fb52b5 100644 --- a/compatibility/3.6.nom +++ b/compatibility/3.6.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V5.12.12.8 +#!/usr/bin/env nomsu -V6.12.12.8 # This file defines upgrades from Nomsu <3.6 to 3.6 @@ -6,24 +6,27 @@ use "compatibility/compatibility.nom" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -upgrade action [..] +upgrade action [ append $item to $list, add $item to $list, to $list add $item, to $list append $item -..to "3.6" as ($list|add $item) +] to "3.6" as ($list, add $item) -upgrade action [add $item to $list at index $i] to "3.6" as (..) - $list|at index $i add $item +upgrade action [add $item to $list at index $i] to "3.6" as + $list, at index $i add $item -upgrade action [pop from $list, remove last from $list] to "3.6" as ($list|pop) -upgrade action [remove index $index from $list] to "3.6" as (..) - $list|remove index $index -upgrade action [to $1 write $2, $1 <-write $2] to "3.6" as ($1|add $2) -upgrade action [to $1 write $2 joined by $3] to "3.6" as ($1|add $2 joined by $3) -upgrade action [declare locals in $lua] to "3.6" as ($lua|declare locals) -upgrade action [declare locals $locs in $lua] to "3.6" as (..) - $lua|declare locals $locs +upgrade action [pop from $list, remove last from $list] to "3.6" as ($list, pop) +upgrade action [remove index $index from $list] to "3.6" as + $list, remove index $index +upgrade action [to $1 write $2, $1 <-write $2] to "3.6" as ($1, add $2) +upgrade action [to $1 write $2 joined by $3] to "3.6" as +..($1, add $2 joined by $3) -upgrade action [add free vars $vars to $lua] to "3.6" as (..) - $lua|add free vars $vars +upgrade action [declare locals in $lua] to "3.6" as ($lua, declare locals) -upgrade action [remove free vars $vars from $lua] to "3.6" as (..) - $lua|remove free vars $vars +upgrade action [declare locals $locs in $lua] to "3.6" as + $lua, declare locals $locs + +upgrade action [add free vars $vars to $lua] to "3.6" as + $lua, add free vars $vars + +upgrade action [remove free vars $vars from $lua] to "3.6" as + $lua, remove free vars $vars diff --git a/compatibility/3.7.nom b/compatibility/3.7.nom index 777585b..e81b9dc 100644 --- a/compatibility/3.7.nom +++ b/compatibility/3.7.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V5.12.12.8 +#!/usr/bin/env nomsu -V6.12.12.8 # This file defines upgrades from Nomsu <3.7 to 3.7 @@ -6,28 +6,37 @@ use "compatibility/compatibility.nom" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -upgrade action [$index st to last in $list] to "3.7" as ($list|$index st to last) -upgrade action [$index nd to last in $list] to "3.7" as ($list|$index nd to last) -upgrade action [$index rd to last in $list] to "3.7" as ($list|$index rd to last) -upgrade action [$index th to last in $list] to "3.7" as ($list|$index rd th last) -upgrade action [last in $list] to "3.7" as ($list|last) -upgrade action [first in $list] to "3.7" as ($list|first) -upgrade action [$item is in $list, $list contains $item, $list has $item] to \ -.."3.7" as ($list|has $item) +upgrade action [$index st to last in $list] to "3.7" as +..($list, $index st to last) -upgrade action [..] +upgrade action [$index nd to last in $list] to "3.7" as +..($list, $index nd to last) + +upgrade action [$index rd to last in $list] to "3.7" as +..($list, $index rd to last) + +upgrade action [$index th to last in $list] to "3.7" as +..($list, $index rd th last) + +upgrade action [last in $list] to "3.7" as ($list, last) + +upgrade action [first in $list] to "3.7" as ($list, first) +upgrade action [$item is in $list, $list contains $item, $list has $item] to +.."3.7" as ($list, has $item) + +upgrade action [ $item isn't in $list, $item is not in $list, $list doesn't contain $item $list does not contain $item, $list doesn't have $item, $list does not have $item -..to "3.7" as (not ($list|has $item)) +] to "3.7" as (not ($list, has $item)) -upgrade action [$list has key $index, $list has index $index] to "3.7" as (..) +upgrade action [$list has key $index, $list has index $index] to "3.7" as $list.$index != (nil) -upgrade action [..] +upgrade action [ $list doesn't have key $index, $list does not have key $index $list doesn't have index $index, $list does not have index $index -..to "3.7" as ($list.$index == (nil)) +] to "3.7" as ($list.$index == (nil)) -upgrade action [..] +upgrade action [ number of keys in $list, len $list, || $list ||, length $list, length of $list -..to "3.7" as (size of $list) +] to "3.7" as (size of $list) diff --git a/compatibility/3.8.nom b/compatibility/3.8.nom index 7de2c71..3362a9c 100644 --- a/compatibility/3.8.nom +++ b/compatibility/3.8.nom @@ -1,19 +1,19 @@ -#!/usr/bin/env nomsu -V5.12.12.8 +#!/usr/bin/env nomsu -V6.12.12.8 # This file defines upgrades from Nomsu <3.8 to 3.8 (Text method changes) -upgrade action [$texts joined with $glue] to "3.8" as ($texts|joined with $glue) -upgrade action [$texts joined, joined $texts] to "3.8" as ($texts|joined) -upgrade action [byte $i of $text] to "3.8" as ($text|byte $i) -upgrade action [bytes $start to $stop of $text] to "3.8" as (..) - $text|bytes $start to $stop -upgrade action [bytes of $text] to "3.8" as ($text|bytes) -upgrade action [capitalized $text, $text capitalized] to "3.8" as (..) - $text|capitalized -upgrade action [uppercase $text, $text uppercase] to "3.8" as ($text|uppercase) -upgrade action [..] +upgrade action [$texts joined with $glue] to "3.8" as ($texts, joined with $glue) +upgrade action [$texts joined, joined $texts] to "3.8" as ($texts, joined) +upgrade action [byte $i of $text] to "3.8" as ($text, byte $i) +upgrade action [bytes $start to $stop of $text] to "3.8" as + $text, bytes $start to $stop +upgrade action [bytes of $text] to "3.8" as ($text, bytes) +upgrade action [capitalized $text, $text capitalized] to "3.8" as + $text, capitalized +upgrade action [uppercase $text, $text uppercase] to "3.8" as ($text, uppercase) +upgrade action [ $text with $sub instead of $patt, $text with $patt replaced by $sub $text s/ $patt / $sub -..to "3.8" as ($text|with $patt -> $sub) -upgrade action [$text matches $pattern] to "3.8" as ($text|matches $pattern) -upgrade action [$text matching $pattern] to "3.8" as ($text|matching $pattern).1 +] to "3.8" as ($text, with $patt -> $sub) +upgrade action [$text matches $pattern] to "3.8" as ($text, matches $pattern) +upgrade action [$text matching $pattern] to "3.8" as ($text, matching $pattern).1 diff --git a/compatibility/3.nom b/compatibility/3.nom index d6d71ad..6086bd0 100644 --- a/compatibility/3.nom +++ b/compatibility/3.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V5.12.12.8 +#!/usr/bin/env nomsu -V6.12.12.8 # This file defines upgrades from Nomsu <=2 to Nomsu 3 @@ -9,7 +9,7 @@ use "compatibility/compatibility.nom" 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 (..) +upgrade action "as" to "3" via for $tree: - compile error at $tree "Object API has changed and 'as' is no longer supported." \ + compile error at $tree "Object API has changed and 'as' is no longer supported." .."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 c5abe1a..228fee9 100644 --- a/compatibility/4.10.12.7.nom +++ b/compatibility/4.10.12.7.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V5.12.12.8 +#!/usr/bin/env nomsu -V6.12.12.8 # This file defines upgrades from Nomsu <4.10.12.7 to 4.10.12.7 use "compatibility/compatibility.nom" @@ -6,42 +6,53 @@ use "compatibility/compatibility.nom" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ upgrade action ($ as lua statements) to "4.10.12.7" as ($ as lua) -upgrade action ($ as lua return) to "4.10.12.7" as (..) +upgrade action ($ as lua return) to "4.10.12.7" as =lua "\$.type == 'Block' and \($ as lua) or 'return '..\($ as lua expr)" + upgrade action (Lua value $) to "4.10.12.7" as (Lua $) + upgrade action ($e for $ in $items) to "4.10.12.7" as [: for $ in $items: add $e] -upgrade action ($e for $k = $v in $items) to "4.10.12.7" as [..] +upgrade action ($e for $k = $v in $items) to "4.10.12.7" as [ : for $k = $v in $items: add $e +] -upgrade action ($e for $i in $start to $stop) to "4.10.12.7" as [..] +upgrade action ($e for $i in $start to $stop) to "4.10.12.7" as [ : for $i in $start to $stop: add $e +] -upgrade action ($e for $i in $start to $stop by $step) to "4.10.12.7" as [..] +upgrade action ($e for $i in $start to $stop by $step) to "4.10.12.7" as [ : for $i in $start to $stop by $step: add $e +] -upgrade action ($e for $i in $start to $stop via $step) to "4.10.12.7" as [..] +upgrade action ($e for $i in $start to $stop via $step) to "4.10.12.7" as [ : for $i in $start to $stop by $step: add $e +] -upgrade action ($k = $v for $ in $items) to "4.10.12.7" as {..} +upgrade action ($k = $v for $ in $items) to "4.10.12.7" as { : for $ in $items: add $k = $v +} -upgrade action ($k = $v for $k0 = $v0 in $items) to "4.10.12.7" as {..} +upgrade action ($k = $v for $k0 = $v0 in $items) to "4.10.12.7" as { : for $k0 = $v0 in $items: add $k = $v +} -upgrade action ($k = $v for $i in $start to $stop) to "4.10.12.7" as {..} +upgrade action ($k = $v for $i in $start to $stop) to "4.10.12.7" as { : for $i in $start to $stop: add $k = $v +} -upgrade action ($k = $v for $i in $start to $stop by $step) to "4.10.12.7" as {..} +upgrade action ($k = $v for $i in $start to $stop by $step) to "4.10.12.7" as { : for $i in $start to $stop by $step: add $k = $v +} -upgrade action ($k = $v for $i in $start to $stop via $step) to "4.10.12.7" as {..} +upgrade action ($k = $v for $i in $start to $stop via $step) to "4.10.12.7" as { : for $i in $start to $stop by $step: add $k = $v +} -upgrade action (parse $text from $filename) to "4.10.12.7" as (..) +upgrade action (parse $text from $filename) to "4.10.12.7" as (NomsuCode from (Source $filename 1 (size of $text)) $text) parsed 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 (..) +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, @@ -61,9 +72,10 @@ upgrade $tree to "4.10.12.7" as: $i += 1 return --- (insert chunk) --- - [$chunk1, $chunk2] = [..] - SyntaxTree {type: "Block", source: $first_chunk.source} - SyntaxTree {type: "Block", source: $first_chunk.source} + [$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 @@ -71,8 +83,10 @@ upgrade $tree to "4.10.12.7" as: 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} + $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 diff --git a/compatibility/4.11.nom b/compatibility/4.11.nom index 38751d9..8f6aacc 100644 --- a/compatibility/4.11.nom +++ b/compatibility/4.11.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V5.12.12.8 +#!/usr/bin/env nomsu -V6.12.12.8 # This file defines upgrades from Nomsu <4.11 to Nomsu 4.11 (overhaul of function literals, deleting (if all of ...), etc. shorthand) @@ -8,16 +8,16 @@ use "compatibility/compatibility.nom" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Overhaul of function literals: -upgrade action "call 1 with" to "4.11" via (..) +upgrade action "call 1 with" to "4.11" via for ($tree $end_version): - $tree2 = {type: "Action", source: $tree.source, 1: $tree.2} + $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 (..) +upgrade action "set" to "4.11" via for ($tree $end_version): [$lhs, $rhs] = [\[], \[]] $lhs.source = $tree.2.source @@ -25,71 +25,76 @@ upgrade action "set" to "4.11" via (..) 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}) + + return + SyntaxTree { + .type = "Action", .source = $tree.source, .1 = $lhs, .2 = "=", .3 = $rhs + } -upgrade action "1 with 2 ~>" to "4.11" via (..) +upgrade action "1 with 2 ~>" to "4.11" via for $tree: - compile error at $tree "This method has been deprecated." \ + compile error at $tree "This method has been deprecated." .."Perhaps this could be use %tree::map instead." # Changing filesystem API: -upgrade action (for file $f in $path $body) to "4.11" as (..) +upgrade action (for file $f in $path $body) to "4.11" as for $f in (files for $path) $body -upgrade action ($expr for file $f in $path) to "4.11" as [..] +upgrade action ($expr for file $f in $path) to "4.11" as [ : for $f in (files for $path): add $expr +] -upgrade action (line $n in $text) to "4.11" as ($text|line $n) -upgrade action (line number of $pos in $text) to "4.11" as (..) - $text|line number at $pos +upgrade action (line $n in $text) to "4.11" as ($text, line $n) +upgrade action (line number of $pos in $text) to "4.11" as + $text, line number at $pos # Deduplicating goto labels: upgrade action [=== $label ===, *** $label ***] to "4.11" as (--- $label ---) -upgrade action [===stop $label ===, ***stop $label ***] to "4.11" as (..) +upgrade action [===stop $label ===, ***stop $label ***] to "4.11" as ---stop $label --- -upgrade action [===next $label ===, ***next $label ***] to "4.11" as (..) +upgrade action [===next $label ===, ***next $label ***] to "4.11" as ---next $label --- # Deprecating shorthand functions: -upgrade action [if all of $items $body, if all of $items then $body] to "4.11" as (..) +upgrade action [if all of $items $body, if all of $items then $body] to "4.11" as if (all of $items) $body -upgrade action [unless all of $items $body, unless all of $items then $body] to \ +upgrade action [unless all of $items $body, unless all of $items then $body] to .."4.11" as (if (not (all of $items)) $body) -upgrade action [if any of $items $body, if any of $items then $body] to "4.11" as (..) +upgrade action [if any of $items $body, if any of $items then $body] to "4.11" as if (any of $items) $body -upgrade action [unless any of $items $body, unless any of $items then $body] to \ +upgrade action [unless any of $items $body, unless any of $items then $body] to .."4.11" as (if (not (any of $items)) $body) -upgrade action [if none of $items $body, if none of $items then $body] to "4.11" \ +upgrade action [if none of $items $body, if none of $items then $body] to "4.11" ..as (if (not (any of $items)) $body) -upgrade action [unless none of $items $body, unless none of $items then $body] to \ +upgrade action [unless none of $items $body, unless none of $items then $body] to .."4.11" as (if (any of $items) $body) -upgrade action [..] +upgrade action [ if all of $items $body else $else, if all of $items then $body else $else -..to "4.11" as (if (all of $items) $body else $else) +] to "4.11" as (if (all of $items) $body else $else) -upgrade action [..] +upgrade action [ unless all of $items $body else $else, unless all of $items then $body else $else -..to "4.11" as (if (not (all of $items)) $body else $else) +] to "4.11" as (if (not (all of $items)) $body else $else) -upgrade action [..] +upgrade action [ if any of $items $body else $else, if any of $items then $body else $else -..to "4.11" as (if (any of $items) $body else $else) +] to "4.11" as (if (any of $items) $body else $else) -upgrade action [..] +upgrade action [ unless any of $items $body else $else, unless any of $items then $body else $else -..to "4.11" as (if (not (any of $items)) $body else $else) +] to "4.11" as (if (not (any of $items)) $body else $else) -upgrade action [..] +upgrade action [ if none of $items $body else $else, if none of $items then $body else $else -..to "4.11" as (if (not (any of $items)) $body else $else) +] to "4.11" as (if (not (any of $items)) $body else $else) -upgrade action [..] +upgrade action [ unless none of $items $body else $else, unless none of $items then $body else $else -..to "4.11" as (if (any of $items) $body else $else) +] to "4.11" as (if (any of $items) $body else $else) diff --git a/compatibility/4.12.nom b/compatibility/4.12.nom index 63525c6..8ab69ae 100644 --- a/compatibility/4.12.nom +++ b/compatibility/4.12.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V5.12.12.8 +#!/usr/bin/env nomsu -V6.12.12.8 # This file defines upgrades from Nomsu <4.11 to Nomsu 4.11 (overhaul of function literals, deleting (if all of ...), etc. shorthand) @@ -7,12 +7,12 @@ use "compatibility/compatibility.nom" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -upgrade action "do next repeat" to "4.12" via (..) +upgrade action "do next repeat" to "4.12" via for $tree: - compile error at $tree "This method has been deprecated." \ + compile error at $tree "This method has been deprecated." .."Use either (do next) or (go to (label)) instead." -upgrade action "stop repeating" to "4.12" via (..) +upgrade action "stop repeating" to "4.12" via for $tree: - compile error at $tree "This method has been deprecated." \ + compile error at $tree "This method has been deprecated." .."Use either (stop) or (go to (label)) instead." diff --git a/compatibility/4.8.10.nom b/compatibility/4.8.10.nom index 58b9818..d250f89 100644 --- a/compatibility/4.8.10.nom +++ b/compatibility/4.8.10.nom @@ -1,11 +1,11 @@ -#!/usr/bin/env nomsu -V5.12.12.8 +#!/usr/bin/env nomsu -V6.12.12.8 # This file defines upgrades from Nomsu <4.8.10 to 4.8.10 (renaming "action" -> "means") use "compatibility/compatibility.nom" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -upgrade action "local action" to "4.8.10" via (..) +upgrade action "local action" to "4.8.10" via for ($tree $end_version): $spec = $tree.3 $body = $tree.4 @@ -19,7 +19,7 @@ upgrade action "local action" to "4.8.10" via (..) else: return \($spec means $body) -upgrade action "action" to "4.8.10" via (..) +upgrade action "action" to "4.8.10" via for ($tree $end_version): $spec = $tree.2 $body = $tree.3 @@ -36,7 +36,7 @@ upgrade action "action" to "4.8.10" via (..) ..else: return \($spec's meaning) -upgrade action "compile 1 to" to "4.8.10" via (..) +upgrade action "compile 1 to" to "4.8.10" via for ($tree $end_version): $spec = $tree.2 $body = $tree.4 @@ -50,7 +50,7 @@ upgrade action "compile 1 to" to "4.8.10" via (..) else: return \($spec compiles to $body) -upgrade action "parse 1 as" to "4.8.10" via (..) +upgrade action "parse 1 as" to "4.8.10" via for ($tree $end_version): $spec = $tree.2 $body = $tree.4 diff --git a/compatibility/4.9.nom b/compatibility/4.9.nom index 26a20fb..5f8c28c 100644 --- a/compatibility/4.9.nom +++ b/compatibility/4.9.nom @@ -1,11 +1,11 @@ -#!/usr/bin/env nomsu -V5.12.12.8 +#!/usr/bin/env nomsu -V6.12.12.8 # This file defines upgrades from Nomsu <4.9 to 4.9 use "compatibility/compatibility.nom" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -upgrade action "if" to "4.9" via (..) +upgrade action "if" to "4.9" via 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 356a8e0..bc34c4f 100644 --- a/compatibility/compatibility.nom +++ b/compatibility/compatibility.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V5.12.12.8 +#!/usr/bin/env nomsu -V6.12.12.8 # This file contains code for defining ways to upgrade code between different versions of Nomsu. @@ -14,7 +14,7 @@ $ACTION_UPGRADES = ({} with fallback $ -> {}) 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 $tree to $version as $body) parses as upgrade to $version via (($ $end_version) -> ($ with $tree -> $body)) (upgrade action $actions to $version as $body) compiles to: @@ -40,29 +40,30 @@ externally (upgrade action $stub to $version via $upgrade_fn) means: $args = [] for $k = $v in $t: if ((type of $k) == "number"): - $args|add (make tree $v) + $args, add (make tree $v) ..else: - $args|add "\($k)=\(make tree $v)" - return "SyntaxTree{\($args|joined with ", ")}" + $args, add "\($k)=\(make tree $v)" + return "SyntaxTree{\($args, joined with ", ")}" else: return (quote $t) unless ("\$lua" == ""): - $lua|add "\n" + $lua, add "\n" $retval = (make tree $body) - $lua|add (..) - Lua " + $lua, add + Lua (" upgrade_action_1_to_2_via(\(quote $action.stub), \($version as lua expr), function(\(\$tree as lua id)) return \$retval - end)" + end) + ") return $lua -externally [..] +externally [ $tree upgraded from $start_version to $end_version $tree upgraded to $end_version from $start_version -..all mean: +] all mean: unless ($tree is syntax tree): return $tree ($ver as list) means (($ as number) for $ in $ver matching "[0-9]+") $versions = {} @@ -77,19 +78,21 @@ externally [..] 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)): - $with_upgraded_args = {..} + $with_upgraded_args = { : for $k = $v in $: add $k = ($v upgraded from $start_version to $end_version) + } set $with_upgraded_args's metatable to ($'s metatable) return ($ACTION_UPGRADES.$ver.($.stub) $with_upgraded_args $end_version) if $UPGRADES.$ver: - $with_upgraded_args = {..} + $with_upgraded_args = { : 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 = ($UPGRADES.$ver $with_upgraded_args $end_version) @@ -101,13 +104,13 @@ externally [..] return $tree -externally ($tree upgraded from $start_version) means (..) +externally ($tree upgraded from $start_version) means $tree upgraded from $start_version to (Nomsu version) -externally ($tree upgraded to $end_version) means (..) +externally ($tree upgraded to $end_version) means $tree upgraded from ($tree.version or (Nomsu version)) to $end_version -externally ($tree upgraded) means (..) +externally ($tree upgraded) means $tree upgraded from ($tree.version or (Nomsu version)) to (Nomsu version) externally (use $path from version $version) means: -- cgit v1.2.3