esolang

stupidBASIC

It reads like BASIC and works like an accumulator machine, and one of its ifs runs when it feels like it.

2021 · Turing complete: unknown · ●○○ easy · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: Hello, world!

The idea

stupidBASIC is a 2021 member of the stupid family of languages, next to stupidc and stupidexpr. Its lines look like BASIC, a command and an argument, but every command works one accumulator, as the Asparagus assembly does. Every value is text and turns into a number only when arithmetic needs one.

Read the story

The argument runs to the end of the line, and its spaces count. store this is a variable and store thisisavariable name two different variables, and set bottles of beer with two spaces sets a text that starts with a space. The specification warns that some commands change the accumulator without telling you, that multiply, divide and modulo are to be removed for extra stupidity, and that ifidk runs its block if the interpreter feels like it.

The machine

CommandDoes
load x store xAccumulator from or to a variable
set text append text newlineSet the accumulator; add text or a line break to it
add n subtract n multiply n divide n modulo nArithmetic on the accumulator
print print newline say textPrint the accumulator, a line break or the text
ask text get key get key and waitRead a line or a key into the accumulator
get random get timer get timeA random number or the clock
if n ... end ifRun the block when the accumulator equals n
ifne iflt ifgt ifle ifge ifidkThe same for other comparisons, and for a whim
loop ... end loopRepeat until an exit loop
program name ... end programA routine for do name; the one without a name runs
exit remLeave the block named, or the innermost one; a comment

An argument that starts with a digit is a number, anything else names a variable. This implementation has no clock, so timer and time read 0, and random and ifidk draw from a fixed seed. Every run replays.

Example

The cat echoes one key.

The cat echoes one key.

Expected: a

A countdown prints the accumulator, takes 1 and leaves the loop at 0.

Expected: 321

The 99 bottles of beer program counts down the same way and ends with exit program. The specification does not say how a number looks after arithmetic, and this implementation writes 98 as plain digits.

Expected: hihi

Further

Also in Jokes

Write your own in Run Convert a program from stupidBASIC

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: stupidbasic.

Command line

shib run stupidbasic -e 'program
 say Hello, world!
end program'
shib manual stupidbasic

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/stupidbasic.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org