Re: How Can I Make a Compiler With Java?

"Scott Stanchfield" <>
10 Oct 1997 22:04:36 -0400

          From comp.compilers

Related articles
How Can I Make a Compiler With Java? (Kevin Albrecht) (1997-10-08)
Re: How Can I Make a Compiler With Java? (Eric Harth) (1997-10-10)
Re: How Can I Make a Compiler With Java? (Scott Stanchfield) (1997-10-10)
Re: How Can I Make a Compiler With Java? (1997-10-10)
Re: How Can I Make a Compiler With Java? (1997-10-10)
Re: How Can I Make a Compiler With Java? (Andrew T. Brown) (1997-10-14)
| List of all articles for this month |

From: "Scott Stanchfield" <>
Newsgroups: comp.compilers
Date: 10 Oct 1997 22:04:36 -0400
Organization: MageLang Institute -
References: 97-10-036
Keywords: Java, parse

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 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
more questions...

  -- Scott

Scott Stanchfield --
Magelang Institute --

VisualAge for Java Tips & Tricks --

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.