I am better to embed all testing assembly instruction in the antlr listener
I am better to embed all testing assembly instruction in the antlr listener rather than finding a way to embed them into the antlr grammar, because:
- Using parser of parser skill set to write a parser to parse antlr grammar and extract the testing asm instruction is too risky. One day the antlr grammar will change, if it happens, you have to adjust your parser.
- Every antlr grammar will become one function in the listener, it is exact 1:1 mapping, so embed the testing instruction in each listener’s method is good enough for me
- Custom Java annotation is the way i add custom thing in front of each function in antlr listener
!!! “testing instruction” is the instruction i pass to my assembler to test the output bytecode, i need the bytecode same as nasm to prove my assembler is correct or not.
!!! This is the tutorial i use to create custom java annotation https://www.mkyong.com/java/java-custom-annotations-example/
read count : 2