Compiler for Entropy, a programming language where all data is in a constant state of decay. Entropy forces the programmer to give up on precise control, and get an idea across in the short time before their program falls apart.
The compiler takes these options:
/h or /? -- print help screen
/m -- set mutation rate (speed that data decays), must be between 0.001 and 100
/d -- Debug mode: parse tree and print to screen
/c -- Transpile to C#
Syntax is quite primitive, but I hope it will be further extended.
Program MyNamespace MyProgram [
print "Hello, World";
]
All datatypes in Entropy are built on reals (floats).
A floating point number, which changes slightly every time it's read from. There is no way to compare whether two values are equal, since the values are so unstable—only the greater than and less than comparisons are available.
Currently available operations:
+
and-
. Unary is not supported yet, so uselet a = 0 - a
instead.- (unofficial)
*
and/
. Devision by zero creates Infinity.
Built on a real, a char rounds off the current value of the real it is built on, and returns the corresponding character.
Char may be created from float by assigning float to char variable. You can't convert char to float back.
An array of chars.
Currently you can just print it, no complex operations are available.
To create a variable, use declare <name> <type>;
To assign (or reassign) variables, use let <variable> = <expression>;
if <condition>
[
<some action>
]
"Else" is not still supported.
Аналогично if
:
while <condition>
[
<some action>
]
print <expression>;
writes object.toString()
to stdout.
Adds a newline. Using this command instead of adding print "\n"
creates new line that doesn't mutate so it is easier to navigate the output.
round(<expression>)
returns string with rounded number. Usefull for printing without these extra digits. However, it can't be used for calculations (ha, that would be too easy).
This code works on .Net v4.8, so it should natively work on all modern windows systems. If you are interested in porting to Linux or updating to Net v7, see net7 branch. It is much clumsier, trickier and slower, so stay here if you are not.
See Entropy in action with Drunk Eliza: http://danieltemkin.com/DrunkEliza
Entropy lives here: http://danieltemkin.com/Entropy
More details: http://esolangs.org/wiki/Entropy
JS version: https://github.com/ndrwhr/entropy