Skip to content

An interpreter for a limited subset of the programming language BASIC. It can read, parse, and execute 7 different commands: print, let, if, gosub, goto, return, end. It can parse numeric expressions and store them into variables and arrays.

Notifications You must be signed in to change notification settings

MohibMirza/BASIC-Interpreter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

HOW TO USE:

Put your BASIC code into a txt file. Format each line like this:

<LINE> <COMMAND>

ex. 
1 PRINT ((1+21)/7)
2 GOTO 20
3 LET X 5
20 END

RUN MAKE AND TYPE ./interpreter <FILE> TO EXECUTE THE CODE!

COMMAND LOGIC:

PRINT <NUM> - PRINTS A NUMERIC EXPRESSION'S VALUE
LET <VAR> <NUM> - STORES VALUE OF NUM'S VALUE INTO VAR
LET <VAR> [<NUM1>] <NUM2> - STORES NUM2'S VALUE AT NUM1 INDEX OF ARRAY VAR
GOTO <LINENO> - JUMPS TO THIS LINENO IN CODE. (LINE NUMBERS ARE FORMATTED BEFORE EACH COMMAND)
IF <BOOL> THEN <LINE> - IF BOOL IS TRUE, IT WILL JUMP TO LINE, IF NOT THE CODE CONTINUES CHRONOLOGICALLY
GOSUB <LINENO> - JUMPS TO LINENO AND RETURNS BACK TO THIS LINE ONCE IT HITS AN END STATEMENT (CAN BE USED FOR RECURSION! :D)
END - TERMINATES PROGRAM. IF WITHIN A GOSUB, THEN JUMPS BACK TO THE GOSUB.

About

An interpreter for a limited subset of the programming language BASIC. It can read, parse, and execute 7 different commands: print, let, if, gosub, goto, return, end. It can parse numeric expressions and store them into variables and arrays.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published