|How Can I Make a Compiler With Java? firstname.lastname@example.org (Kevin Albrecht) (1997-10-08)|
|Re: How Can I Make a Compiler With Java? email@example.com (Eric Harth) (1997-10-10)|
|Re: How Can I Make a Compiler With Java? firstname.lastname@example.org (Scott Stanchfield) (1997-10-10)|
|Re: How Can I Make a Compiler With Java? email@example.com (1997-10-10)|
|Re: How Can I Make a Compiler With Java? firstname.lastname@example.org (1997-10-10)|
|Re: How Can I Make a Compiler With Java? email@example.com (Andrew T. Brown) (1997-10-14)|
|From:||"Scott Stanchfield" <firstname.lastname@example.org>|
|Date:||10 Oct 1997 22:04:36 -0400|
|Organization:||MageLang Institute - http://www.magelang.com|
Well, first, download ANTLR 2.0 from
ANTLR (and the other tools you mention) are known as parser generators.
A parser generator is a tool that takes a grammatical specification of
the language you want to process, and generates a parser that will
recognize valid inputs in that language. You can add actions to that
grammar to do certain things when certain constructs are matched. For
example, you could add some information to a symbol table when you see
a declaration, or look it up when you see a reference.
ANTLR and JavaCC will create both parsers and scanners. A scanner is a
tool that will read the raw input and group it into manageable chunks
for the parser to handle. Think of a scanner as your eyes looking at
these letters on the screen, grouping them into words and symbols like
punctuation. The parser would act like your brain, grouping those
words into sentences and figuring out the meaning of those sentences.
Jlex produces scanners, while CUP I believe produces parsers.
If you haven't had any experience with compiler technology (or I
should just say parsers) I would recommend getting a copy of "Crafting
a Compiler" by Fischer & LeBlanc. It was the book I learned a bunch
of compiler stuff from. Another good one that everyone recommends is
the "Red Dragon" book by Aho et al (can someone provide the ref to
this -- I don't have it). [It's in the FAQ. -John]
Most if not all the tools you mention have sample grammars provided.
ANTLR's docs are online at
http://www.parr-research.com/antlr/doc/index.html. Terence Parr and I
are working on a Tutorial book for ANTLR as well.
I could go on forever, but it would probably be better if you targeted a few
Scott Stanchfield -- http://www.scruz.net/~thetick
Magelang Institute -- http://www.magelang.com
VisualAge for Java Tips & Tricks --
Return to the
Search the comp.compilers archives again.