From its earliest year UNIX/Linux had utilities including lex and yacc that automate much of these fuctions. I tended to use awk to create powerful new command scripts.
lex and yacc only automate one tiny part of the front-end of a compiler.
How to Write Your Own Compiler (2009)
11–20 of 43 posts
Re: How to Write Your Own Compiler (2009)
#12One of the best resources I've seen on this is Capon and Jinks 'Compiler Engineering Using Pascal' (1988; ISBN 0-333-47155-5) if you can get hold of it http://www.cs.man.ac.uk/~pjj/book.html
Re: How to Write Your Own Compiler (2009)
#13May I suggest considering Forth as a substrate? Or will that get me voted straight into neckbeard land? I've had a lot of fun hacking Forths, writing my own languages didn't really click until I finally had a serious look. Forth skips on most of the complexity of getting from bytes to semantics; even Lisp is complex in comparison; but is still powerful enough to do interesting things; and the best foundation for DSL'…
Snabel looks like an interesting experiment in that regard..
Re: How to Write Your Own Compiler (2009)
#14May I suggest considering Forth as a substrate? Or will that get me voted straight into neckbeard land? I've had a lot of fun hacking Forths, writing my own languages didn't really click until I finally had a serious look. Forth skips on most of the complexity of getting from bytes to semantics; even Lisp is complex in comparison; but is still powerful enough to do interesting things; and the best foundation for DSL'…
Forth is one of those things that always fascinates me but ultimately always ends up feeling too hard to read. Snabel looks like an interesting experiment in that regard..
I'm not very much into dogmatics and orthodoxy, Forth wasn't the final answer to anything. Nothing ever is. Implementing the same thing over and over again doesn't make sense to me; I have plenty of experience of my own that thinks differently, things I always wanted to work differently. So that's what I'm doing, my best to improve the status quo.
Re: How to Write Your Own Compiler (2009)
#15If you're wondering why that page looks the way it does, well: > " rel="nofollow">http://www.w3.org/TR/REC-html40">
Re: How to Write Your Own Compiler (2009)
#16May I suggest considering Forth as a substrate? Or will that get me voted straight into neckbeard land? I've had a lot of fun hacking Forths, writing my own languages didn't really click until I finally had a serious look. Forth skips on most of the complexity of getting from bytes to semantics; even Lisp is complex in comparison; but is still powerful enough to do interesting things; and the best foundation for DSL'…
Forth is one of those things that always fascinates me but ultimately always ends up feeling too hard to read. Snabel looks like an interesting experiment in that regard..
I've not done anything original in Forth, only hacking some existing code on FreeBSD, but I found Forth to be remarkable quiet to pick up once I took time to familiarise myself with it's syntax.
Unfortunately that was a while ago now with so little time spent in the language at the time and none spent in it since that I've now forgotten most of what I had learned.
Re: How to Write Your Own Compiler (2009)
#17One of the best resources I've seen on this is Capon and Jinks 'Compiler Engineering Using Pascal' (1988; ISBN 0-333-47155-5) if you can get hold of it http://www.cs.man.ac.uk/~pjj/book.html
Also Brinch Hansen on Pascal Compilers : https://www.amazon.com/Brinch-Hansen-Pascal-Compilers/dp/013...
Re: How to Write Your Own Compiler (2009)
#18Re: How to Write Your Own Compiler (2009)
#19I appreciate the effort to have a web page talking about writing your own compiler. Right now, I'm looking for an easy way to add define-use chains to a compiler. I know it involves breaking code into blocks and tracing through the code looking for use of the same variables. This tutorial is good because it adds a symbol table on each block level, which helps in differentiating names that are re-used in a block and d…
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.
Re: How to Write Your Own Compiler (2009)
#20I appreciate the effort to have a web page talking about writing your own compiler. Right now, I'm looking for an easy way to add define-use chains to a compiler. I know it involves breaking code into blocks and tracing through the code looking for use of the same variables. This tutorial is good because it adds a symbol table on each block level, which helps in differentiating names that are re-used in a block and d…
A more convenient interface to go program analysis is https://godoc.org/golang.org/x/tools/go/loader. See https://blog.cloudflare.com/building-the-simplest-go-static-... for a basic tutorial on using the module.