Applesoft BASIC appears to not care about whitespace, but it gets a little weird with AT/ATN/TO. For example, you can write A TO X AT O, but if you crunch the whitespace out it will instead be parsed as A TO XA TO. For everything else, whitespace is ignored. ON ERR GO TO becomes ONERR GOTO. The trick when scanning is to find the longest match (ON is also ...
Here's something that should do the trick.
It's written in AWK. Any language I picked will be the wrong language. awk (or gawk) is everywhere.
Copy and paste it into a file (say, expand.awk).
awk -f expand.awk crunched.bas > uncrunched.bas
# License: Creative Commons 0 https://creativecommons.org/share-your-work/public-domain/cc0/
If you're happy with a .net core solution you could take my MS Basic clone, load the code and then save it again.
You would need to remove the EditLine function in the GlassTeletype which uses Win32 interop to provide an line editor (invoked by edit nnnn where nnnn is the linenumber) and maybe give it a little tweak ...
In general: there were some system variables, system stack, display memory, buffers, etc. On some systems, there was a RAM area "under" the ROM (it means on the same address, but not accessible in a straight way) - for example, the Atari XL.
I seem to remember a statement that was spelled 'something like' EDITLN or EDITLINE or LINEDIT,
TL;DR: There was EDIT in many (MS-)BASICs, but it was a direct command, not applicable during runtime.
I guess that memory is about EDIT <line>. A command present since Altair BASIC, but optional, depending on the philosophy and space. It was ...
Beta Basic for the ZX Spectrum had ALTER, which was specifically intended to "alter references in the program" as demonstrated by this code:
1 LET free=MEM()
2 FOR n=1 TO 100
3 ALTER (n) TO "VAL"+CHR$ 34+STR$ n+CHR$ 34
4 NEXT n 5 PRINT "Saved ";MEM()+28-free;" bytes"
This replaces all numbers in the program from 1 to 100 with a variable. The manual ...
In the APPLE II, the DOS 3.3 had a program called Phone List which stored the data of the phone numbers by modifying itself. It had empty DATA instructions from the lines 200 to 400 and this instructions would get filled when one entered new records. Upon program termination a SAVE would be executed to save the contents of the program again. Next time the ...
If your looking for concepts to add to BASIC, One of the most advanced BASICS of the time was Microware's BASIC09 for the 6809. It had removed line numbers as well as added structured programming concepts. It had a number of features that took advantage of the processor that might be very difficult to do on a 6502.
Considering how much of a rush job Locomotive BASIC was, it's remarkably good. But it's not perfect.
Sinclair BASIC has one powerful keyword that Locomotive BASIC lacks: VAL. Sure, Locomotive BASIC has a VAL() function, but Sinclair's one is a function evaluator:
10 FOR X=-5 TO 5
20 PRINT X,VAL ("X * X")
30 NEXT X
This would fail on an Amstrad CPC, but on ...
Was Locomotive BASIC significantly better than Sinclair BASIC?
TL;DR: Oh, yes, it was!
I'm aware that both Basics were more advanced than the C64 Microsoft implementation,
Comparison of C64 BASIC to other BASICs of the same time is never in favour for the C64, as it's a quick port of the original 1977 PET Version.
but neither [Locomotive BASIC, ...
The big improvement to the language in Locomotive BASIC, compared to Sinclair BASIC (and many other BASICs), was the addition of timer support:
AFTER 50,0 GOSUB 320
would call the subroutine at line 320 after a second, and
EVERY 500,0 GOSUB 320
would call the subroutine every ten seconds. In both cases, the first value is the interval in fiftieths of a ...
If by "unavailable to store BASIC program text," the general answer
would be "all sorts of stuff." A typical memory map for an early
Apple system would be along the lines of the following:
$0000 - $00FF (0 - 255): Zero Page (system variables)
$0100 - $01FF (256 - 511): 6502 Processor Stack
$0200 - $02FF (512 - 767): GETLN Line Input Buffer
$0300 - $03CF (...
Let's take for example an MSX computer with 64K RAM. That's what you get on boot:
Where does this 28815 come from?
To start with, a MSX is a Z80 based machine. The Z80 has an addressing space of 64K. The MSX standard divides these 64K in four 16K pages that can be independently switched to any internal or external memory slot.
When booting in BASIC mode (...
Dartmouth Basic wasn't an interpreter at all — it compiled directly into machine code when the user typed RUN. It was designed so that the program appeared to start executing almost immediately, and there were a number of tricks that made this possible.
Speed of compilation was a design criterion. The compiler only needed a single pass over the input, and ...
were these interpreters implemented as tree-walker interpreters
(simply traversing the parse tree) or bytecode interpreters?
I have been looking at various BASICs for the last while. The answer is "all of the above".
Pure interpreters - Tiny BASIC
TinyBASIC parsed the line to the extent of converting the line number to an 8-bit value to see if the line ...
Most early 8-bit personal computer Basic interpreters were tokenized recursive descent interpreters. Tokenized to reduce the size of the program text, as well as speed up the interpreter by not have to parse text at runtime, and runtime recursive descent, trading off stack space usage versus having to build a parse tree in memory beforehand. Very few (if ...
The Sinclair systems were tokenised directly at the keyboard, so there was almost no lexical analysis. Keys were inputs to a state machine that implemented the BASIC language structure in a ROM table.
The first keystroke would have a label on it -- maybe the P key was also labelled Print, G was Goto, and the L key was Let. After that was hit, the state ...
[W]ere these interpreters implemented as tree-walker interpreters or bytecode interpreters?
Neither, or both. They are kind of source code interpreters - much like (classic) shell scripts - except they used a tokenized storage format (*1). Their structure was dictated by balancing lack of memory, lack of interpreter code and desired optimization for speed (*...