Re:How to Write Your Own Compiler (2009)
by tom_mellior on Friday August 25, 2017 @09:31AM
(#15098247)
> a symbol table on each block level, which helps in differentiating names
Yes, that's something that every compiler (for languages with scopes that allow hiding) needs. Typically you also never compare variables by name but by pointer to a symbol structure or some numeric ID.
> Does anyone know of code that makes clear what is involved in def-use for a variable without saying "this is an exercise for the reader" ?
It's not code, but chapter 2 of Nielson/Nielson/Hankin's Principles of Program Analysis discusses how to do this. See accompanying slides on the book's website: http://www.imm.dtu.dk/~hrni/PPA/ppasup2004.html
In a sense, this must be an exercise for the reader, since if you are working on your own compiler, nobody's code will be compatible with yours.
Yes, that's something that every compiler (for languages with scopes that allow hiding) needs. Typically you also never compare variables by name but by pointer to a symbol structure or some numeric ID.
> Does anyone know of code that makes clear what is involved in def-use for a variable without saying "this is an exercise for the reader" ?
It's not code, but chapter 2 of Nielson/Nielson/Hankin's Principles of Program Analysis discusses how to do this. See accompanying slides on the book's website: http://www.imm.dtu.dk/~hrni/PPA/ppasup2004.html
In a sense, this must be an exercise for the reader, since if you are working on your own compiler, nobody's code will be compatible with yours.