code / nomsu

Lines6.6K Lua5.1K PEG1.3K make117
2 others 83
Markdown60 Bourne Again Shell23
(77 lines)
1 #!/usr/bin/env nomsu -V7.0.0
2 ###
3 This file defines upgrades from Nomsu <4.10.12.7 to 4.10.12.7
4 use "compatibility/compatibility"
6 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 upgrade action ($ as lua statements) to "4.10.12.7" as ($ as lua)
9 upgrade action ($ as lua return) to "4.10.12.7" as
10 =lua "\$.type == 'Block' and \($ as lua) or 'return '..\($ as lua expr)"
11 upgrade action (Lua value $) to "4.10.12.7" as (Lua $)
12 upgrade action ($e for $ in $items) to "4.10.12.7" as [: for $ in $items: add $e]
13 upgrade action ($e for $k = $v in $items) to "4.10.12.7" as
14 [: for $k = $v in $items: add $e]
16 upgrade action ($e for $i in $start to $stop) to "4.10.12.7" as
17 [: for $i in $start to $stop: add $e]
19 upgrade action ($e for $i in $start to $stop by $step) to "4.10.12.7" as
20 [: for $i in $start to $stop by $step: add $e]
22 upgrade action ($e for $i in $start to $stop via $step) to "4.10.12.7" as
23 [: for $i in $start to $stop by $step: add $e]
25 upgrade action ($k = $v for $ in $items) to "4.10.12.7" as
26 {: for $ in $items: add $k = $v}
28 upgrade action ($k = $v for $k0 = $v0 in $items) to "4.10.12.7" as
29 {: for $k0 = $v0 in $items: add $k = $v}
31 upgrade action ($k = $v for $i in $start to $stop) to "4.10.12.7" as
32 {: for $i in $start to $stop: add $k = $v}
34 upgrade action ($k = $v for $i in $start to $stop by $step) to "4.10.12.7" as
35 {: for $i in $start to $stop by $step: add $k = $v}
37 upgrade action ($k = $v for $i in $start to $stop via $step) to "4.10.12.7" as
38 {: for $i in $start to $stop by $step: add $k = $v}
40 upgrade action (parse $text from $filename) to "4.10.12.7" as
41 (NomsuCode from (Source $filename 1 #$text) $text) parsed
43 upgrade action ($ as lua statements) to "4.10.12.7" as ($ as lua)
44 upgrade action (compile error at $pos $err hint $hint) to "4.10.12.7" as
45 compile error at $pos $err $hint
47 ### In old code, it was okay to have imports at the top of the file in the same chunk,
48 but changes to the API now require imports to be in their own file chunk in order
49 for compilation to work properly.
50 upgrade $tree to "4.10.12.7" as:
51 if ($tree.type == "FileChunks"):
52 $first_chunk = $tree.1
53 $i = 1
54 $has_use = (no)
55 repeat while ($i <= #$first_chunk):
56 if (($first_chunk.$i.type == "Action") and ($first_chunk.$i.stub == "use")):
57 $has_use = (yes)
58 ..else:
59 if $has_use:
60 go to (insert chunk)
62 $i += 1
63 return
64 --- (insert chunk) ---
65 [$chunk1, $chunk2] =
66 ["Block" tree from $first_chunk.source, "Block" tree from $first_chunk.source]
68 for $j in (1 to ($i - 1)):
69 $chunk1.$j = $first_chunk.$j
71 for $j in ($i to #$first_chunk):
72 $chunk2.($j - $i + 1) = $first_chunk.$j
74 $new_tree = ("FileChunks" tree from $tree.source with $chunk1 $chunk2)
75 for $i in (2 to #$tree):
76 $new_tree.($i + 1) = $tree.$i
77 return $new_tree