projects
Selenium Compiler
# python# compiler# esoteric# c
Selenium is a small esoteric language with a lunar / poetic surface and a strict, C-like core.
Features
- strongly typed
- semicolon-terminated statements
- functions
- variables and constants
eclipse/shadowfor if / elsetidefor whileorbitfor forswitch/case/defaultfor switch statementsbreakandcontinuefor loops and switch- prefix
++and--operators - ternary conditional
?: - bitwise operators
<<>>&|^ whisperfor printingread_int,read_float,read_bool,read_charfor input- explicit
cast(type, expr)conversions
Syntax sketch
wax int moon = 3;
seal int tide = 8;
ritual add(int a, int b) -> int {
return a + b;
};
eclipse (moon < tide) {
whisper moon;
} shadow {
whisper tide;
};
tide (moon < 10) {
whisper moon;
moon = moon + 1;
};
orbit (wax int i = 0; i < 5; i = i + 1) {
whisper i;
};
switch (moon) {
case 1: {
whisper "one";
break;
};
case 3: {
whisper "three";
break;
};
default: {
whisper "other";
break;
};
};
wax int max = moon > tide ? moon : tide;
whisper max;
wax int shifted = moon << 2;
whisper shifted;
wax int input = read_int();
whisper input;
whisper add(moon, tide);
Build a C file
python -m selenium.main examples/hello.sel -o out.c
gcc out.c -o out
./out
Or install it as a script:
pip install -e .
seleniumc examples/hello.sel -o out.c
Notes
- The compiler is intentionally strict.
- No implicit type coercion.
- Top-level
wax,seal, and statements are emitted intomain. - Function definitions become normal C functions.
← all docs