Smol interpreted language.
This is a small educational language I made with the primary intent
to help new students get accustomed to programming without having to know
intricate programming concepts.
It is not intended to make sense for a seasoned programmer, but for people who
are not that familiar with programming yet.
It at this point has also become an expiriment to see how well a language that does not have expressions fairs.
And for some reason i made it compile chip-8 ROMS. (wip)
- install the golang language. How to do this can be found here
- execute the following commands
$ go get github.com/fabulousduck/smol
$ cd $GOPATH/src/github.com/fabulousduck/smol/cmd
$ go build main.goOnce you have built the main.go file, you can execute it with any .lo file like so:
./main ../examples/example.lo- The file extention for smol is
.lo
The syntax of smol is extremely small and aims to resemble something between lolcode and x86_64 ASM. Although it does not implement any of the x86_64 keywords. It does however keep to the style of 3 letter keywords.
All statements must end with a ;. Not doing so will result in syntax errors.
In smol MEM is used to declare a variable on the stack. Losp only supports whole integers as variable types. This is done on purpose to make the programmer use arithmatic to accomplish tasks like you would in assembly.
Example:
MEM A 20;
PRI A;outputs:
20
PRI stands for "PRint Integer, so as the name suggests, the second parameter must be a number litteral or a variable name.
Example:
MEM A 20;
PRI A;outputs:
20
Pru is the same as PRI but instead of simply printing to the screen what it is given. I will use the given variable and lookup its associated value on the unicode table. So this can be used to print a character instead of an integer.
Example
Example:
MEM A 72;
PRU A;outputs:
H
INC increments value V where V must be a variable. trying to call INC on a number litteral will result in a syntax error.
Example:
Example:
MEM A 20;
INC A;
PRI A;outputs:
21
Simply prints a \n character to the terminal
Smol has support for simple functions. The can be defined like so:
FUNCTION_NAME[1,2];
DEF FUNCTION_NAME<PARAM_A,PARAM_B>:
PRI A;
PRI B;
END
Functions do not support return values yet.
SWT is a the switch equivelant of smol. It supports cases using either number litterals or variables. it also supports default cases. it can be used like so:
Example:
MEM A 30;
MEM B 10;
SWT[B]: #Switch
CAS 10: #case
PRI 700;
BRK;
END
CAS 20:
PRI 20;
BRK;
END
CAS A:
PRI A;
BRK;
END
EOS: #End Of Switch
PRI 30;
BRK;
END
END
outputs
700CAS defines a case within a switch.
Example:
MEM A 30;
MEM B 10;
SWT[B]:
CAS 10: #case
PRI 700;
BRK;
END
CAS A:
PRI A;
BRK;
END
END
outputs
700EOS can be used to declare a default case in a SWT statement
Example
MEM A 100;
MEM B 44;
SWT[B]: #SWiTch
CAS 10: #case
PRI 700;
BRK;
END
CAS 20:
PRI 20;
BRK;
END
CAS A:
PRI A;
BRK;
END
EOS: #End Of Switch
PRI 30;
BRK;
END
END
outputs
30ANB is the while loop of smol. It will run its body untill A == B. So it can be seen as a simple while a != b {} loop.
Example:
MEM A 0;
MEM B 10;
ANB[A,B]:
PRI A;
BRK;
INC A;
END
PRU 0;
outputs
0
1
2
3
4
5
6
7
8
9
EQ stands for "equals" and checks if A == B.
Example
MEM A 10;
EQ[A, 10]:
PRI A;
END
outputs:
10
NEQ stands for "not equals" and checks if A == B.
Example
MEM A 11;
NEQ[A, 10]:
PRI A;
END
outputs:
10
GT stands for "greater than" and checks is A < B
Example
MEM A 10;
GT[A, 9]:
PRI A;
END
outputs:
10
LT stands for "less than" and checks if A < B
Example
MEM A 10;
LT[A, 11]:
PRI A;
END
outputs:
10
Smol supports the basic mathematical operators and all work the same way. When called, like in assebly, the result of the calculation will be stored in the left hand variable given. this means it is not possible for the left hand side to be a number litteral.
Adds A and B
MEM A 10;
MEM B 20;
ADD A B;
outputs
30
Subtracts B from A
MEM A 20;
MEM B 10;
SUB A B;
outputs
10
multiplies A and B
MEM A 10;
MEM B 20;
MUL A B;
outputs
200
Devides A by B
MEM A 20;
MEM B 10;
DIV A B;
outputs
2
Smol has support for code comments using the # symbol.
Example
MEM A 10; #side comment
#top comment
MEM B 20;