From 854b2a652ff473c9d2eaa3222008d4baed36ae63 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 17 Jul 2018 17:53:07 -0700 Subject: Fixed a bug in text escapes in nomsu codegen. --- compatibility/compatibility.nom | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 compatibility/compatibility.nom (limited to 'compatibility/compatibility.nom') diff --git a/compatibility/compatibility.nom b/compatibility/compatibility.nom new file mode 100644 index 0000000..303c05b --- /dev/null +++ b/compatibility/compatibility.nom @@ -0,0 +1,38 @@ +#!/usr/bin/env nomsu -V1 +use "core" +use "lib/os.nom" + +%UPGRADES <- {} + +action [upgrade to %version via %upgrade_fn] + %UPGRADES.%version <- %upgrade_fn + +parse [upgrade %tree to %version as %body] as + upgrade to %version via ([%] -> (% with %tree -> %body)) + +action [%tree upgraded from %start_version to %end_version, %tree upgraded to %end_version from %start_version] + local action [%ver as list] + (% as number) for % where %ver matches "[0-9]+" + + %versions <-: (keys in %UPGRADES) sorted by % -> (% as list) + for %ver in %versions + if: (%ver as list) <= (%start_version as list) + do next %ver + if: (%ver as list) > (%end_version as list) + stop %ver + %tree <- (call %UPGRADES.%ver with [%tree]) + return %tree + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +parse [%tree upgraded from %start_version] as: %tree upgraded from %start_version to (Nomsu version) +parse [%tree upgraded to %end_version] as: %tree upgraded from %tree.version to %end_version +parse [%tree upgraded] as: %tree upgraded from %tree.version to (Nomsu version) + +action [use %path from version %version] + for file %filename in %path + if (=lua "LOADED[\%filename]") + do next %filename + %file <-: read file %filename + %tree <-: parse %file from %filename + %tree <-: upgrade %tree from %version + run tree %tree -- cgit v1.2.3