basic: somewhat working but 'REM' does not?

This commit is contained in:
minjaesong
2020-12-14 19:37:41 +09:00
parent ddb7437755
commit 186340d704
2 changed files with 15 additions and 12 deletions

View File

@@ -23,7 +23,7 @@ if (exec_args !== undefined && exec_args[1] !== undefined && exec_args[1].starts
let INDEX_BASE = 0;
let TRACEON = false;
let TRACEON = true;
let DBGON = true;
let DATA_CURSOR = 0;
let DATA_CONSTS = [];
@@ -2411,8 +2411,8 @@ bF._gotoCmds = {GOTO:1,GOSUB:1,RETURN:1,NEXT:1,END:1,BREAKTO:1}; // put nonzero
*/
bF._troNOP = function(lnum) { return new SyntaxTreeReturnObj("null", undefined, lnum + 1); }
bF._executeSyntaxTree = function(lnum, syntaxTree, recDepth) {
let _debugExec = true;
let _debugPrintCurrentLine = true;
let _debugExec = false;
let _debugPrintCurrentLine = false;
let recWedge = "> ".repeat(recDepth);
if (_debugExec || _debugPrintCurrentLine) serial.println(recWedge+"@@ EXECUTE @@");
@@ -2487,12 +2487,12 @@ bF._executeSyntaxTree = function(lnum, syntaxTree, recDepth) {
});
// test print new tree
serial.println("[BASIC.DEFUN] defun debug info for function "+defunName);
serial.println("[BASIC.DEFUN] defun name tree: ");
serial.println(astToString(nameTree));
serial.println("[BASIC.DEFUN] defun renaming map: "+Object.entries(defunRenamingMap));
serial.println("[BASIC.DEFUN] defun expression tree:");
serial.println(astToString(exprTree));
//serial.println("[BASIC.DEFUN] defun debug info for function "+defunName);
//serial.println("[BASIC.DEFUN] defun name tree: ");
//serial.println(astToString(nameTree));
//serial.println("[BASIC.DEFUN] defun renaming map: "+Object.entries(defunRenamingMap));
//serial.println("[BASIC.DEFUN] defun expression tree:");
//serial.println(astToString(exprTree));
// check if the variable name already exists
// search from constants

View File

@@ -802,12 +802,15 @@ let states14 = ["lit","lit","paren","lit","paren","op","lit","lit","op","num","l
"lit","lit","lit","op","num","lit","num",
"lit","lit","paren","lit","op","num","paren","op","lit","paren","lit","op","num","paren"];
// PRINT(MAP FIB, 1 TO 10) is broken
// PRINT(MAP FIB, 1 TO 10) is not broken, it's obvious syntax error
// use "PRINT MAP(FIB, 1 TO 10)" instead
let tokens15 = ["PRINT","MAP","(","FIB",",","1","TO","10",")"];
let states15 = ["lit","lit","paren","lit","sep","num","op","num","paren"];
try {
let trees = bF._parseTokens(lnum,
tokens14,
states14
tokens15,
states15
);
trees.forEach((t,i) => {
serial.println("\nParsed Statement #"+(i+1));