I wrote a short tutorial on using my implementation of ASDL. You can find link to it in the document.
I don’t have a blog or things like that so I just used a Github Gist.
For some reason I got locked out of my Github account and if it was not for a miracle I would have been locked out forever. I barely use Github anyways. I don’t understand why Tarvolds uses this shit corporate hellhole of a website as the primary platform for his projects, which sadly includes Git.
I made a model in ChatGPT to walk me through libgit2 so I can make my own remote host. I don’t like any of the other bloated Git on Web platforms that are out there. I know about Git Tea, but that damn thing is bloated. I want some thing like this guy has: http://c9x.me/
This is what I mean when I say ‘OWN YOUR DATA’. Don’t trust Github, or any of these corporations, with shit.
I get this is really hypocritical to use Gist, then turn around and call Github a soulless corporation. But sadly, I use it BECAUSE it’s a soulless corporation, not in spite of it.
I don’t have money to buy a server. Yes, I am that poor. That is why I have to trust this PaaS and SaaS assholes.
Anyways fuck Github.
Your code looked alright. Working in C is a risky chore. You’re early in your journey and I think it’s good to get a taste of many of the traditional techniques before turning towards newer fancier algorithms.
“Haskell and OCaml”, hm? The two concepts you need to internalize are katamorphisms and paramorphisms. You may have heard of “recursion schemes”; these two schemes are the ones available on any tree. Fundamentally, most of a compiler is tree-to-tree transformations (nanopasses), and they are expressible as one of two forms:
If you look again at my AST builder builder, you’ll see
.run()
and.walk()
methods, implementing the recursion for any katamorphism or paramorphism respectively. In Haskell, these are calledTraversable
types. This is a pun in Monte, where.run()
is also the default method; the syntax makes it easy to perform a katamorphism by passing a tree-traversing object directly to the AST.Your types are alright, but you’ll want to pass a generic parameter through them, turning them into a valid
Functor
in Haskell or a generic module in OCaml. This is a basic defense against the “AST Decoration Problem”, AKA the “AST Typing Problem”. As you add features to your compiler, you’ll realize why these are necessary.(Sorry if this is a double post) I think what you call ‘decoration’ I call 'augmentation;. After many iterations ,I came up with this AST: https://pastebin.com/NA1DhZF2
I like it, but I am still skeptical as of comitting to it. I really want to use Functors… But i’m nto sure how. These are new concepts to me!