I decided to write a compiler as a learning experiment.I first started by following some random tutorials here and there and built something that I called by naive implementation. (Since there's a lot of guessing that went into it).I then decided to buy a book that treated the subject (https://www.amazon.ca/dp/0470177071). The book provides a very step by step way of building such software.In order to learn from it, and to not do a direct rewrite of what is written in it (because it pretty much gives you an implementation), I decided to read the intro parts, and then try to build something from there, and if I was stuck / couldn't go forward I would read the suggested code and then implement it. Throughout the code, I comment on why some parts interact with other parts, I reference my naive implementation and compare the two solutions.It happens that the compiler showed in the book and the compiler I wanted to build treated the same language. (I didn't know this at the moment of purchase). Which makes it a little harder to make it very different.Beside the general framework (packages layout, interfaces), my code is pretty much different that the one provided in the book, but many ressemblances can be found, and obviously some parts are almost identical.My questionI was thinking of open sourcing the result of the code I have written, and explaining that it is sort of my journey through the book. I wanted to licence it as MIT, but since it is derived work from the book, is it OK to do so? 
Open sourcing code derived from a book
licensing;mit
For clarity, let me focus only on the parts that you did copy or derive from the book (as in copy-then-modify). Parts of code that are your own original creation are yours and you can therefore license these under any terms you please including the MIT. When you copy code from a book, what you copy is subject to a license whether explicit or not. And you cannot reuse significant elements from a book without the proper permission from the author or publisher (e.g. whoever owns the rights). In this case, Ronald Mak has a web site where the source code of this books is also available for download.Most of the files have a copyright from Ronald Mak and one seems to have been written while he was working at NASA Ames Research Center. There are no specific rights granted in the code, documentation or on the web site beside this statement found in the code: For instructional purposes only.  No warranties.Short of other rights granted by the author, you cannot do much with this code (or its printed version) and certainly you are not allowed to include significant chunks of it and relicense this using an MIT license: you do not have a license in the first place that allows you to do this. If I were you I would contact Mr. Mak to ask for a permission (if he actually own this and not his publisher.)