factory-lang/readme

45 lines
1.7 KiB
Plaintext

Factory is an interpreted programming language based on a two-dimensional grid.
# Building
ghc --make Main.hs -o factory
If you're on Arch Linux, you may get an error. In that case, try:
ghc -dynamic --make Main.hs -o factory
# Running
./factory [ file ]
# Symbol overview
- E: The entrypoint. This is where the first element is spawned.
- X: The exitpoint. If an element reaches a tile like this, the program will
exit with the value of the element as the exit value.
- >: Track going east.
- v: Track going south.
- <: Track going west.
- ^: Track going north.
- +: Increments the incoming element and spits it out (east).
- -: Decrements the incoming element and spits it out (east).
- D: Duplicates the incoming element and spits one copy out to the first track
found starting east and going clockwise, and spits the other copy out to
the second.
- ?: If the incoming element's value is 0, spit the incoming element out to the
first track found starting east and going clockwise. Otherwise, it is sput
out to the second track found.
An example program looks like this:
E>?>+
^ v v
^<- v
^<<<
This example program can be found at examples/looping.fac
The element will spawn with a value of zero at E and be sput out to the first
track it finds, starting from east and going clockwise. It will hit the
conditional check, and continue going eastwards because the value of the element
is 0. It will hit the incrementing modifier, which will spit it out below. The
element will then follow the track until it comes back to the beginning.
However, this time it will go downwards at the conditional check and be
decremented for the next iteration. This turns into an infinite loop of
incrementing and decrementing the value of the element.