Taking the plunge today and starting to actually write parsing code for C.

It is currently 😱.

Mostly because connecting the theory of top-down parsing with actually writing code that does it is hard.
Even when the C standard comes with a grammar!


It took a large part of the afternoon, re-reading the parsing sections of both my compiler books, reading parsers of the D compiler, Go compiler, tcc and `clang -ast-dump ...` BUT I got my head around how to implement the theory and made a 200 line or so 'start'.

Not committed it yet, so not much parser to see, but the reset of the compiler is here:

@s Nice! I've never seen any DLang before, but the contract stuff looks cool! Reminds me of a mix of C & Java (with the function attributes stuff declaring exceptions that might be thrown for example)

@s is the name a reference to Ceres station, beltalowda?

@danhatesnumbers Sa Sa Mi lowda 😄

I might like The Expanse as much as I like Star Trek......

@danhatesnumbers Dlang contracts make contracts so easy. I'd like to add more, along with invariants ( called on exit of any method, must always be true ).

You can tag functions as '@nothrow', also '@safe' and '@pure'. Also user defined attributes!

Sign in to participate in the conversation
Mastodon is one server in the network