Open hikari-no-yume opened 9 years ago
In order to do this, we need an easy-to-optimise AST. While the opcodes sort of work as an AST, they aren't really.
Currently we have two stages with a certain output (in brackets):
lex -> parse
(tokens) (opcodes)
What we need is three stages:
lex -> parse -> compile
(tokens) (ast) (opcodes)
Though that only works for the interpreter - JS output isn't just opcodes. So you need one further stage:
lex -> parse -> optimise -> compile
(tokens) (ast) (optimised ast) (js/opcodes)
Currently we just have the naïve interpreter. However, it should do some optimisation passes and eventually have the option to produce code (in C or JavaScript).