diff --git a/DNCL3.js b/DNCL3.js index 8c6cbe8..cabee0a 100644 --- a/DNCL3.js +++ b/DNCL3.js @@ -37,9 +37,9 @@ class Break { export class DNCL3 { constructor(s, callbackoutput) { this.s = s.replaceAll("\r", ""); - this.p = 0; this.vars = {}; this.callbackoutput = callbackoutput; + //this.parseTokens(); this.parse(); } output(s) { @@ -448,17 +448,23 @@ export class DNCL3 { } if (token.type == "print") { const res = []; - for (;;) { - res.push(this.getExpression()); - const op = this.getToken(); - if (op.type == "eol" || op.type == "eof" || op.type == "else") { - this.backToken(op); - break; - } - if (op.operator != ",") { - this.backToken(op); - break; - //throw new Error("表示はコンマ区切りのみ対応しています"); + const chk = this.getToken(true); + if (chk.type == "eol" || chk.type == "eof") { + this.backToken(chk); + } else { + this.backToken(chk); + for (;;) { + res.push(this.getExpression()); + const op = this.getToken(); + if (op.type == "eol" || op.type == "eof") { + this.backToken(op); + break; + } + if (op.operator != ",") { + this.backToken(op); + break; + //throw new Error("表示はコンマ区切りのみ対応しています"); + } } } body.push({ @@ -787,11 +793,20 @@ export class DNCL3 { return true; } parse() { + this.p = 0; const body = []; while (this.parseCommand(body)); const ast = { "type": "Program", body }; this.ast = ast; } + parseTokens() { + this.p = 0; + for (;;) { + const c = this.getToken(true); + console.log(c); + if (c.type == "eof") break; + } + } getArrayIndex(ast) { const prop = this.calcExpression(ast); if (prop < 0 || typeof prop == "string" && parseInt(prop).toString() != prop) { diff --git a/dncl2js.html b/dncl2js.html index 41845fc..6a98dd2 100644 --- a/dncl2js.html +++ b/dncl2js.html @@ -115,7 +115,8 @@