From ff780236d315e3e8d8845fa501d68edf4bc8fabe Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Thu, 13 Aug 2020 12:51:35 -0500 Subject: [PATCH] basic: HPBASIC, TINY, computedGoto, required END (18, 57, 111) --- presets/basic/sieve.bas | 4 +- src/common/basic/compiler.ts | 236 ++++++++++++++++++++++++++++++----- src/common/basic/runtime.ts | 98 +++++++++++---- src/common/teletype.ts | 3 +- 4 files changed, 285 insertions(+), 56 deletions(-) diff --git a/presets/basic/sieve.bas b/presets/basic/sieve.bas index b28e6e64..ff2408e1 100644 --- a/presets/basic/sieve.bas +++ b/presets/basic/sieve.bas @@ -1,6 +1,8 @@ -005 OPTION CPUSPEED MAX +001 OPTION DIALECT MODERN +002 OPTION CPUSPEED MAX 010 REM***A PRIME NUMBER SIEVE BENCHMARK 020 T = TIMER +022 C = 0 025 N = 8191 030 DIM F(N+1) 040 FOR I = 0 TO N : F(I)=1 : NEXT I diff --git a/src/common/basic/compiler.ts b/src/common/basic/compiler.ts index d64757ae..1196613b 100644 --- a/src/common/basic/compiler.ts +++ b/src/common/basic/compiler.ts @@ -7,7 +7,8 @@ export interface BASICOptions { uppercaseOnly : boolean; // convert everything to uppercase? optionalLabels : boolean; // can omit line numbers and use labels? optionalWhitespace : boolean; // can "crunch" keywords? - varNaming : 'A1'|'AA'|'*'; // only allow A0-9 for numerics, single letter for arrays/strings + varNaming : 'A'|'A1'|'AA'|'*'; // only allow A0-9 for numerics, single letter for arrays/strings + squareBrackets : boolean; // "[" and "]" interchangable with "(" and ")"? tickComments : boolean; // support 'comments? hexOctalConsts : boolean; // support &H and &O integer constants? validKeywords : string[]; // valid keywords (or null for accept all) @@ -27,6 +28,7 @@ export interface BASICOptions { defaultArrayBase : number; // arrays start at this number (0 or 1) defaultArraySize : number; // arrays are allocated w/ this size (starting @ 0) maxDimensions : number; // max number of dimensions for arrays + arraysContainChars : boolean; // HP BASIC array-slicing syntax // PRINTING printZoneLength : number; // print zone length numericPadding : boolean; // " " or "-" before and " " after numbers? @@ -35,7 +37,9 @@ export interface BASICOptions { optionalNextVar : boolean; // can do NEXT without variable multipleNextVars : boolean; // NEXT J,I checkOnGotoIndex : boolean; // fatal error when ON..GOTO index out of bounds + computedGoto : boolean; // non-const expr GOTO label (and GOTO..OF expression) restoreWithLabel : boolean; // RESTORE