mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-10 06:54:04 +09:00
basic:fixing two new operators are not getting parsed well
This commit is contained in:
@@ -58,6 +58,9 @@ lang.outOfMem = function(line) {
|
|||||||
lang.dupDef = function(line, varname) {
|
lang.dupDef = function(line, varname) {
|
||||||
return "Duplicate definition"+((varname !== undefined) ? (" on "+varname) : "")+" in "+line;
|
return "Duplicate definition"+((varname !== undefined) ? (" on "+varname) : "")+" in "+line;
|
||||||
};
|
};
|
||||||
|
lang.asgnOnConst = function(line, constname) {
|
||||||
|
return 'Trying to modify constant "'+constname+'" in '+line;
|
||||||
|
};
|
||||||
Object.freeze(lang);
|
Object.freeze(lang);
|
||||||
|
|
||||||
let fs = {};
|
let fs = {};
|
||||||
@@ -300,11 +303,18 @@ let threeArgNum = function(lnum, args, action) {
|
|||||||
if (isNaN(rsvArg2)) throw lang.illegalType(lnum, rsvArg2);
|
if (isNaN(rsvArg2)) throw lang.illegalType(lnum, rsvArg2);
|
||||||
return action(rsvArg0, rsvArg1, rsvArg2);
|
return action(rsvArg0, rsvArg1, rsvArg2);
|
||||||
}
|
}
|
||||||
|
let initBvars = function() {
|
||||||
|
return {
|
||||||
|
"NIL": new BasicVar([], "array"),
|
||||||
|
"PI": new BasicVar(Math.PI, "number")
|
||||||
|
};
|
||||||
|
}
|
||||||
let bStatus = {};
|
let bStatus = {};
|
||||||
bStatus.gosubStack = [];
|
bStatus.gosubStack = [];
|
||||||
bStatus.forLnums = {}; // key: forVar, value: linenum
|
bStatus.forLnums = {}; // key: forVar, value: linenum
|
||||||
bStatus.forStack = []; // forVars only
|
bStatus.forStack = []; // forVars only
|
||||||
bStatus.vars = {}; // contains instances of BasicVars
|
bStatus.vars = initBvars(); // contains instances of BasicVars
|
||||||
|
bStatus.consts = {"NIL":1}; Object.freeze(bStatus.consts);
|
||||||
bStatus.defuns = {};
|
bStatus.defuns = {};
|
||||||
bStatus.rnd = 0; // stores mantissa (23 bits long) of single precision floating point number
|
bStatus.rnd = 0; // stores mantissa (23 bits long) of single precision floating point number
|
||||||
bStatus.getArrayIndexFun = function(lnum, array) {
|
bStatus.getArrayIndexFun = function(lnum, array) {
|
||||||
@@ -333,6 +343,7 @@ if no arg text were given (e.g. "10 NEXT"), args will have zero length
|
|||||||
var rh = resolve(args[1]);
|
var rh = resolve(args[1]);
|
||||||
if (rh === undefined) throw lang.refError(lnum, args[1].troValue);
|
if (rh === undefined) throw lang.refError(lnum, args[1].troValue);
|
||||||
var type = sigil.sgType || JStoBASICtype(rh);
|
var type = sigil.sgType || JStoBASICtype(rh);
|
||||||
|
if (bStatus.consts[sigil.sgName]) throw lang.asgnOnConst(lnum, sigil.sgName);
|
||||||
bStatus.vars[sigil.sgName] = new BasicVar(rh, type);
|
bStatus.vars[sigil.sgName] = new BasicVar(rh, type);
|
||||||
return {asgnVarName: sigil.sgName, asgnValue: rh};
|
return {asgnVarName: sigil.sgName, asgnValue: rh};
|
||||||
},
|
},
|
||||||
@@ -513,7 +524,7 @@ if no arg text were given (e.g. "10 NEXT"), args will have zero length
|
|||||||
return r;
|
return r;
|
||||||
},
|
},
|
||||||
"CLEAR" : function(lnum, args) {
|
"CLEAR" : function(lnum, args) {
|
||||||
bStatus.vars = {};
|
bStatus.vars = initBvars();
|
||||||
},
|
},
|
||||||
"PLOT" : function(lnum, args) {
|
"PLOT" : function(lnum, args) {
|
||||||
threeArgNum(lnum, args, function(xpos, ypos, color) { graphics.plotPixel(xpos, ypos, color); });
|
threeArgNum(lnum, args, function(xpos, ypos, color) { graphics.plotPixel(xpos, ypos, color); });
|
||||||
@@ -683,7 +694,7 @@ bF._isNumSep = function(code) {
|
|||||||
return code == 0x2E || code == 0x42 || code == 0x58 || code == 0x62 || code == 0x78;
|
return code == 0x2E || code == 0x42 || code == 0x58 || code == 0x62 || code == 0x78;
|
||||||
};
|
};
|
||||||
bF._is1o = function(code) {
|
bF._is1o = function(code) {
|
||||||
return (code >= 0x3C && code <= 0x3E) || code == 0x2A || code == 0x2B || code == 0x2D || code == 0x2F || code == 0x5E;
|
return code == 0x3A || code == 0x7E || (code >= 0x3C && code <= 0x3E) || code == 0x2A || code == 0x2B || code == 0x2D || code == 0x2F || code == 0x5E;
|
||||||
};
|
};
|
||||||
bF._is2o = function(code) {
|
bF._is2o = function(code) {
|
||||||
return (code >= 0x3C && code <= 0x3E);
|
return (code >= 0x3C && code <= 0x3E);
|
||||||
|
|||||||
Reference in New Issue
Block a user