S.I.L.O.S or SIL is designed for a nostalgic view of the past. It is simple and minimalistic, but remains capable of universal computation. Feel free to | try this language online! The interpreter is hosted by Dennis Mitchell.
S.I.L.O.S stands for
It is also known as SIL (Simple Interpreted Language)
The syntax is simple
//One command per line //one letter variable names //Only type integer //No declaration needed they all start at 0 //direct access to the memory array a = get 5 lblFoo GOTO Foo No syntax checking VB like behavior allowing erros to pass unnoticed and unhandled if x Foo //goes to Foo iff x>0 a - b subtraction a + b addition a * b multiplication a / b division a % b modulus a | //absolute value of a and reassigns this to a ~ bitwise not a < b left shift a > b right shift a & b bitwise and a : b or a ! b xor a ? b xnor a ^ b a raised to the b //all assignment operators x - 5 is the equivalent of x-=5 for those familiar with C styled languages
That is the basic syntax, note that as of this printing, integers are 32 bit signed integers [-1*2^31,2^31-1] which overflow and wrap around. There is a plan to make them big numbers with unbounded size.
You can directly write to the memory buffer like such
set 288 57 //acccesses the heap at 288 and sets it to 57 a = get 288 //gets back what the thing at position 288 printInt a set a 88 //sets the thing at position a to 88 b = get a //gets the thing at position a and sets it in the value of b printInt b printIntNoLine a printLine a + 10 b + 11 set b a //sets what is at b's position to a c = get b //gets the number from above printInt c
Remember please be careful to not use any positions below 256 on the array as these can be used for ascii variable names, touch these at great peril
input and output is done like so
readIO SOME PROMPT FOR THE USER
the magical interpreter thus prints out SOME PROMPT FOR THE USER and stores the value in the variable i NOTE that for the onlne version it is imperative you avoid the use of this command. All prompts are disabled in the online version, so
printLine SOME PROMPT
Printing is done with three commands
printInt a //prints out the value of a with a trailing newline printLine a //prints out "a" with a trailing newline print a //prints out "a" with no trailing new line printChar x prints out the value of x as a character
the randomness is provided by a prng currently the prng is provided courtesy of Oracle and uses the system time as a seed
gets a random number [0,x) 0 inclusive to max exclusive and stores it in the variable r max may also be a literal like 12
See the usage of functions in functions.txt to better comperehend it, but here is the basics. Function should be declared as such
GOTO endOfAllFunctions funcfunctionname //code the function here return funcsomeFunc return lblendOfAllFunctions
now at any point in the code you may calll the function named functionname as such
The stack is automagically handled works similar to most languages. However one must be cuatious of properly enclosing the function safely with returns. Also ensure to jump around the functions with the Goto's otherwise all the functions will run.
Ideally functions should have only one return statement.
As of this printing functions can only be void and have no return type.
the first line is used by the interpreter to allocate the size of the array (heap) this number should be at least 256 if you omit this line the interpretter will just allocate 8192 slots in its memory for its future use you are allowed to use single character identifiiers
1 = 5 printInt 1 //prints five print 1 //1
But never do this unless it is for obfuscation purposes the compiler will struggle with resolving what you are talking about also as far as commenting goes the compiler will ignore non code thus
this is a comment
is valid syntax but don't abuse this as
1 = foo
could break your code instead // is recommended to start all comments lastly as input and randomness are stored into the variables i and r when requested it is recommended that you reserve these variables for that use
New Features in v1.5
As of 8/24/2016 SIL has new, improved input, here are the new features
//This shows the new features of SIL def p print load loadLine : lbl //With the new "illiterate preprocessor" (tm) the above statement (which must appear on the second line) defines any number of macros in the form of def string replace string2 replace p Hello, pLine World! pSee pLine! a = 5 pInt a //loading the next line of stdin as a string is easy. load testing! //the loadLine command will take one line (either one single command line argument on TIO (Try it Online!), or STDIN on java and loads it in starting at the 256th heap spot and working out) //look the macro now will allow : to work as a label a = 256 :a x = get a printInt x if x continue GOTO end :continue pChar x a + 1 if x a :end
Support for Graphical Output has been added in SILOS 2.0. SILOS 2.0 comes primarily with support for graphics, but also features I highly optimized interpreter (thanks to kckennylau!), and a
command which as the name would suggest, waits x milliseconds. Now, let's take a look at how graphical output works.
canvas width height wordForTheHeader
You first must use the above command to declare a canvas THan you must decide to create objects Each object will be in the current pen color. THe pen color gets set with
pen r g b
where r g and b are variables represent red green and blue values of a color (of any name) or integer literals.
Than you can create an object
newObj type height width
a square is type 0 an elipse is type one. Height and width and type are all variables/integer literals. This will add a new object to the drawable list. This list is zero indexed.
moveObj index x y
will move an object to a designated location.
is a mandatory command to be invoked once you have moved the objects around. refresh is the only way to actually trigger the painting.
Please see the game.txt and gui.txt files in the examples folder for an explanation.
At any point you can place a binding to certain characters
bind intRepresentingChar1 heapSpot1 intOfChar2 heapSpot2 etcetera
Where intRepresentingChar is an integer literal or variable representing a char ((ascii convention used) 97 would mean 'a') and heapspot is an integer value of a valid spot on the heap.
When the corresponding characters get typed (and a canvas has already been created) the corresponding heapspot will be set to one. This feature only works on the desktop version when a canvas is in focus
Most whitespace dependency is gone. The only necessary whitespace separates arguments and the new lines between commands. All lines are now indentable! Bitwise operators now have support. Please view the bitwise.txt document for a full rundown.
Stacks and Queues
You have access to 32 stacks and 32 queues
stack x y
will add y to the xth stack
queue x y
will queue y onto the xth queue
will pop a value off of the xth stack and store in variable m
will dequeue a value off of the front of the xth queue and store in variable m
Please note that all interactivity including graphics support is unavailable on Try it Online! all input must be through command line arguments.