Here is the most valuable exercise I can think of for language development: write a function that produces a formatted error string that renders the location of the cause of the error and the reason for the error. Once you have this, it will be much easier to write your compiler from the ground up because every step of the way you can validate that the compiler is only handling inputs that you it expect it to and rejecting everything else.
The error reporting function is not easy to write correctly, but a decent one can be written in fewer than 100 lines of lua (and I am certain it can be done in all but the least expressive languages in under 200).
thrance•1h ago
I've been there before, got something working and then kept adding features until I went "Hey, this could be a library!". Never finished the library. Nor the language for that matter.
9d•2h ago
> the Gleam language, which is written in Rust and has first-party LSP support
Very much a work in progress, but I hope to soon be able to provide the same minimal interpreter in Java/C/Common Lisp, each using the unique strengths of the host language.
danielvaughn•20m ago
The author mentions he decided against using Treesitter, but I’d highly recommend using it. It’s phenomenal, especially when you’re in the prototyping phase.
norir•3h ago
The error reporting function is not easy to write correctly, but a decent one can be written in fewer than 100 lines of lua (and I am certain it can be done in all but the least expressive languages in under 200).
thrance•1h ago