2 ms·
A minimal self-hosted js compiler in 1k lines
- lioeters 10y agoInteresting exercise/experiment. It parses JS into a syntax tree, then puts it back together to JS again. Not sure if that can be called a "compiler"? Admirable effort to write the compiler in the language that it implements. Perhaps it can be more compact if the tokens were organized as a dictionary (object with tokens as properties) instead of separate constants, so that they can be looked up simpler than a list of if statements.