User Tools

Site Tools


en:techinformation

Developer and Technical

Overview

BASIC-256 programs are first compiled to byte code using LEX and YACC, and then run by interpreting the byte code in a stack machine. Adding functions is a simple matter of adding a byte code, letting LEX and YACC know how to parse the syntax, and coding the appropriate instruction in the interpreter. If you've never written a compiler or interpreter, the BASIC-256 internals would provide an excellent introduction to the basics of that.

Please keep in mind that BASIC-256 is a teaching language for children (target ages 7-9), so we'd like to stay away from advanced concepts as much as possible. While it would be fun to make BASIC-256 a powerful high-level language, there are already much better languages that exist to fill that need: Python, Scheme.

To do

  1. Real-time error checking in the editor (parse each line just after it's typed)

The life of a BASIC-256 program

  1. BASIC program parsed into tokens by LEX
  2. LEX feeds tokens to YACC
  3. YACC determines if line is valid syntax. If so, it adds the appropriate byte codes to the byte-coded program
  4. If no syntax errors occur, the C++ portion of the program interprets the byte code one instruction at a time, using a stack machine
  5. Run time errors halt program execution and display an error message on the screen

Graphical Output

All graphing functions are performed on a buffer, which is subsequently written to the screen immediately after each operation. This is intentionally inefficient. The “fast” way to do this would be to have a separate rendering thread that calls a display routine when it's done, or to do all the rendering in the display routine.

This is an ideal illustration of concessions made in BASIC-256 to keep things simple. We're interested in kids being able to see their dots move across the screen without having to explain double-buffering and multi-threading. We also want to allow them to write games like Pong that test for collisions using basic geometric formulas and draw the ball and paddles in a single loop. The current approach allows for this.

Note: To speed things up for children doing more advanced programs, the FASTGRAPHICS mode has been added. When in this mode, the display will only be updated when the BASIC program uses the REFRESH command. This allows kids to benefit from double-buffering without having to understand it completely.

en/techinformation.txt · Last modified: 2020/02/28 10:46 (external edit)