nomsu/lib/compatibility/4.10.12.7.nom
Bruce Hill a1849da175 Autoformat (mostly just to do with the new
blank-line-after-end-of-multi-indent-block rule
2019-03-27 15:22:46 -07:00

77 lines
3.0 KiB
Plaintext

#!/usr/bin/env nomsu -V7.0.0
###
This file defines upgrades from Nomsu <4.10.12.7 to 4.10.12.7
use "compatibility/compatibility"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
upgrade action ($ as lua statements) to "4.10.12.7" as ($ as lua)
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
[: for $k = $v in $items: add $e]
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
[: 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
[: for $i in $start to $stop by $step: add $e]
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
{: for $k0 = $v0 in $items: add $k = $v}
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
{: 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
{: for $i in $start to $stop by $step: add $k = $v}
upgrade action (parse $text from $filename) to "4.10.12.7" as
(NomsuCode from (Source $filename 1 #$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
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
$i = 1
$has_use = (no)
repeat while ($i <= #$first_chunk):
if (($first_chunk.$i.type == "Action") and ($first_chunk.$i.stub == "use")):
$has_use = (yes)
..else:
if $has_use:
go to (insert chunk)
$i += 1
return
--- (insert chunk) ---
[$chunk1, $chunk2] =
["Block" tree from $first_chunk.source, "Block" tree from $first_chunk.source]
for $j in (1 to ($i - 1)):
$chunk1.$j = $first_chunk.$j
for $j in ($i to #$first_chunk):
$chunk2.($j - $i + 1) = $first_chunk.$j
$new_tree = ("FileChunks" tree from $tree.source with $chunk1 $chunk2)
for $i in (2 to #$tree):
$new_tree.($i + 1) = $tree.$i
return $new_tree