Re:Show HN: A small virtual machine written in C
by spatulon on Monday August 04, 2014 @06:05AM
(#8130995)
This is a technique I first came across in the code for lcc, as described in David R. Hanson's book "A Retargetable C Compiler: Design and Implementation".
The code in that book feels pretty dated in a lot of places, but this was a neat trick. Every piece of information related to a token is defined in one place:
https://sites.google.com/site/lccretargetablecompiler/
The code in that book feels pretty dated in a lot of places, but this was a neat trick. Every piece of information related to a token is defined in one place:
https://github.com/drh/lcc/blob/master/src/token.h
Then here's how it's used:
https://github.com/drh/lcc/blob/master/src/expr.c#L8
https://github.com/drh/lcc/blob/master/src/output.c#L107