Srelipmoc ni esruoc tsrif a

Aug 19, 2013 21:10

If I ever design a first course in compilers, I'll do it backwards: we'll start with code generation, move on to static analysis, then parse a token stream and finally lex source text. As we go along, students will be required to implement a small compiler for a simple language, using the techniques they've just learned. The (excellent) Stanford/ ( Read more... )

teaching, computers, jobs, beware the geek, compilers

Leave a comment

Comments 5

ext_1499893 August 19 2013, 20:54:03 UTC
Hum, you are missing that we now have a good pseudo-LR(1) parser in Menhir in Ocaml. Second, I think that using something other than Yacc/Lex (flex/bison) in C will make learning this stuff much, much easier to learn about rather than having to struggle with C's syntax. Although, I am biased in the Ocaml direction; I think doing this in an ML derived language would make the concepts easier to grasp. At that point, it is all about tree transforms (aka the boring side of static analysis).

Reply

pozorvlak August 20 2013, 15:16:02 UTC
Yeah, I think the ML family really shine for that kind of stuff.

Reply


thesz August 21 2013, 05:54:08 UTC
What if we implement simple compiler on a first day? Something that have literals and calls, enough to say "Hello, world!".

This way we will cover everything at once and then extend.

Reply


lindseykuper December 20 2013, 07:36:55 UTC
The back-to-front style of writing a compiler is exactly what we did in the compilers course that I took from Kent Dybvig in 2009, during my first year of grad school. I loved it! Every compiler pass had a specified input and output language, so that at every step of the way, you had a working compiler -- first for a language that was a very thin layer on top of x86_64, and gradually for a more and more high-level language. We ended up compiling a substantial subset of Scheme to x86_64. The course also used the nanopass framework, which made it easy to write a compiler with lots of small easy-to-understand passes instead of a few monolithic ones.

Reply

lindseykuper December 27 2013, 23:31:48 UTC
I'm AIing (the Indiana equivalent of TAing) the compilers course at Indiana this upcoming semester and can thus state definitively that this is precisely how it still done. Having taken the course last spring I echo Lindsey's sentiment.

Reply


Leave a comment

Up