I haven't gone to the bare metal level since (as well as using parser generators), but it's a great piece of work that gives you a slight understanding of what YACC+family do under the covers (even though they are different types of parsers). I continually recommend it as a starting point for anyone who wants to learn how to write parsers.
Let’s Build a Compiler (1995)
51–58 of 58 posts
Re: Let’s Build a Compiler (1995)
#52I went through this on my own back in a HS programming class! Glad to see it here. While the teacher was walking students through how to do loops, I got permission to hack away in the back of the room on this. I ended up building a BASIC-like interpreter with a decent graphics API. By the end of the class, my project was a multi-level breakout game I'd written in the interpreter I'd written. TLDR; two years later, I…
You're lucky, I was doing the same things in middle school. Took me until college for that last part... :) That same game project I started then still has been going on since then, multiple compilers and VMs written to do parts of the game. It's ended up an incredibly complex monstrosity with procedurally generated worlds and randomly altered scripts (some actions just won't be available on some play-throughs).
Re: Let’s Build a Compiler (1995)
#53I followed this in the early 90s and had a lovely time. It helped that Turbo Pascal was my language of choice though and might not be quite so helpful now although Pascal is a pretty good pseudocode.. It's not the same but Vidar Hokstad has been writing a series for several years now in Ruby: http://www.hokstad.com/compiler/ .. and other resources aplenty: http://stackoverflow.com/a/1672/3951
The really great part with the Crenshaw tutorial, is that it's so cohesive and concise. It's reminiscent of Wirths compiler construction texts, but much simpler to follow.
Re: Let’s Build a Compiler (1995)
#54I followed this in the early 90s and had a lovely time. It helped that Turbo Pascal was my language of choice though and might not be quite so helpful now although Pascal is a pretty good pseudocode.. It's not the same but Vidar Hokstad has been writing a series for several years now in Ruby: http://www.hokstad.com/compiler/ .. and other resources aplenty: http://stackoverflow.com/a/1672/3951
> Pascal is a pretty good pseudocode.. Pascal is pretty much directly derived from early dialects of Algol, which is where most modern programming language syntaxes derive; it's the original block-structured syntax, as opposed to line-structured assembly and early FORTRAN and the fully-bracketed Lisp syntax (which is also block-structured if you indent it sanely).
This is quite interesting: Pascal and its Successors - Niklaus Wirth http://www.swissdelphicenter.ch/en/niklauswirth.php
Re: Let’s Build a Compiler (1995)
#55Reading the text files, using vim, which were written in the 80s and talk about Borland and other old stuff, makes me... a bit sentimental.
Talking about sentimental, This made me giggle, "there will probably never come a time when a good assembler-language programmer can't out-program a compiler." Reading that reminded me why I'll never make predictions on computing, especially on what can't be done.
Not least because no language includes sufficient semantic information for the compiler to be able to safely optimize all the parts that the programmer can.
It's still mostly true - just not worth the effort for anything but smaller fragments.
Re: Let’s Build a Compiler (1995)
#56Earlier quoted context omitted.
Talking about sentimental, This made me giggle, "there will probably never come a time when a good assembler-language programmer can't out-program a compiler." Reading that reminded me why I'll never make predictions on computing, especially on what can't be done.
A good assembler-language programmer these days starts with the output of a compiler. And then proceeds to beat the pants off said compiler by optimizing specific portions. Not least because no language includes sufficient semantic information for the compiler to be able to safely optimize all the parts that the programmer can . It's still mostly true - just not worth the effort for anything but smaller fragments.
I realize that many people believe that computers will some day be able to truly think on a human level. I just don't happen to be one of those people.
Re: Let’s Build a Compiler (1995)
#57Re: Let’s Build a Compiler (1995)
#58Earlier quoted context omitted.
You're lucky, I was doing the same things in middle school. Took me until college for that last part... :) That same game project I started then still has been going on since then, multiple compilers and VMs written to do parts of the game. It's ended up an incredibly complex monstrosity with procedurally generated worlds and randomly altered scripts (some actions just won't be available on some play-throughs).
Is the game (or its code) online somewhere? :P