2018-10-31 15:05:17 -07:00
|
|
|
#!/usr/bin/env nomsu -V4.8.10
|
2018-07-23 15:56:59 -07:00
|
|
|
#
|
|
|
|
This file defines upgrades from Nomsu <2.4 to Nomsu 2.4
|
|
|
|
|
2018-07-20 17:56:06 -07:00
|
|
|
use "compatibility/compatibility.nom"
|
|
|
|
|
2018-11-08 15:23:22 -08:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
2018-07-20 17:56:06 -07:00
|
|
|
upgrade %tree to "2.4" as:
|
|
|
|
unless (%tree is "Action" syntax tree): return
|
|
|
|
if %tree.stub is:
|
|
|
|
"when %":
|
|
|
|
%conditions = []
|
|
|
|
%new_lines = []
|
2018-07-20 20:27:15 -07:00
|
|
|
%body = (..)
|
|
|
|
(%tree.2 upgraded) if (%tree.2 is "Block" syntax tree) else [%tree.2 upgraded]
|
2018-07-20 17:56:06 -07:00
|
|
|
for %line in %body:
|
|
|
|
if:
|
|
|
|
(not (%line is syntax tree)):
|
|
|
|
compile error at %tree.source "WUT: %s"
|
|
|
|
(not (%line is "Action" syntax tree)):
|
2018-08-29 15:59:30 -07:00
|
|
|
%new_lines::add %line
|
2018-07-20 17:56:06 -07:00
|
|
|
(%line.stub is "* %"):
|
2018-08-29 15:59:30 -07:00
|
|
|
%conditions::add %line.2
|
2018-07-20 17:56:06 -07:00
|
|
|
(%line.stub == "* else %"):
|
2018-08-29 15:59:30 -07:00
|
|
|
%new_lines::add (\(else %block) with vars {block:%line.3})
|
2018-07-20 17:56:06 -07:00
|
|
|
(%line.stub != "* % %"):
|
2018-08-29 15:59:30 -07:00
|
|
|
%new_lines::add %line
|
2018-07-20 17:56:06 -07:00
|
|
|
else:
|
2018-08-29 15:59:30 -07:00
|
|
|
%conditions::add %line.2
|
2018-07-20 17:56:06 -07:00
|
|
|
%action = %line.3
|
|
|
|
unless (%action is "Block" syntax tree):
|
|
|
|
%action = (=lua "Block(\%action.source, \%action)")
|
2018-08-29 15:59:30 -07:00
|
|
|
%conditions::add %action
|
|
|
|
%new_lines::add (=lua "Action(\%conditions[1].source, unpack(\%conditions))")
|
2018-07-20 17:56:06 -07:00
|
|
|
%conditions = []
|
2018-07-20 20:27:15 -07:00
|
|
|
|
|
|
|
return (..)
|
|
|
|
\(if %body) with vars {body:=lua "Block(\%tree[2].source, unpack(\%new_lines))"}
|
|
|
|
|
2018-07-20 17:56:06 -07:00
|
|
|
"when % is ? %" "when % = ? %":
|
|
|
|
%values = []
|
|
|
|
%new_lines = []
|
2018-07-20 20:27:15 -07:00
|
|
|
%body = (..)
|
|
|
|
(%tree.5 upgraded) if (%tree.5 is "Block" syntax tree) else [%tree.5 upgraded]
|
2018-07-20 17:56:06 -07:00
|
|
|
for %line in %body:
|
|
|
|
if:
|
|
|
|
(not (%line is "Action" syntax tree)):
|
2018-08-29 15:59:30 -07:00
|
|
|
%new_lines::add %line
|
2018-07-20 17:56:06 -07:00
|
|
|
(%line.stub is "* %"):
|
2018-08-29 15:59:30 -07:00
|
|
|
%values::add %line.2
|
2018-07-20 17:56:06 -07:00
|
|
|
(%line.stub == "* else %"):
|
2018-08-29 15:59:30 -07:00
|
|
|
%new_lines::add (\(else %block) with vars {block:%line.3})
|
2018-07-20 17:56:06 -07:00
|
|
|
(%line.stub != "* % %"):
|
2018-08-29 15:59:30 -07:00
|
|
|
%new_lines::add %line
|
2018-07-20 17:56:06 -07:00
|
|
|
else:
|
2018-08-29 15:59:30 -07:00
|
|
|
%values::add %line.2
|
2018-07-20 17:56:06 -07:00
|
|
|
%action = %line.3
|
|
|
|
unless (%action is "Block" syntax tree):
|
2018-08-27 13:38:58 -07:00
|
|
|
%action = \(: %action)
|
2018-08-29 15:59:30 -07:00
|
|
|
%values::add %action
|
|
|
|
%new_lines::add (=lua "Action(\%values[1].source, unpack(\%values))")
|
2018-07-20 17:56:06 -07:00
|
|
|
%values = []
|
2018-07-20 20:27:15 -07:00
|
|
|
|
|
|
|
return (..)
|
|
|
|
\(if %var is %body) with vars {..}
|
2018-07-22 15:01:05 -07:00
|
|
|
var:%tree.2 upgraded, body:=lua "Block(\%tree[5].source, unpack(\%new_lines))"
|