File | Date | Author | Commit |
---|---|---|---|
LICENSE | 2018-10-31 |
![]() |
[bd0263] Initial commit |
README.md | 2019-02-02 |
![]() |
[d5e43f] Update README.md |
paloaltobasic.rb | 2019-02-03 |
![]() |
[d09f8b] Some comments |
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
.