From 54b787529509bd9b0bc30571952abac85c810c3a Mon Sep 17 00:00:00 2001 From: fros4943 Date: Thu, 8 Jan 2009 17:47:37 +0000 Subject: [PATCH] minor fix: using yield and wait_until macro to implement yield_wait_until --- .../java/se/sics/cooja/plugins/ScriptParser.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/plugins/ScriptParser.java b/tools/cooja/java/se/sics/cooja/plugins/ScriptParser.java index 0edaf3e78..a32fe6950 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/ScriptParser.java +++ b/tools/cooja/java/se/sics/cooja/plugins/ScriptParser.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ScriptParser.java,v 1.1 2009/01/08 16:27:48 fros4943 Exp $ + * $Id: ScriptParser.java,v 1.2 2009/01/08 17:47:37 fros4943 Exp $ */ package se.sics.cooja.plugins; @@ -59,12 +59,12 @@ public class ScriptParser { code = parseTimeoutWithAction(code); + code = replaceYieldThenWaitUntils(code); + code = replaceYields(code); code = replaceWaitUntils(code); - code = replaceYieldThenWaitsUntils(code); - this.code = code; } @@ -179,7 +179,7 @@ public class ScriptParser { return pattern.matcher(code).replaceAll("SCRIPT_SWITCH()"); } - private String replaceYieldThenWaitsUntils(String code) throws ScriptSyntaxErrorException { + private String replaceYieldThenWaitUntils(String code) throws ScriptSyntaxErrorException { Pattern pattern = Pattern.compile( "YIELD_THEN_WAIT_UNTIL\\(" + "(.*)" /* expression */ + @@ -189,9 +189,7 @@ public class ScriptParser { while (matcher.find()) { code = matcher.replaceFirst( - "do { " + - " SCRIPT_SWITCH();" + - "} while (!(" + matcher.group(1) + "))"); + "YIELD(); WAIT_UNTIL(" + matcher.group(1) + ")"); matcher.reset(code); } @@ -209,7 +207,7 @@ public class ScriptParser { while (matcher.find()) { code = matcher.replaceFirst( "while (!(" + matcher.group(1) + ")) { " + - " SCRIPT_SWITCH()" + + " SCRIPT_SWITCH(); " + "}"); matcher.reset(code); }