| ▲ | sieve 3 hours ago | ||||||||||||||||
Anyone trying to do this... the first thing you do is avoid lex/yacc/bison/antlr. You do not need all this ceremony. A recursive descent parser that uses Pratt parsing will work for a vast majority of cases. The lexer/parser is never the bottleneck. In fact, you can write those two by hand over a single weekend for a largish language. With LLMs, it takes 15 minutes if you have an unambiguous spec. The biggest time sink, and the reason you will fail for sure, is the inability to restrict the scope of the project. You start with a limited feature set and produce the entire compiler/vm toolchain. Then you get greedy and fiddle with the type system, adding features that you have never used and probably never will. And now you have to change every single phase from start to end. I mostly give up at this stage. | |||||||||||||||||
| ▲ | wg0 2 hours ago | parent | next [-] | ||||||||||||||||
Jonathan Blow wrote his own game enginee and for that he wrote his own programming language. He went through straight recursive descendant parser and said same thing. I think compiler courses teach from yacc, bison etc that's where this whole thing came from but in practice people discovered that hand written recursive descendant parsers are all you need. | |||||||||||||||||
| |||||||||||||||||
| ▲ | pan69 an hour ago | parent | prev | next [-] | ||||||||||||||||
I learned to do this about 2 years ago (pre LLM). I have been developing software for ~30 years and somehow doing something like this was a major mental obstacle, mostly created by the perception of "the dragon book", as in this topic being full of mystical unobtainable incantations, so I never even dared venture into this space. Silly, I know. However, after diving into this and learning to write a recursive descent parser for a DSL I wanted to write, it felt like I'd acquired a superpower. Totally understand that there is many more layers to all of this, layer that can get very complex, but just learning that first bit... | |||||||||||||||||
| |||||||||||||||||
| ▲ | true_religion 3 hours ago | parent | prev [-] | ||||||||||||||||
I wrote a few of these due to an interest in compilers and hardware. The easiest syntax to copy if you’re looking for a high level language is Smalltalk. But most of the time, I wouldn’t even use that. Simple imperative languages that look like BASIC works pretty well in most domains. If you simplify the syntax a little, it’s very easy to understand the compiler and use it for say when you want users to input code into existing systems. | |||||||||||||||||
| |||||||||||||||||