From 7abda44fd656d91970a51c0b42b9adcdf4233d10 Mon Sep 17 00:00:00 2001 From: bwhitn Date: Fri, 24 Nov 2017 05:48:40 -0800 Subject: [PATCH] Added Negative Matching to conditional jumps so negative lookahead is not required. --- src/core/FlowControl.js | 13 ++++++++----- src/core/config/OperationConfig.js | 5 +++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/core/FlowControl.js b/src/core/FlowControl.js index 4a94ffdf..da6fe8c5 100755 --- a/src/core/FlowControl.js +++ b/src/core/FlowControl.js @@ -201,8 +201,9 @@ const FlowControl = { let ings = state.opList[state.progress].getIngValues(), dish = state.dish, regexStr = ings[0], - jumpNum = ings[1], - maxJumps = ings[2]; + invert = ings[1], + jumpNum = ings[2], + maxJumps = ings[3]; if (jumpNum < 0) { jumpNum--; @@ -212,9 +213,11 @@ const FlowControl = { return state; } - if (regexStr !== "" && dish.get(Dish.STRING).search(regexStr) > -1) { - state.progress += jumpNum; - state.numJumps++; + if (regexStr !== "") { + let strMatch = dish.get(Dish.STRING).search(regexStr) > -1; + if (!invert && strMatch || invert && !strMatch) { + state.progress += jumpNum; + state.numJumps++; } return state; diff --git a/src/core/config/OperationConfig.js b/src/core/config/OperationConfig.js index 9caa4f91..87564229 100755 --- a/src/core/config/OperationConfig.js +++ b/src/core/config/OperationConfig.js @@ -165,6 +165,11 @@ const OperationConfig = { type: "string", value: "" }, + { + name: "Negative match (logical NOT)", + type: "boolean", + value: false + }, { name: "Number of operations to jump over if match found", type: "number",