Remix.run Logo
supriyo-biswas 3 days 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.

kccqzy 3 days ago | parent | next [-]

Obviously not. An introductory course would introduce concepts like lexers, parsers, AST, etc, instead of working on strings.

Here are lines 431 through 433:

    if expr.startswith('new '):
        obj = expr[4:]
            if obj.startswith('Date('):
3 days ago | parent [-]
[deleted]
Too 3 days ago | parent | prev [-]

There’s a famous presentation by David Beazley where he implements a WASM interpreter in Python in under an hour. Highly recommended.

bangaladore 3 days ago | parent [-]

Bytecode interpreters are quite simple compared to the actual lexer / parser.