In homage to Crenshaw, I'm going to write a little series on how to write a compiler, updated to use C# 2.0 / .NET. Maybe somebody else out there will find it enlightening.
The project will cover the following areas:
- How compilers are structured.
- A lexer for lexical analysis.
- A parser for syntactic analysis and parse-time evaluation.
- Designing of a virtual machine.
- A simple virtual machine.
- A new parser generating code for the virtual machine.
- Type analysis and operator overloading.
3 comments:
Crenshaw's series was a revelation to me, as well. I had had glimmerings of comprehension, as Turbo Pascal evolved, and some of what goes on under the covers inevitably became apparent. But Jack's clear style, and his so fundamental approach to the mechanics of implementation, gave me a much greater comprehension of what goes on.
Mind you, I have still not written a compiler of my own -- I'm more than happy with Delphi and C# -- but now I know that I could, and that the result could at least be competent and workmanlike.
You said you'd write a series of articles but as far as I can see this was the first and only one. Are you going to continue?
This open-source project may be useful http://code.google.com/p/delphibasic in writing an expression evaliator or even a programming language on Delphi.
Post a Comment