A javascript based minimal basic toy compiler and runtime envionment
- Create a frontend only minimal UI
- Striped Editor where code will be written
- Emulated Terminal, that can print
- Emulated Terminal, that can handle input with callbacks
- Run/Clear Button
- Create a lexer, that can parse raw code and generated tokenised code
- Create a parser, that can parse tokenised code and generated op code
- Create a runtime, that can run op code and interact with emulated terminal for output and input
- Debugging Controls
- Show variable and call stack while debugging mode
- Show syntax errors
The runtime should be able to handle the below basic commands
-
LET
—assigns a value (which may be the result of an expression) to a variable. -
DATA
—holds a list of values which are assigned sequentially using the READ command. -
READ
-reads data from DATA statements into variables
-
IF ... THEN ... {ELSE}
—used to perform comparisons or make decisions. -
FOR ... TO ... {STEP} ... NEXT
—repeat a section of code a given number of times. A variable that acts as a counter is available within the loop. -
WHILE ... WEND
—repeat a section of code while the specified condition is true. The condition may be evaluated before each iteration of the loop. -
REPEAT ... UNTIL
—repeat a section of code while the specified condition is true. The condition may be evaluated after each iteration of the loop. -
DO ... LOOP {WHILE}
or {UNTIL
}—repeat a section of code Forever or While/Until the specified condition is true. The condition may be evaluated before each iteration of the loop, or after. -
GOTO
—jumps to a numbered or labelled line in the program. -
GOSUB
—jumps to a numbered or labelled line, executes the code it finds there until it reaches a RETURN Command, on which it jumps back to the operator following the GOSUB – either after a colon, or on the next line. This is used to implement subroutines. -
ON ... GOTO/GOSUB
—chooses where to jump based on the specified conditions. See Switch statement for other forms.
-
PRINT
—displays a message on the screen or other output device. -
INPUT
—asks the user to enter the value of a variable. The statement may include a prompt message.