Zinc is my attempt at a low-level systems programming language prototype. I found this parser, called Owl mirrored here, that generates parsers for visibly pushdown languages. Visibly pushdown languages are those where recursion to other grammar productions must be guarded by tokens which can only be used for that purpose. While somewhat limiting, this ends up meaning that all grammar productions that can "contain" other productions are wrapped in certain tokens and so the language is visually easier to parse. And it runs in linear time.
mut i = 0
def n = 10
while 0 <= i < n {
def x = call rndi()
if i = 0 {
; verify that the fixed seed rng is working as expected
assert "rndi() = 13109595": x = 13109595
}
call puti(x)
call putc(10)
set i = i + 1
}
return i
0 <= i < 100
assert
syntax - that's included in all compliation modes. Make sure things are what you expect them to be.lib/prelude.h
.if
and while
statements don't need parentheses around their conditional.assert
message..zn
is executed when the file is included.While I dreamed of integrating it with some 2D graphics or tile engine and playing around with old-school game dev, I ran into a few limitations with its design. Like how cool would it be to write a clone of Raptor: Call of the Shadows in a language I wrote?
I intended to write it as a single-pass compiler directly from the syntax tree and targeting C via TCC to enable it to run quickly and on any platform. Unfortunately I also designed a language with top-level execution and nested functions - neither of which I could come up with a good compilation model for if I wanted to preserve the single-pass, no AST, no IR design of the compiler. It's certainly possible there is a model, but my musings couldn't figure it out.
The reality is too that I've been a programmer in GC languages my entire career (if you ignore the 5 years I did C++ and Verilog) and that's where my mind resides so writing a low-level limited language was, well, limiting.
https://github.com/mattiasgustavsson/libs Mattias Gustavsson's single-file libraries
https://github.com/nothings/stb/ Nothings' (Sean T Barrett's) single-file libraries
https://github.com/gingerBill/gb Ginger Bill's single-file libraries
https://github.com/antirez/sds Antirez's C string library
https://github.com/floooh/sokol Sokol single header libraries
https://github.com/sheredom/subprocess.h single header process launching solution for C
https://github.com/jondgoodwin/cone/blob/master/PLAN.md a language plan table
tail
to specify tail calls?
https://github.com/nothings/stb/blob/master/docs/stb_howto.txt
https://nemequ.github.io/hedley/api-reference.html#HEDLEY_NO_RETURN
What you are I once was. What I am you will become.