| ▲ | Octoth0rpe a day ago |
| I've been playing with a very basic compiler for a language that looks a bit like go -> llvm ir, but I'm finding myself constantly revising my AST implementation as I progressively add more things that it needs to represent. Is anyone aware of any kind of vaguely standardized AST implementation used by more than one project? I've been searching this morning for one and am coming up empty. My thinking is that if I can find some reasonably widely used implementation, then hopefully that implementation has thought out lots of the corner cases that I haven't gotten to yet. |
|
| ▲ | znkr a day ago | parent | next [-] |
| LISP ;-) |
| |
| ▲ | xnacly a day ago | parent | next [-] | | This, lisp is perfect for representing arbitrary data, nesting is just another sexpr, easy to produce, easy to parse and easy to debug / reason about | | |
| ▲ | pjmlp a day ago | parent [-] | | When I did my degree, the years prior to mine had some flexibility choosing the implementation language for compilers class. Lisp and Prolog were forbidden due to how easy the whole exercise would be. |
| |
| ▲ | Octoth0rpe a day ago | parent | prev [-] | | I can appreciate this answer, but I don't think it's really what I'm asking. I think I'm more looking for some kind of standardized struct definition that translates easily to llvm IR and is flexible enough for a wide variety of languages to target. Something like this: https://gist.github.com/thomaswp/8c8ef19bd5203ce8b6cd4d6df5e... (Which doesn't meet my criteria because AFAICT isn't used by anything, but is reasonably close to what I want)
or this: https://docs.rs/sap-ast/latest/src/ast/lib.rs.html#1-83 (which seems specific to SAP, I would like something more general) |
|
|
| ▲ | emptysea a day ago | parent | prev [-] |
| Ruff’s ast is used by Ruff, Ty, and Pyrefly |
| |