-
Notifications
You must be signed in to change notification settings - Fork 2
Quickstart
Welcome to the SIMAS programming language!
SIMAS stands for Simple Assembly, a programming language with a syntax inspired heavily by Assembly.
SIMAS code, in files ending in .simas
, compiles to .csa
bytecode, which stands for Compiled Simple Assembly, which is then execued by the SIMAS runtime environment.
There are 3 basic types in SIMAS: bool
, num
and str
Each line of SIMAS starts with an instruction, followed by zero or more operands. Instructions and types are case-insensitive, and everything else are case-sensitive
To get started, download the latest release from the release page, or git clone
it locally and build it.
It is recommended that you add both the executable simasc
(compiler) and simas
(runtime environment) to your PATH.
Tip
If you're using Visual Studio Code(VS Code), you can install the SIMAS Language Support Extension for syntax highlighting and code completion
run simas init myProject
in your command line, and you should see a project called myProject initialized, with some default this SIMAS code generated:
PRINTC Hello World!;
Note
It is case-insensitive for instructions(like printc
) and data types. But for everything else, capitalization matters.
By convention, it is good practice to all-caps your instructions and data types.
Alternatively, you can just create a file with the contents above.
To run it, enter the following in your command line:
simasc Main.simas
This should compile your .simas
file into a .csa
file. If you created your own file instead of using simas init
, just replace Main.simas
with whatever your filename is.
Now, to execute the bytecode, type in the following:
simas Main.csa
Again replace Main.csa
with the name of your generated .csa
file. It should print Hello, World!
.
Use the same process to execute any SIMAS programs in the future.
Congrats! You just wrote your first SIMAS program!
Let's explore some basic operations in SIMAS.
Variables and Assignment:
-
Declaring a Variable: In SIMAS, you don't explicitly declare variable types. You can simply assign a value to a variable, and its type will be inferred.
-
Example:
set num myNumber 10;
This line declares a variable named myNumber
and assigns the integer value 10
to it.
Arithmetic Operations:
-
SIMAS supports basic arithmetic operations:
-
add
: Adds two numbers. -
sub
: Subtracts two numbers. -
mul
: Multiplies two numbers. -
div
: Divides two numbers.
-
-
Example:
set num result 3;
add num result 5;
print result;
This code will:
- Calculate
5 + 3
and store the result (8) in theresult
variable. - Print the value of
result
to the console.
Caution
Please put one space and one space only between operands and instructions, as well as between operands themselves. If more than one space is entered, unexpected behavior might occur
There are a few different types of print statements in SIMAS
-
print
This prints a variable. Example:
set str myName Aarik;
print myName;
-
println
This prints a new line. Example:
println;
-
printc
This prints a constant. Example:
printc Hello!;
printc 10;
printc false;
-
prints
This prints a space. Example:
prints;
Comments are ignored by the SIMAS runtime. They are designed for humans to read code easier. On SIMAS, comments are single-lined and starts with @
and ends with ;
@ This is a comment;
If you want to be polite to SIMAS, you can optionally add the keyword PLEASE
(case-insensitive) in front of any instruction.
please printc Hello;
Does the exact same thing as
printc Hello;
Important
please
doesn't do anything, but it does make you a more polite programmer.
It is very important to be polite to everyone.
This Quickstart is just the tip of the massive SIMAS iceberg. If you want to learn more, you can:
- read the README.md
- contribute by open an issue or a pull request
- explore the rest of the wiki
Lastly, if you enjoyed SIMAS, please consider starring this repo. Thanks!
Copyright (c) 2024 Turrnut