Menu

Tree [d09f8b] master /
 History

HTTPS access


File Date Author Commit
 LICENSE 2018-10-31 pankuznetsov pankuznetsov [bd0263] Initial commit
 README.md 2019-02-02 pankuznetsov pankuznetsov [d5e43f] Update README.md
 paloaltobasic.rb 2019-02-03 pankuznetsov pankuznetsov [d09f8b] Some comments

Read Me

PaloAlto BASIC in Ruby less then in 500 lines

PaloAlto BASIC (also known as Tiny BASIC) interpreter less than in 500 lines writen in Ruby.
The original program takes only 3KB or ROM and runs on Intel 8080, Motorola 6800 and MOS Technology 6502 processors.

This BASIC understands a few statements and all variables there are 16 or 32-bit integers.

Take a look on Wikipedia page.

The grammer is also pretty simple and can be described in ABNF just in a few lines:

CR stands for Carret Return (\r\n or \n, depends on OS)

empty stands for nothing.

space stands for any white space _ASCII symbol._

(...)* means that ... may be repeated zero or more times.

digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

lowercase ::= a | b | c ... x | y | z

uppercase ::= A | B | C ... X | Y | Z

letter ::= lowercase | uppercase

number ::= digit (digit)*

string ::= " (letter | digit | space)* "

var ::= uppercase

var-list ::= var (, var)*

factor ::= var | number | ( expression )

term ::= factor ((_ | /_) factor)

expression ::= (+ | - | empty) term ((+ | -) term)*

expression-list ::= (expression | string) (, expression | string)*

ralational-operator ::= (< (> | = | empty)) | (> (< | = | empty)) | =

statement ::= PRINT expression-list
| INPUT var-list
| LET var = expression
| GOTO expression
| GOSUB expression
| RETURN
| IF expression relational-operator THEN statement
| END

line ::= ((number statement) | (statement)) CR

To run the programm just download paloaltobasic.rb and run it using ruby paloaltobasic.rb. Program works stable on Ruby version 2.6.

Contact me via e-mail pankuznetsov@gmail.com.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.