mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-11 23:34:04 +09:00
basic: fix: would crap out when 'REM' is not a first statement of a line
This commit is contained in:
1
assets/tbas/doc/statements.tex
Normal file
1
assets/tbas/doc/statements.tex
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
@@ -8,7 +8,8 @@ line =
|
||||
linenumber = digits ;
|
||||
|
||||
stmt =
|
||||
"IF" , expr_sans_asgn , "THEN" , stmt , ["ELSE" , stmt]
|
||||
"REM" , ? anything ?
|
||||
| "IF" , expr_sans_asgn , "THEN" , stmt , ["ELSE" , stmt]
|
||||
| "DEFUN" , [ident] , "(" , [ident , {" , " , ident}] , ")" , "=" , expr
|
||||
| "ON" , expr_sans_asgn , ("GOTO" | "GOSUB") , expr_sans_asgn , {"," , expr_sans_asgn}
|
||||
| "(" , stmt , ")"
|
||||
@@ -37,7 +37,6 @@ digraph g {
|
||||
LITERAL -> PAREN [label="()[]"]
|
||||
LITERAL -> limbo [label=_]
|
||||
LITERAL -> SEP [label=","]
|
||||
LITERAL -> NUMBER [label="0..9"]
|
||||
LITERAL -> OPERATOR [label="^*/+->=<"]
|
||||
LITERAL -> LITERAL [label=otherwise]
|
||||
|
||||
@@ -78,7 +78,8 @@ bF._parseTokens = function(lnum, tokens, states) {
|
||||
|
||||
/** Parses following EBNF rule:
|
||||
stmt =
|
||||
"IF" , expr_sans_asgn , "THEN" , stmt , ["ELSE" , stmt]
|
||||
"REM" , ? anything ?
|
||||
| "IF" , expr_sans_asgn , "THEN" , stmt , ["ELSE" , stmt]
|
||||
| "DEFUN" , [ident] , "(" , [ident , {" , " , ident}] , ")" , "=" , expr
|
||||
| "ON" , expr_sans_asgn , ident , expr_sans_asgn , {"," , expr_sans_asgn}
|
||||
| "(" , stmt , ")"
|
||||
@@ -90,14 +91,6 @@ bF._parseStmt = function(lnum, tokens, states, recDepth) {
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
let headTkn = tokens[0].toUpperCase();
|
||||
let headSta = states[0];
|
||||
|
||||
let treeHead = new BasicAST();
|
||||
treeHead.astLnum = lnum;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
// case for: single word (e.g. NEXT for FOR loop)
|
||||
if (tokens.length == 1 && states.length == 1) {
|
||||
bF.parserPrintdbgline('$', "Single Word Function Call", lnum, recDepth);
|
||||
@@ -106,6 +99,19 @@ bF._parseStmt = function(lnum, tokens, states, recDepth) {
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
let headTkn = tokens[0].toUpperCase();
|
||||
let headSta = states[0];
|
||||
|
||||
let treeHead = new BasicAST();
|
||||
treeHead.astLnum = lnum;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
// case for: "REM" , ? anything ?
|
||||
if (headTkn == "REM" && headSta != "qot") return;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
let parenDepth = 0;
|
||||
let parenStart = -1;
|
||||
let parenEnd = -1;
|
||||
|
||||
Reference in New Issue
Block a user