Re: How Can I Make a Compiler With Java?

"Scott Stanchfield" <thetick@magelang.com>
10 Oct 1997 22:04:36 -0400

          From comp.compilers

Related articles
How Can I Make a Compiler With Java? kevalb@earthlink.net (Kevin Albrecht) (1997-10-08)
Re: How Can I Make a Compiler With Java? harth2@cuimail.unige.ch (Eric Harth) (1997-10-10)
Re: How Can I Make a Compiler With Java? thetick@magelang.com (Scott Stanchfield) (1997-10-10)
Re: How Can I Make a Compiler With Java? bothner@cygnus.com (1997-10-10)
Re: How Can I Make a Compiler With Java? dcm@c-sw.com (1997-10-10)
Re: How Can I Make a Compiler With Java? andrewbrown@acm.org (Andrew T. Brown) (1997-10-14)
| List of all articles for this month |

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

Well, first, download ANTLR 2.0 from
    http://java.magelang.com/antlr


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


  -- Scott


==============================================
Scott Stanchfield -- http://www.scruz.net/~thetick
Magelang Institute -- http://www.magelang.com


VisualAge for Java Tips & Tricks --
    http://www.scruz.net/~thetick/visualage
--


Post a followup to this message

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