basic: optional labels setting

This commit is contained in:
Steven Hugg 2020-08-08 20:03:48 -05:00
parent 14524726e6
commit bbae87269f
3 changed files with 17 additions and 10 deletions

View File

@ -521,8 +521,4 @@ Don't grab cursor focus when trap occurs (how do we know?)
Use tick() and refresh(), not callbacks
Show current datum when using READ
Use https://codemirror.net/doc/manual.html#markText
Reset doesn't break @ start unless debugging tools expanded

View File

@ -206,6 +206,7 @@ function stripQuotes(s: string) {
// TODO: implement these
export interface BASICOptions {
uppercaseOnly : boolean; // convert everything to uppercase?
optionalLabels : boolean; // can omit line numbers and use labels?
strictVarNames : boolean; // only allow A0-9 for numerics, single letter for arrays/strings
sharedArrayNamespace : boolean; // arrays and variables have same namespace? (conflict)
defaultArrayBase : number; // arrays start at this number (0 or 1)
@ -290,9 +291,13 @@ export class BASICParser {
line.label = tok.str;
this.curlabel = tok.str;
break;
case TokenType.Float1:
case TokenType.Float2:
this.compileError(`Line numbers must be positive integers.`);
break;
default:
// TODO
this.pushbackToken(tok);
if (this.opts.optionalLabels) this.pushbackToken(tok);
else this.dialectError(`optional line numbers`);
break;
}
}
@ -340,8 +345,10 @@ export class BASICParser {
// not empty line?
if (this.tokens.length) {
this.parseOptLabel(line);
line.stmts = this.parseCompoundStatement();
this.curlabel = null;
if (this.tokens.length) {
line.stmts = this.parseCompoundStatement();
this.curlabel = null;
}
}
return line;
}
@ -637,6 +644,7 @@ export class BASICParser {
if (isEOS(tok)) break;
list.push(tok.str);
} while (true);
this.pushbackToken(tok);
var stmt : OPTION_Statement = { command:'OPTION', optname:tokname.str, optargs:list };
this.parseOptions(stmt);
return stmt;
@ -700,6 +708,7 @@ export class BASICParser {
export const ECMA55_MINIMAL : BASICOptions = {
uppercaseOnly : true,
optionalLabels : false,
strictVarNames : true,
sharedArrayNamespace : true,
defaultArrayBase : 0,
@ -725,6 +734,7 @@ export const ECMA55_MINIMAL : BASICOptions = {
export const ALTAIR_BASIC40 : BASICOptions = {
uppercaseOnly : true,
optionalLabels : false,
strictVarNames : true,
sharedArrayNamespace : true,
defaultArrayBase : 0,

View File

@ -256,6 +256,7 @@ class BASICPlatform implements Platform {
tty: TeleTypeWithKeyboard;
ips: number = 500;
clock: number = 0;
hotReload: boolean = false;
constructor(mainElement: HTMLElement) {
//super();
@ -331,7 +332,7 @@ class BASICPlatform implements Platform {
this.program = data;
this.runtime.load(data);
// only reset if we exited, otherwise we try to resume
if (didExit) this.reset();
if (!this.hotReload || didExit) this.reset();
}
getROMExtension() {