mirror of
https://github.com/inexorabletash/jsbasic.git
synced 2025-05-18 05:38:23 +00:00
Linting
This commit is contained in:
parent
dcc85aec58
commit
308c2d0baf
57
basic.js
57
basic.js
@ -434,20 +434,20 @@ this.basic = (function() {
|
|||||||
0x00E6: function(v) { if (env.display) { env.display.hires_plotting_page = (v === 64 ? 2 : 1); } },
|
0x00E6: function(v) { if (env.display) { env.display.hires_plotting_page = (v === 64 ? 2 : 1); } },
|
||||||
|
|
||||||
// Keyboard strobe
|
// Keyboard strobe
|
||||||
0xC010: function(v) { if (env.tty.clearKeyboardStrobe) { env.tty.clearKeyboardStrobe(); } },
|
0xC010: function() { if (env.tty.clearKeyboardStrobe) { env.tty.clearKeyboardStrobe(); } },
|
||||||
|
|
||||||
// Display switches
|
// Display switches
|
||||||
0xC050: function(v) { if (env.display) { env.display.setState("graphics", true); } }, // Graphics
|
0xC050: function() { if (env.display) { env.display.setState("graphics", true); } }, // Graphics
|
||||||
0xC051: function(v) { if (env.display) { env.display.setState("graphics", false); } }, // Text
|
0xC051: function() { if (env.display) { env.display.setState("graphics", false); } }, // Text
|
||||||
0xC052: function(v) { if (env.display) { env.display.setState("full", true); } }, // Full Graphics
|
0xC052: function() { if (env.display) { env.display.setState("full", true); } }, // Full Graphics
|
||||||
0xC053: function(v) { if (env.display) { env.display.setState("full", false); } }, // Split Screen
|
0xC053: function() { if (env.display) { env.display.setState("full", false); } }, // Split Screen
|
||||||
0xC054: function(v) { if (env.display) { env.display.setState("page1", true); } }, // Page 1
|
0xC054: function() { if (env.display) { env.display.setState("page1", true); } }, // Page 1
|
||||||
0xC055: function(v) { if (env.display) { env.display.setState("page1", false); } }, // Page 2
|
0xC055: function() { if (env.display) { env.display.setState("page1", false); } }, // Page 2
|
||||||
0xC056: function(v) { if (env.display) { env.display.setState("lores", true); } }, // Lo-Res
|
0xC056: function() { if (env.display) { env.display.setState("lores", true); } }, // Lo-Res
|
||||||
0xC057: function(v) { if (env.display) { env.display.setState("lores", false); } }, // Hi-Res
|
0xC057: function() { if (env.display) { env.display.setState("lores", false); } }, // Hi-Res
|
||||||
|
|
||||||
// Speaker toggle
|
// Speaker toggle
|
||||||
0xC030: function(v) { } // no-op
|
0xC030: function() { } // no-op
|
||||||
};
|
};
|
||||||
|
|
||||||
call_table = {
|
call_table = {
|
||||||
@ -503,7 +503,7 @@ this.basic = (function() {
|
|||||||
throw new GoToLine(line);
|
throw new GoToLine(line);
|
||||||
},
|
},
|
||||||
|
|
||||||
'on_goto': function ON_GOTO(index, line1, line2 /* ... */) {
|
'on_goto': function ON_GOTO(index /* , ...lines */) {
|
||||||
index = (index - 1) >> 0;
|
index = (index - 1) >> 0;
|
||||||
var lines = Array.prototype.slice.call(arguments, 1);
|
var lines = Array.prototype.slice.call(arguments, 1);
|
||||||
|
|
||||||
@ -521,7 +521,7 @@ this.basic = (function() {
|
|||||||
throw new GoToLine(line);
|
throw new GoToLine(line);
|
||||||
},
|
},
|
||||||
|
|
||||||
'on_gosub': function ON_GOSUB(index, line1, line2 /* ... */) {
|
'on_gosub': function ON_GOSUB(index /* , ...lines */) {
|
||||||
index = (index - 1) >> 0;
|
index = (index - 1) >> 0;
|
||||||
var lines = Array.prototype.slice.call(arguments, 1);
|
var lines = Array.prototype.slice.call(arguments, 1);
|
||||||
if (index < 0 || index >= lines.length) {
|
if (index < 0 || index >= lines.length) {
|
||||||
@ -570,7 +570,7 @@ this.basic = (function() {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
'next': function NEXT(var1, var2 /* ... */) {
|
'next': function NEXT(/* ...varnames */) {
|
||||||
var varnames = Array.prototype.slice.call(arguments),
|
var varnames = Array.prototype.slice.call(arguments),
|
||||||
varname, stack_record, value;
|
varname, stack_record, value;
|
||||||
do {
|
do {
|
||||||
@ -640,7 +640,7 @@ this.basic = (function() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// PERF: optimize by turning into a function, e.g. "state.parsevar(name, lib.read())"
|
// PERF: optimize by turning into a function, e.g. "state.parsevar(name, lib.read())"
|
||||||
'read': function READ(lvalue1, lvalue2 /* ... */) {
|
'read': function READ(/* ...lvalues */) {
|
||||||
var lvalues = Array.prototype.slice.call(arguments);
|
var lvalues = Array.prototype.slice.call(arguments);
|
||||||
while (lvalues.length) {
|
while (lvalues.length) {
|
||||||
if (state.data_index >= state.data.length) {
|
if (state.data_index >= state.data.length) {
|
||||||
@ -657,7 +657,7 @@ this.basic = (function() {
|
|||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
'print': function PRINT(string1, string2 /* ... */) {
|
'print': function PRINT(/* ...strings */) {
|
||||||
var args = Array.prototype.slice.call(arguments), arg;
|
var args = Array.prototype.slice.call(arguments), arg;
|
||||||
while (args.length) {
|
while (args.length) {
|
||||||
arg = args.shift();
|
arg = args.shift();
|
||||||
@ -711,7 +711,7 @@ this.basic = (function() {
|
|||||||
throw new BlockingInput(im, ih);
|
throw new BlockingInput(im, ih);
|
||||||
},
|
},
|
||||||
|
|
||||||
'input': function INPUT(prompt, var1, var2 /* ... */) {
|
'input': function INPUT(prompt /* , ...varlist */) {
|
||||||
var varlist = Array.prototype.slice.call(arguments, 1); // copy for closure
|
var varlist = Array.prototype.slice.call(arguments, 1); // copy for closure
|
||||||
var im, ih;
|
var im, ih;
|
||||||
im = function(cb) { return env.tty.readLine(cb, prompt); };
|
im = function(cb) { return env.tty.readLine(cb, prompt); };
|
||||||
@ -906,7 +906,7 @@ this.basic = (function() {
|
|||||||
if (env.hires2) { env.hires2.setColor(n); }
|
if (env.hires2) { env.hires2.setColor(n); }
|
||||||
},
|
},
|
||||||
|
|
||||||
'hplot': function HPLOT(x1, y1, x2, y2 /* ... */) {
|
'hplot': function HPLOT(/* ...coords */) {
|
||||||
var hires = env.display.hires_plotting_page === 2 ? env.hires2 : env.hires;
|
var hires = env.display.hires_plotting_page === 2 ? env.hires2 : env.hires;
|
||||||
if (!hires) { runtime_error('Hires graphics not supported'); }
|
if (!hires) { runtime_error('Hires graphics not supported'); }
|
||||||
|
|
||||||
@ -932,7 +932,7 @@ this.basic = (function() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
'hplot_to': function HPLOT_TO(x1, y1, x2, y2 /* ... */) {
|
'hplot_to': function HPLOT_TO(/* ...coords */) {
|
||||||
var hires = env.display.hires_plotting_page === 2 ? env.hires2 : env.hires;
|
var hires = env.display.hires_plotting_page === 2 ? env.hires2 : env.hires;
|
||||||
if (!hires) { runtime_error('Hires graphics not supported'); }
|
if (!hires) { runtime_error('Hires graphics not supported'); }
|
||||||
|
|
||||||
@ -1032,7 +1032,7 @@ this.basic = (function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Apply a signature [return_type, arg0_type, arg1_type, ...] to a function
|
// Apply a signature [return_type, arg0_type, arg1_type, ...] to a function
|
||||||
function funcsign(func, return_type, arg0_type, arg1_type /* ... */) {
|
function funcsign(func /*, return_type, ...arg_types */) {
|
||||||
func.signature = Array.prototype.slice.call(arguments, 1);
|
func.signature = Array.prototype.slice.call(arguments, 1);
|
||||||
return func;
|
return func;
|
||||||
}
|
}
|
||||||
@ -1166,7 +1166,7 @@ this.basic = (function() {
|
|||||||
(function(source) {
|
(function(source) {
|
||||||
function munge(kw) {
|
function munge(kw) {
|
||||||
// Escape special characters
|
// Escape special characters
|
||||||
function escape(c) { return /[\[\]\\\^\$\.\|\?\*\+\(\)]/.test(c) ? '\\' + c : c; }
|
function escape(c) { return (/[\[\]\\\^\$\.\|\?\*\+\(\)]/).test(c) ? '\\' + c : c; }
|
||||||
// Allow linear whitespace between characters
|
// Allow linear whitespace between characters
|
||||||
//return kw.split('').map(escape).join('[ \\t]*');
|
//return kw.split('').map(escape).join('[ \\t]*');
|
||||||
|
|
||||||
@ -1670,7 +1670,7 @@ this.basic = (function() {
|
|||||||
|
|
||||||
function parseCommand() {
|
function parseCommand() {
|
||||||
|
|
||||||
function slib(name, arg0, arg1 /* ... */) {
|
function slib(name /* , ...args */) {
|
||||||
var args = Array.prototype.slice.call(arguments, 1);
|
var args = Array.prototype.slice.call(arguments, 1);
|
||||||
return 'lib[' + quote(name) + '](' + args.join(',') + ');';
|
return 'lib[' + quote(name) + '](' + args.join(',') + ');';
|
||||||
}
|
}
|
||||||
@ -1705,10 +1705,9 @@ this.basic = (function() {
|
|||||||
if (!subscripts) {
|
if (!subscripts) {
|
||||||
identifiers.variables[name] = true;
|
identifiers.variables[name] = true;
|
||||||
return 'state.variables[' + quote(name) + '] = ' + expr;
|
return 'state.variables[' + quote(name) + '] = ' + expr;
|
||||||
} else {
|
|
||||||
identifiers.arrays[name] = true;
|
|
||||||
return 'state.arrays[' + quote(name) + '].set([' + subscripts + '], ' + expr + ')';
|
|
||||||
}
|
}
|
||||||
|
identifiers.arrays[name] = true;
|
||||||
|
return 'state.arrays[' + quote(name) + '].set([' + subscripts + '], ' + expr + ')';
|
||||||
|
|
||||||
case kws.DIM:
|
case kws.DIM:
|
||||||
js = '';
|
js = '';
|
||||||
@ -1732,9 +1731,8 @@ this.basic = (function() {
|
|||||||
throw parse_error("DEF FN function type and argument type must match");
|
throw parse_error("DEF FN function type and argument type must match");
|
||||||
}
|
}
|
||||||
|
|
||||||
expr = vartype(name) === 'string'
|
expr = vartype(name) === 'string' ?
|
||||||
? parseStringExpression()
|
parseStringExpression() : parseNumericExpression();
|
||||||
: parseNumericExpression();
|
|
||||||
|
|
||||||
return slib('def', quote(name),
|
return slib('def', quote(name),
|
||||||
'function (arg){' +
|
'function (arg){' +
|
||||||
@ -1820,10 +1818,9 @@ this.basic = (function() {
|
|||||||
if (test('number')) {
|
if (test('number')) {
|
||||||
// IF expr THEN linenum
|
// IF expr THEN linenum
|
||||||
return js + slib('goto', match('number'));
|
return js + slib('goto', match('number'));
|
||||||
} else {
|
|
||||||
// IF expr THEN statement
|
|
||||||
return js + parseCommand(); // recurse
|
|
||||||
}
|
}
|
||||||
|
// IF expr THEN statement
|
||||||
|
return js + parseCommand(); // recurse
|
||||||
|
|
||||||
case kws.END: // End program
|
case kws.END: // End program
|
||||||
return slib('end');
|
return slib('end');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user