Gecko: Here is the tutorial requested for the LPse language.
- Design the language as a subset of ANSI C, and remove features from ANSI C grammar which is BNF.
- Use a parser generator to generate the abstract syntax tree, parse tree and convert to JSON.
- Use RxJava to convert JSON to a data stream.
- Write a map to iterate over the stream, add an observer and convert tokens to MIPS machine code.
- We do not describe optimization, loop unrolling etc.
Several tools exist to scaffold the code to hand-written code, the machine-generated code is a scaffolding to hand editing for academic work.
Javacc, is a LL(1) parser generator, and you can use this to generate the code and use the treejj structure for code generation or use JSON.
Hermes is another generator that can generate java and you can add the lexer(), parser() and eat() as native Java in the grammar.
Remember to hand-code the generated code, to high-quality compiler code, an art that takes decades to learn, help is available from AWS Code Guru, an AI-based code refactoring tool.