Streamlang
Streamlang is an esoterical language that works with streams/queues.
Streamlang only has one operator, the arrow. Each item of a stream is equivalent in size to a signed long long.
Syntax
The Arrow
in -> out
This code is an example cat program, as it will take an item from the input stream, and put it on the output stream.
The arrow expects the same amount of streams on each side. Streams do not have to be unique.
a -> b a b -> c d a a b -> c d c
Since the delimiter of the operation is the amount of Streams, it is possible to stack operations
a -> b c -> d e -> f
which is equivalent to
a -> b c -> d e -> f
Literals
Instead of a stream, you can also use a constant literal as a source.
1 -> a 'h' -> b 0x43 -> c "Hello, world!" -> d 0b10101101 -> e
When a literal is used as a destination, it acts as a void and consumes its input.
a -> 0
There are 3 types of literals:
Integers
Basically the same as every other language ever
1 -> a +0 -12 -> b a 0x3b 0b10011 -> c d
Streamlang does not support floats.
Characters
'a' -> a
Strings
"More than one character!" -> a
Strings are a bit special, because unlike all previous items, they push the entirety of themselves into the stream, which means they push more than once
Comments
# Everything now gets ignored #
Comments are started and ended with a octothorpe. They are completely ignored and only server documentary purposes.
Execution
Special Streams
In order to make Streamlang Turing complete, certain streams have special functionality.
| Keyword | Functionality |
|---|---|
| - | IO |
| in | READONLY Pulls data from stdin into the program |
| out | WRITEONLY Pushes data from the program into stdout |
| - | Comparisons |
| eq | Compares every item in it. If they are equal, it is pullable from. Flushes eitherway. |
| neq | Compares every item in it. If they are unequal, it is pullable from. Flushes eitherway. |
| lt | Compares every item in it. If they are less than the previous, it is pullable from. Flushes eitherway. |
| gt | Compares every item in it. If they are greater than the previous, it is pullable from. Flushes eitherway. |
| - | Arithmetic |
| sum | When pulled from, outputs the sum of all items inside. |
| prd | When pulled from, outputs the product of all items inside. |
| neg | Negates an item. |
| - | Binary operations |
| and | When pulled from, outputs the binary and of all items inside. |
| or | When pulled from, outputs the binary or of all items inside. |
| not | Inverts an item. |
| - | Misc |
| dup | Duplicates an element. |
| rng | READONLY Returns a random value. |
| hlt | WRITEONLY Halts the program on push. |
Examples
in -> out
in '1' -> eq eq eq -> a a '1' -> a out '0' 1 -> out hlt
Interpreter
A working interpreter can be found here. This interpreter is not public yet (its still a buggy mess im sorry)