mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-13 06:26:05 +09:00
basic: somewhat working but 'REM' does not?
This commit is contained in:
@@ -23,7 +23,7 @@ if (exec_args !== undefined && exec_args[1] !== undefined && exec_args[1].starts
|
|||||||
|
|
||||||
|
|
||||||
let INDEX_BASE = 0;
|
let INDEX_BASE = 0;
|
||||||
let TRACEON = false;
|
let TRACEON = true;
|
||||||
let DBGON = true;
|
let DBGON = true;
|
||||||
let DATA_CURSOR = 0;
|
let DATA_CURSOR = 0;
|
||||||
let DATA_CONSTS = [];
|
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._troNOP = function(lnum) { return new SyntaxTreeReturnObj("null", undefined, lnum + 1); }
|
||||||
bF._executeSyntaxTree = function(lnum, syntaxTree, recDepth) {
|
bF._executeSyntaxTree = function(lnum, syntaxTree, recDepth) {
|
||||||
let _debugExec = true;
|
let _debugExec = false;
|
||||||
let _debugPrintCurrentLine = true;
|
let _debugPrintCurrentLine = false;
|
||||||
let recWedge = "> ".repeat(recDepth);
|
let recWedge = "> ".repeat(recDepth);
|
||||||
|
|
||||||
if (_debugExec || _debugPrintCurrentLine) serial.println(recWedge+"@@ EXECUTE @@");
|
if (_debugExec || _debugPrintCurrentLine) serial.println(recWedge+"@@ EXECUTE @@");
|
||||||
@@ -2487,12 +2487,12 @@ bF._executeSyntaxTree = function(lnum, syntaxTree, recDepth) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// test print new tree
|
// test print new tree
|
||||||
serial.println("[BASIC.DEFUN] defun debug info for function "+defunName);
|
//serial.println("[BASIC.DEFUN] defun debug info for function "+defunName);
|
||||||
serial.println("[BASIC.DEFUN] defun name tree: ");
|
//serial.println("[BASIC.DEFUN] defun name tree: ");
|
||||||
serial.println(astToString(nameTree));
|
//serial.println(astToString(nameTree));
|
||||||
serial.println("[BASIC.DEFUN] defun renaming map: "+Object.entries(defunRenamingMap));
|
//serial.println("[BASIC.DEFUN] defun renaming map: "+Object.entries(defunRenamingMap));
|
||||||
serial.println("[BASIC.DEFUN] defun expression tree:");
|
//serial.println("[BASIC.DEFUN] defun expression tree:");
|
||||||
serial.println(astToString(exprTree));
|
//serial.println(astToString(exprTree));
|
||||||
|
|
||||||
// check if the variable name already exists
|
// check if the variable name already exists
|
||||||
// search from constants
|
// search from constants
|
||||||
|
|||||||
@@ -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","lit","op","num","lit","num",
|
||||||
"lit","lit","paren","lit","op","num","paren","op","lit","paren","lit","op","num","paren"];
|
"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 {
|
try {
|
||||||
let trees = bF._parseTokens(lnum,
|
let trees = bF._parseTokens(lnum,
|
||||||
tokens14,
|
tokens15,
|
||||||
states14
|
states15
|
||||||
);
|
);
|
||||||
trees.forEach((t,i) => {
|
trees.forEach((t,i) => {
|
||||||
serial.println("\nParsed Statement #"+(i+1));
|
serial.println("\nParsed Statement #"+(i+1));
|
||||||
|
|||||||
Reference in New Issue
Block a user