Comment by supriyo-biswas
2 months ago
Heh, now I wonder how much JavaScript it actually interprets and given that it’s < 1000 lines, whether it could be used towards an introductory course in compilers.
2 months ago
Heh, now I wonder how much JavaScript it actually interprets and given that it’s < 1000 lines, whether it could be used towards an introductory course in compilers.
Obviously not. An introductory course would introduce concepts like lexers, parsers, AST, etc, instead of working on strings.
Here are lines 431 through 433:
There’s a famous presentation by David Beazley where he implements a WASM interpreter in Python in under an hour. Highly recommended.
Bytecode interpreters are quite simple compared to the actual lexer / parser.