Creating a bytecode based programming language, part 3
Third and last post about creating a compiler and an interpreter.
We convert each expression identified during the token reduction to an instruction (each expression kind is mapped to an instruction class).
The set of instruction objects obtained after having converted all expressions is the bytecode.
Now, how to we use it?
An instruction class is quite simple, it defines two methods: an init and a process one.
The init method has a single parameter: a token (or a complex token as it extends the token class). This token, or it's sub-tokens, is used to initialized the attributes of the instruction object.
The process method takes two parameters, firstly an execution output and then the execution context.
The execution output is mostly a StringBuffer.
The execution context is more complex. It contains access to information like the