home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.ada:3949 comp.compilers:2139
- Path: sparky!uunet!spool.mu.edu!uwm.edu!ogicse!das-news.harvard.edu!spdcc!iecc!compilers-sender
- From: eifrig@beanworld.cs.jhu.edu (Jonathan Eifrig)
- Newsgroups: comp.lang.ada,comp.compilers
- Subject: Re: Compiler Construction in Ada
- Keywords: courses, Ada, books
- Message-ID: <93-01-066@comp.compilers>
- Date: 12 Jan 93 00:12:03 GMT
- Article-I.D.: comp.93-01-066
- References: <93-01-048@comp.compilers> <93-01-058@comp.compilers>
- Sender: compilers-sender@iecc.cambridge.ma.us
- Reply-To: eifrig@beanworld.cs.jhu.edu (Jonathan Eifrig)
- Organization: The Johns Hopkins University CS Department
- Lines: 46
- Approved: compilers@iecc.cambridge.ma.us
-
- 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.
-