comp.lang.ada
 help / color / mirror / Atom feed
From: agate!spool.mu.edu!uwm.edu!ogicse!das-news.harvard.edu!spdcc!iecc!compile rs-sender@ucbvax.Berkeley.EDU  (Jonathan Eifrig)
Subject: Re: Compiler Construction in Ada
Date: 12 Jan 93 00:12:03 GMT	[thread overview]
Message-ID: <93-01-066@comp.compilers> (raw)

bpb9204@tamsun.tamu.edu (Brent Burton) writes:
>This format [hand-coded lexer/parser in Pascal, using the Dragon book]
>proved to be quite effective and educational.  Through
>previous work at IBM, I had experience with lex and yacc already and a
>good understanding of the parsing process.  However, the hand-coding
>approach was, I feel, mandatory to learn the important underlying
>algorithms and to better understand the roles lex and yacc play.  After
>the the discussion about LL and LALR parsers, I could finally understand
>the shift/reduce and reduce/reduce errors. ;-)

	Having been involved in teaching the compiler design course here
at Hopkins for the last two years, I thought I'd put my two cents in.
(For the record, the first two years used the Dragon book, with a bunch of
hand-written supplements, while the last year used Fischer/LeBlanc (C
version)).

	Basically, I'd agree with Brent's motives: it's very important to
understand the theory of shift/reduce parsing and backing-up DFA lexing
before one can use the lex/yacc family of tools effectively.  However, I
don't think that necessarily means writing lexers/parsers by hand.

	Here at Hopkins we structure the course around the semester
project, which traditionally has been writing a Toy-to-C translator, where
Toy is a Pascal-like language with integer and function types, ref and
array constructors, and first-class functions.  (Function closures are
what make the translation non-trivial).  The first half of the
semester-long course's lectures are all on parsing theory, using Gough's
excellent "Syntax Analysis and Software Tools" as a supplemental text.
However, the students build their lexers and parsers using C, lex, and
yacc.  I really don't see that subjecting students to the torture of
cranking out lexers for a grammar with something like thirty keywords
accomplishes much other than convincing them one is a sadist.  Don't even
think about LR parsers with non-trivial action functions; debugging even
the machine- generated ones is a horror show.

	I think that it's much better to get the student's up and running
with a useable parser in a short amount of time.  This lets them
concentrate on the more interesting parts of the compiler, like the
type-checker, and experiment with different run-time strategies.  Yes, the
theory of LR parsing is very important to learn, but I don't believe that
can only be done by "rolling your own."
--
Jack Eifrig (eifrig@cs.jhu.edu)       The Johns Hopkins University, C.S. Dept.
-- 
Send compilers articles to compilers@iecc.cambridge.ma.us or
{ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.

             reply	other threads:[~1993-01-12  0:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-01-12  0:12 agate!spool.mu.edu!uwm.edu!ogicse!das-news.harvard.edu!spdcc!iecc!compile [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-01-17 22:49 Compiler Construction in Ada enterpoop.mit.edu!world!iecc!compilers-sender
1993-01-15 16:59 agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!zaphod.mps.ohio-state
1993-01-15 16:58 Robert I. Eachus
1993-01-15 14:00 agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!zaphod.mps.ohio-state
1993-01-15 13:14 Robert Firth
1993-01-15  2:04 agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!zaphod.mps.ohio-state
1993-01-13 19:53 Eliot Moss
1993-01-11  3:08 Brent Burton
1993-01-10 17:58 Michael Feldman
1993-01-08 20:41 swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!pacific.mps.ohio-sta
1993-01-08 14:24 James Crigler
1993-01-07 23:28 enterpoop.mit.edu!usc!wupost!uwm.edu!ogicse!das-news.harvard.edu!spdcc!ie
1993-01-07 12:42 agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!zaphod.mps.ohio-state
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox