History of yabasic

Early in 1995 I came across the book "Compilerbau" (ISBN 3-519-32338-9) by Niklaus Wirth. Reading this great book left me with the impression, that writing a compiler or interpreter would be a breeze ;-). So I started to write my own interpreter; and as basic was the only interpreted language I had experience with, I started to write a basic interpreter.

A first version of yabasic was completed around May 1995, still missing many features (no arrays, no loops, just goto); nevertheless I released it as version 1.0. Having released yabasic to the public, yabasic users sent me bug reports and feature requests, which drove the further developement.

The next major improvement came in summer 1996, when I got my Windows95-machine: Porting yabasic to the Win32-platform took two weeks and writing an installation program took a month. This was version 2.0 .

Having ported yabasic to Windows the stream of bug reports and feature requests began to swell. After two and a half years it had reached a level I could not handle in a resonable manner. And I decided to share the work. As the code of yabasic is somewhat obfuscated, I could not expect anyone to fix the numerous bugs in yabasic. Therefore I choose to let the users care about the new features. And as the users of yabasic mostly liked to program in yabasic, the new features had to be added using yabasic (not C). Therefore I added subroutines and libraries to yabasic in summer 1999, releasing it as version 2.57 . The idea is, that users may now implement new features as a set of subroutines in a separate library and may share them with others. On the long term we should end up with a standard library for yabasic, and of course: Any help is welcome !

Between 2006 and 2013 I hardly worked on yabasic, because my professional and domestic duties were demanding more and more of my time. In december 2013 I noticed, that to my regreet yabasic could no longer be build on a modern linux system ! Luckily, january 2014 I changed jobs and had some weeks of sparetime, which allowed me to make some bugifxes and updates to the toolchain, so that yabasic is now usable on modern systems again.

For the future, my intent is to keep yabasic up to date, add some features, fix bugs and answer any user-question.

Flex and Bison

You may have noticed from the above, that yabasic made quite a rapid start; this is mainly due to flex and bison, the prime tools, used to implement yabasic (refer to "lex & yacc" by John R. Levine, Tony Mason and Doug Brown, ISBN 1-56592-000-7) .

Bison and flex take the grammar in Backus-Naur-form and produce two C-programs, which all by themselves can parse an input program in the new language and verify it for grammatical correctness. The only thing left to the programmer is to put flesh on this skeleton, so that the parsed and verified input program actually does something.

This process is remarkably efficient: 32 kB of flex and bison instructions generate 184 kB of C-code, which has to be compared with the 199 kB of C-code which I wrote myself. Together these implement the functionality of yabasic. So actually half of the code has been generated by flex and bison !

Execution of a program

Although yabasic behaves mostly like an interpreter, it is rather a compiler: If you give it any basic-code for execution, the code is compiled, yielding instructions for a weird and simple stack-machine. These instructions are then interpreted immediately, so that you will never get in touch with the stack-machine. But you may find out the time needed for the different phases of this process, if you invoke yabasic with infolevel set to note.