3 ms·
Believe it or not, once the lexing and parsing was out of the way, the two-page description of the two-pass process in the book was really all it took: make a l
by cellularmitosis 6y ago
Believe it or not, once the lexing and parsing was out of the way, the two-page description of the two-pass process in the book was really all it took: make a list of all of the goto labels, then calculate the address of each.
I’d be happy to turn this into a couple of tutorial blog posts. If you removed all of the lexing and parsing code, and chopped the ISA down to just 1 or 2 instructions, it would really highlight how simple the core problem really is!
One technique I’ve used before (and a technique echoed by David Beazley in his compilers course), was to skip the lexer and parser and jump straight to working on something which is handed an already-parsed AST. Let’s you skip right to the interesting part, especially if you are already bored with writing parsers by hand.
- bogomipz 6y ago>"I’d be happy to turn this into a couple of tutorial blog posts. Yes that would be great. Please do! I think there would genuine interest in more posts. Please post it here if so. Cheers.