From fa2d2867b733000338af7f08165709d2260e12fe Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Tue, 15 Oct 2013 01:24:32 +0000 Subject: [PATCH] Remove support for the older "natural English" script syntax. The older syntax for scripts tried to express time spans using natural English phrases, but were more difficult to write and were nonsensical when put together with other valid expressions that use the modern syntax. Remove support for the old syntax to simplify the compiler and the script engine. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1043 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- OvaleBestAction.lua | 86 --------------------------------------------------- OvaleCompile.lua | 75 -------------------------------------------- 2 files changed, 161 deletions(-) diff --git a/OvaleBestAction.lua b/OvaleBestAction.lua index c290648..f250fea 100644 --- a/OvaleBestAction.lua +++ b/OvaleBestAction.lua @@ -107,13 +107,6 @@ local function PutValue(element, value, origin, rate) return result end -local function ComputeAfter(element, atTime) - local self = OvaleBestAction - local timeA = self:Compute(element.time, atTime) - local startA, endA = self:Compute(element.a, atTime) - return addTime(startA, timeA), addTime(endA, timeA) -end - local function ComputeAnd(element, atTime) Ovale:Logf("%s [%d]", element.type, element.nodeId) local self = OvaleBestAction @@ -150,58 +143,6 @@ local function ComputeAnd(element, atTime) return startB, endB, prioriteB, elementB end -local function ComputeBefore(element, atTime) - local self = OvaleBestAction - local timeA = self:Compute(element.time, atTime) - local startA, endA = self:Compute(element.a, atTime) - return addTime(startA, -timeA), addTime(endA, -timeA) -end - -local function ComputeBetween(element, atTime) - Ovale:Log("between") - local self = OvaleBestAction - local tempsA = self:Compute(element.a, atTime) - local tempsB = self:Compute(element.b, atTime) - if not tempsA and not tempsB then - Ovale:Logf("%s returns 0 because the two nodes are nil", element.type) - return 0 - end - if not tempsA or not tempsB then - Ovale:Logf("%s return nil", element.type) - return nil - end - local diff - if tempsA > tempsB then - diff = tempsA - tempsB - else - diff = tempsB - tempsA - end - Ovale:Logf("%s returns %f", element.type, diff) - return diff -end - -local function ComputeCompare(element, atTime) - Ovale:Logf("compare %s", element.comparison) - local self = OvaleBestAction - local tempsA = self:Compute(element.a, atTime) - local timeB = self:Compute(element.time, atTime) - Ovale:Logf("%s %s %s", tempsA, element.comparison, timeB) - if element.comparison == "more" and (not tempsA or tempsA > timeB) then - Ovale:Logf("%s return 0", element.type) - return 0 - elseif element.comparison == "less" and tempsA and tempsA < timeB then - Ovale:Logf("%s return 0", element.type) - return 0 - elseif element.comparison == "at most" and tempsA and tempsA <= timeB then - Ovale:Logf("%s return 0", element.type) - return 0 - elseif element.comparison == "at least" and (not tempsA or tempsA >= timeB) then - Ovale:Logf("%s return 0", element.type) - return 0 - end - return nil -end - local function ComputeCustomFunction(element, atTime) Ovale:Logf("custom function %s", element.name) local self = OvaleBestAction @@ -214,23 +155,6 @@ local function ComputeCustomFunction(element, atTime) return element.startA, element.endA, element.priorityA, element.elementA end -local function ComputeFromUntil(element, atTime) - Ovale:Log("fromuntil") - local self = OvaleBestAction - local tempsA = self:Compute(element.a, atTime) - if not tempsA then - Ovale:Logf("%s return nil", element.type) - return nil - end - local tempsB = self:Compute(element.b, atTime) - if not tempsB then - Ovale:Logf("%s return nil", element.type) - return nil - end - Ovale:Logf("%s returns %f", element.type, tempsB - tempsA) - return tempsB - tempsA -end - local function ComputeFunction(element, atTime) local self = OvaleBestAction if element.func == "spell" or element.func == "macro" or element.func == "item" or element.func == "texture" then @@ -657,10 +581,6 @@ local function ComputeOperator(element, atTime) return startA, endA, OVALE_DEFAULT_PRIORITY, PutValue(element, l, m, n) end -local function ComputeTime(element, atTime) - return element.value -end - local function ComputeUnless(element, atTime) Ovale:Logf("%s [%d]", element.type, element.nodeId) local self = OvaleBestAction @@ -712,13 +632,8 @@ end -- local OVALE_COMPUTE_VISITOR = { - ["after"] = ComputeAfter, ["and"] = ComputeAnd, - ["before"] = ComputeBefore, - ["between"] = ComputeBetween, - ["compare"] = ComputeCompare, ["customfunction"] = ComputeCustomFunction, - ["fromuntil"] = ComputeFromUntil, ["function"] = ComputeFunction, ["group"] = ComputeGroup, ["if"] = ComputeAnd, @@ -726,7 +641,6 @@ local OVALE_COMPUTE_VISITOR = ["not"] = ComputeNot, ["operator"] = ComputeOperator, ["or"] = ComputeOr, - ["time"] = ComputeTime, ["unless"] = ComputeUnless, ["value"] = ComputeValue, ["wait"] = ComputeWait, diff --git a/OvaleCompile.lua b/OvaleCompile.lua index 6c73201..a67aeef 100644 --- a/OvaleCompile.lua +++ b/OvaleCompile.lua @@ -172,13 +172,6 @@ local function TestConditions(paramList) return true end -local function ParseTime(value) - local node = self_pool:Get() - node.type = "time" - node.value = tonumber(value) - return AddNode(node) -end - local function ParseNumber(dummy, value) local node = self_pool:Get() node.type = "value" @@ -431,38 +424,6 @@ local function ParseNot(a) return AddNode(node) end -local function ParseBefore(t,a) - local node = self_pool:Get() - node.type = "before" - node.time = self_node[tonumber(t)] - node.a = self_node[tonumber(a)] - return AddNode(node) -end - -local function ParseAfter(t,a) - local node = self_pool:Get() - node.type = "after" - node.time = self_node[tonumber(t)] - node.a = self_node[tonumber(a)] - return AddNode(node) -end - -local function ParseBetween(a,b) - local node = self_pool:Get() - node.type = "between" - node.a = self_node[tonumber(a)] - node.b = self_node[tonumber(b)] - return AddNode(node) -end - -local function ParseFromUntil(a,b) - local node = self_pool:Get() - node.type = "fromuntil" - node.a = self_node[tonumber(a)] - node.b = self_node[tonumber(b)] - return AddNode(node) -end - local function ParseOr(a,b) local node = self_pool:Get() node.type = "or" @@ -480,15 +441,6 @@ local function ParseOp(a, op, b) return AddNode(node) end -local function ParseCompare(comp,t,a) - local node = self_pool:Get() - node.type = "compare" - node.comparison = comp - node.time = self_node[tonumber(t)] - node.a = self_node[tonumber(a)] - return AddNode(node) -end - local function ParseGroup(text) local nodes = {} @@ -561,7 +513,6 @@ local function ParseCommands(text) while true do local was = text text = strgsub(text, "(%w+)%.?(%w*)%s*%((.-)%)", ParseFunction) - text = strgsub(text, "(%d+%.?%d*)s", ParseTime) text = strgsub(text, "([^%w])(%d+%.?%d*)", ParseNumber) text = strgsub(text, "node(%d+)%s*([%*%/%%])%s*node(%d+)", ParseOp) text = strgsub(text, "node(%d+)%s*([%+%-])%s*node(%d+)", ParseOp) @@ -584,22 +535,6 @@ local function ParseCommands(text) while true do local was = text text = strgsub(text, "not%s+node(%d+)", ParseNot) - text = strgsub(text, "between%s+node(%d+)%s+and%s+node(%d+)", ParseBetween) - text = strgsub(text, "from%s+node(%d+)%s+until%s+node(%d+)", ParseFromUntil) - text = strgsub(text, "(more)%s+than%s+node(%d+)%s+node(%d+)", ParseCompare) - text = strgsub(text, "(less)%s+than%s+node(%d+)%s+node(%d+)", ParseCompare) - text = strgsub(text, "(at least)%s+node(%d+)%s+node(%d+)", ParseCompare) - text = strgsub(text, "(at most)%s+node(%d+)%s+node(%d+)", ParseCompare) - text = strgsub(text, "node(%d+)%s+before%s+node(%d+)", ParseBefore) - text = strgsub(text, "node(%d+)%s+after%s+node(%d+)", ParseAfter) - if was == text then - break - end - end - - while true do - local was = text - text = strgsub(text, "not%s+node(%d+)", ParseNot) text = strgsub(text, "node(%d+)%s*([%*%+%-%/%>%<]=?|==)%s*node(%d+)", ParseOp) text = strgsub(text, "node(%d+)%s+and%s+node(%d+)", ParseAnd) text = strgsub(text, "node(%d+)%s+or%s+node(%d+)", ParseOr) @@ -904,16 +839,6 @@ function OvaleCompile:DebugNode(node) text = self:DebugNode(node.a).." or "..self:DebugNode(node.b) elseif (node.type == "not") then text = "not "..self:DebugNode(node.a) - elseif (node.type == "before") then - text = self:DebugNode(node.time) .. " before "..self:DebugNode(node.a) - elseif (node.type == "between") then - text = "between "..self:DebugNode(node.a).." and "..self:DebugNode(node.b) - elseif (node.type == "fromuntil") then - text = "from "..self:DebugNode(node.a).." until "..self:DebugNode(node.b) - elseif (node.type == "compare") then - text = node.comparison.." than "..self:DebugNode(node.time).." "..self:DebugNode(node.a) - elseif (node.type == "time") then - text = node.value.."s" elseif node.type == "operator" then text = self:DebugNode(node.a)..node.operator..self:DebugNode(node.b) elseif node.type == "lua" then -- 1.7.9.5