A small interpreted language where the keywords are biology. An organism holds organs, the nucleus is where it starts, and a fossil can never be changed.
organism FibonacciSystem { organ computeGen(dna generations) -> colony { cell colony sequence = [0, 1] replicate (sequence.length < generations) { dna nextGen = sequence[-1] + sequence[-2] sequence.inject(nextGen) } return sequence } nucleus() { fossil dna target = 10 fossil enzyme isReady = active mutate (isReady) { cell colony result = computeGen(target) secrete("Generation Complete:") secrete(result) } adapt { secrete("System is dormant.") } } }
adapt mutate (...) chains.(init; cond; step).bio file.mutate/adapt, replicate, traverse, sever, skipfossil refuses reassign and mutation-1 is the last elementgraft, with cycle detectionmembrane) with methods and field mutationspore is a lambdaabsorb; 17 array methodsnucleus per organism; grafted files may not declare their own--max-loop NThe project states its scope in the source, at the point each limit applies, rather than in a marketing line.
The lexer is also written in BioLang. It reads a .bio
source and emits the same token stream the C# lexer does — checked by
byte-equality, not by hand-written expectations.
PASS fibonacci.bio 100 tokens identical PASS lexer.bio 1943 tokens identical PASS fibonacci.bio 2994 bytes identical PASS lexlib.bio 53224 bytes identical PASS parser.bio 286200 bytes identical
The second line is the interesting one: the self-hosted lexer lexing its own
266-line source, through the same escape handling, comments and token types.
Three bugs came out of that comparison — including an escape that turned
into the letter r, which silently made every
identifier starting with r disappear.
The parser parses its own 1,100-line source and produces a tree identical to the C# one, all 286 KB of it. Byte-equality is the only test that catches a column drifting by one or a precedence level collapsing - and four of those happened while this was being written.
Stage two of four. The lexer and the parser are done. The evaluator and the bootstrap are not.
The published specification had three defects. Each is fixed in the interpreter and documented where it lives:
// 1. nucleus() was unreachable MainDecl was defined but never referenced from Program, so the grammar could not parse its own example program. // 2. no Expression production existed The grammar used Expression in seven places and defined it in none. Precedence is now: comparison > term > factor > unary. // 3. the grammar rejected the spec's own example VarDeclaration requires 'cell' or 'fossil', but the example writes `dna nextGen = ...` bare. A bare typed declaration is now legal and means the same as 'cell'.
Semantic decisions the spec left open — how dna prints, what a
condition coerces to, whether fossil blocks mutation as well as
reassignment — are written down in the interpreter header with the reasoning.
# needs the .NET SDK git clone https://github.com/athallajovian9-cyber/BioLang cd BioLang/src dotnet build # run a program ./bin/Debug/net10.0/biolang ../tests/fibonacci.bio # debug modes biolang --tokens file.bio # dump the token stream biolang --ast file.bio # parse, report the tree, do not run # the test suite cd .. && bash run_tests.sh # 117 checks