This project is meant to be run using .NET 9 and C# 13.
To interpret your MiniBasic source files (.mb) run the following command in the project root directory:
dotnet run NAMES_OF_SOURCE_FILES_SEPARATED_BY_SPACESThe interpreter will then interpret the given program. If a file is inaccessible, due to any reason, its parsing will be skipped without stopping the interpreter.
- INTEGER -
%- Their size will be
32-bit
- Their size will be
- STRING -
$ - Arrays -
[]- Only arrays of INTEGERs
%[]and STRINGs$[]are supported - Arrays are indexed from
0, cannot be multidimensional - Only basic indexing is supported
- Only arrays of INTEGERs
- For INTEGER:
+,-,*,/,MOD - For STRING:
+,LEN%,MID$ - For Arrays:
[]
Variables are declared using the DIM keyword.
Variables are strongly typed, their names are case-sensitive and must satisfy the regex: ^[a-zA-Z_][a-zA-Z0-9_]*$.
INPUTwill be used to read from the standard input (no;joining ofPRINTs and without theLINEspecifier)PRINTwill be used to print variables to the standard output (no;joining ofPRINTs)
-
No forward declarations are allowed
-
SUB/FUNCTIONparameters are passed by reference and must be strongly typed -
SUB/FUNCTIONcan only see parameters inside their scope -
No
SUB/FUNCTIONcan be defined inside anotherSUB/FUNCTION -
Each
SUB/FUNCTIONmust have a unique name and their name must also satisfy the variable name regex -
SUBs are called with theCALLkeyword with their parameters between(and) -
SUBcannot return any value -
Return type for
FUNCTIONmust be strongly typed as well, and it can only returnINTEGERorSTRING
Each label must be defined on a new line.
Label names must satisfy the regex : ^[a-zA-Z_][a-zA-Z0-9_]*:$, similar to variables, but their definition must end in :.
GOTO is used to jump to label using its name.
Without the trailing :.
GOTO cannot jump outside current SUB/FUNCTION body.
Only block statements are supported, no single line IF THEN ELSE statements are allowed.
Branching with ELSEIF is allowed as well.
Variables defined inside a block are not accessible from other blocks.
The index variable is implicitly declared, do not re-declare it. The NEXT keyword must be followed by the index variable.
No extra restrictions, STEP statement is allowed as well.
Variables defined inside FOR loop are not accessible from outside.
- The first source code outside any
SUB/FUNCTIONbody will be considered as the entry point - The entry point will end with the first
SUB/FUNCTIONbody definition or with the end of file
Comments are declared using the REM keyword.
Any incorrect usage (invalid variable name, out-of-bounds indexing, GOTO to non-existent label, ...) will result in stopping the interpretation and an error message.
To get to know the language more try some example programs, you can find them in ./examples.