From 1f88a878be8d8e0e82acff1fba9c002e5e5daa85 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Wed, 10 Jun 2020 01:29:29 +0900 Subject: [PATCH] yet another state machine fix --- assets/tbas/basic.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/assets/tbas/basic.js b/assets/tbas/basic.js index 724511f..a0b65e1 100644 --- a/assets/tbas/basic.js +++ b/assets/tbas/basic.js @@ -357,15 +357,14 @@ basicFunctions._interpretLine = function(lnum, cmd) { /* do nothing */ } else if (0x22 == charCode) { - sb = ""; mode = "quote" } else if (basicFunctions._isParen(charCode)) { - sb = ""; + sb = "" + char; mode = "paren"; } else if (basicFunctions._isSeparator(charCode)) { - sb = ""; + sb = "" + char; mode = "sep"; } else { @@ -430,6 +429,9 @@ basicFunctions._interpretLine = function(lnum, cmd) { if (tokens.length != states.length) throw "InternalError: size of tokens and states does not match (line: "+lnum+")"; // END TOKENISE + println(tokens.join("~")); + println(states.join(" ")); + // ELABORATION : distinguish numbers and operators from literals k = 0; while (k < states.length) { // using while loop because array size will change during the execution @@ -517,6 +519,11 @@ basicFunctions._interpretLine = function(lnum, cmd) { } // END ELABORATION + + println(tokens.join("~")); + println(states.join(" ")); + + // PARSING (SYNTAX ANALYSIS) var syntaxTree = basicFunctions._parseTokens(lnum, tokens, states, 0); println("k bye"); @@ -524,10 +531,6 @@ basicFunctions._interpretLine = function(lnum, cmd) { // END PARSING - println(tokens.join("~")); - println(states.join(" ")); - - return lnum + 1; }; // end INTERPRETLINE