code / nomsu

Lines6.6K Lua5.1K PEG1.3K make117
2 others 83
Markdown60 Bourne Again Shell23
(99 lines)
1 #!/usr/bin/env nomsu -V7.0.0
2 ###
3 This file defines upgrades from Nomsu <4.11 to Nomsu 4.11
4 (overhaul of function literals, deleting (if all of ...), etc. shorthand)
6 use "compatibility/compatibility"
8 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 ### Overhaul of function literals:
11 upgrade action "call 1 with" to "4.11" via
12 for $tree:
13 $tree2 = {.type = "Action", .source = $tree.source, .1 = $tree.2}
14 for ($i = $arg) in $tree.4:
15 $tree2.($i + 1) = $arg
16 return (SyntaxTree $tree2)
18 upgrade action ->$yield_value to "4.11" as (yield $yield_value)
20 ### Replace set {$x:1, $y:2} with [$x, $y] = [1, 2]
21 upgrade action "set" to "4.11" via
22 for $tree:
23 [$lhs, $rhs] = [\[], \[]]
24 $lhs.source = $tree.2.source
25 $rhs.source = $tree.2.source
26 for ($i = $entry) in $tree.2:
27 $lhs.$i = $entry.1
28 $rhs.$i = $entry.2
29 return ("Action" tree from $tree.source with $lhs "=" $rhs)
31 upgrade action "1 with 2 ~>" to "4.11" via
32 for $tree:
33 at $tree fail ("
34 Upgrade error: This method has been deprecated.
35 Hint: Perhaps this could be use ($tree, map ...) instead.
36 ")
38 ### Changing filesystem API:
39 upgrade action (for file $f in $path $body) to "4.11" as
40 for $f in (files for $path) $body
42 upgrade action ($expr for file $f in $path) to "4.11" as
43 [: for $f in (files for $path): add $expr]
45 upgrade action (line $n in $text) to "4.11" as ($text, line $n)
46 upgrade action (line number of $pos in $text) to "4.11" as
47 $text, line number at $pos
49 ### Deduplicating goto labels:
50 upgrade action [=== $label ===, *** $label ***] to "4.11" as (--- $label ---)
51 upgrade action [===stop $label ===, ***stop $label ***] to "4.11" as
52 ---stop $label ---
54 upgrade action [===next $label ===, ***next $label ***] to "4.11" as
55 ---next $label ---
57 ### Deprecating shorthand functions:
58 upgrade action [if all of $items $body, if all of $items then $body] to "4.11" as
59 if (all of $items) $body
61 upgrade action [unless all of $items $body, unless all of $items then $body] to
62 .."4.11" as (if (not (all of $items)) $body)
64 upgrade action [if any of $items $body, if any of $items then $body] to "4.11" as
65 if (any of $items) $body
67 upgrade action [unless any of $items $body, unless any of $items then $body] to
68 .."4.11" as (if (not (any of $items)) $body)
70 upgrade action [if none of $items $body, if none of $items then $body] to "4.11"
71 ..as (if (not (any of $items)) $body)
73 upgrade action [unless none of $items $body, unless none of $items then $body] to
74 .."4.11" as (if (any of $items) $body)
76 upgrade action [
77 if all of $items $body else $else, if all of $items then $body else $else
78 ] to "4.11" as (if (all of $items) $body else $else)
80 upgrade action [
81 unless all of $items $body else $else, unless all of $items then $body else $else
82 ] to "4.11" as (if (not (all of $items)) $body else $else)
84 upgrade action [
85 if any of $items $body else $else, if any of $items then $body else $else
86 ] to "4.11" as (if (any of $items) $body else $else)
88 upgrade action [
89 unless any of $items $body else $else, unless any of $items then $body else $else
90 ] to "4.11" as (if (not (any of $items)) $body else $else)
92 upgrade action [
93 if none of $items $body else $else, if none of $items then $body else $else
94 ] to "4.11" as (if (not (any of $items)) $body else $else)
96 upgrade action [
97 unless none of $items $body else $else
98 unless none of $items then $body else $else
99 ] to "4.11" as (if (any of $items) $body else $else)