Re: How do I create a programming language?

From: Programmer Dude (Chris_at_Sonnack.com)
Date: 12/09/03


Date: Tue, 09 Dec 2003 11:38:55 -0600

Leif K-Brooks wrote:

> I'm not really at the stage of language design yet, I'm just trying
> to figure out how to write basic parsers. I would be happy with a
> print statment and simple arithmetic (print 2+2 resulting in 4 being
> displayed, for instance).

Go Ogle for Jack Crenshaw's Compiler Tutorial.

Its brevity is only paralleled by its brilliance. After one day
(a longish day, but not a Day From Hell), I had a working compiler
that parsed mathematical expressions. Also an interpreter (the
compiler emitted 8086 assembler which, in theory, I could have fed
to MASM or something to generate a working program).

By the end of the weekend, I had a working compiler and a simple
(yet fairly complete) language.

Jack takes you through each stage in small, very easy to digest
pieces. The learning process alone was fun, let alone ending up
with a working product in short order.

Note: the tutorial is written for Pascal, but is quite easy to
translate to your favorite language (I was using C++).

-- 
|_ CJSonnack <Chris@Sonnack.com> _____________| How's my programming? |
|_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL  |
|_____________________________________________|_______________________|