diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-07-17 23:08:13 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-07-17 23:08:24 -0700 |
| commit | ba639f2bd05f47e08c12198b7b20cd4cf371b25f (patch) | |
| tree | 656fcb15a27e642f891fba24046e01b4f139ab52 /compatibility | |
| parent | 854b2a652ff473c9d2eaa3222008d4baed36ae63 (diff) | |
Upgraded core code to latest Nomsu verison.
Diffstat (limited to 'compatibility')
| -rw-r--r-- | compatibility/2.nom | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/compatibility/2.nom b/compatibility/2.nom new file mode 100644 index 0000000..409f374 --- /dev/null +++ b/compatibility/2.nom @@ -0,0 +1,30 @@ +#!/usr/bin/env nomsu -V2 +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") + unless (%true_body is "Block" syntax tree): + %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)") + 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 <- [..] + "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) + unless ((last in %bits) is "Block" syntax tree): + %body <- (last in %bits) + %bits.(length of %bits) <- (=lua "Block(\%body.source, \%body)") + return (=lua "Action(\%tree.source, unpack(\%bits))") |
