home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / ada / 3949 < prev    next >
Encoding:
Internet Message Format  |  1993-01-11  |  3.3 KB

  1. Xref: sparky comp.lang.ada:3949 comp.compilers:2139
  2. Path: sparky!uunet!spool.mu.edu!uwm.edu!ogicse!das-news.harvard.edu!spdcc!iecc!compilers-sender
  3. From: eifrig@beanworld.cs.jhu.edu (Jonathan Eifrig)
  4. Newsgroups: comp.lang.ada,comp.compilers
  5. Subject: Re: Compiler Construction in Ada
  6. Keywords: courses, Ada, books
  7. Message-ID: <93-01-066@comp.compilers>
  8. Date: 12 Jan 93 00:12:03 GMT
  9. Article-I.D.: comp.93-01-066
  10. References: <93-01-048@comp.compilers> <93-01-058@comp.compilers>
  11. Sender: compilers-sender@iecc.cambridge.ma.us
  12. Reply-To: eifrig@beanworld.cs.jhu.edu (Jonathan Eifrig)
  13. Organization: The Johns Hopkins University CS Department
  14. Lines: 46
  15. Approved: compilers@iecc.cambridge.ma.us
  16.  
  17. bpb9204@tamsun.tamu.edu (Brent Burton) writes:
  18. >This format [hand-coded lexer/parser in Pascal, using the Dragon book]
  19. >proved to be quite effective and educational.  Through
  20. >previous work at IBM, I had experience with lex and yacc already and a
  21. >good understanding of the parsing process.  However, the hand-coding
  22. >approach was, I feel, mandatory to learn the important underlying
  23. >algorithms and to better understand the roles lex and yacc play.  After
  24. >the the discussion about LL and LALR parsers, I could finally understand
  25. >the shift/reduce and reduce/reduce errors. ;-)
  26.  
  27.     Having been involved in teaching the compiler design course here
  28. at Hopkins for the last two years, I thought I'd put my two cents in.
  29. (For the record, the first two years used the Dragon book, with a bunch of
  30. hand-written supplements, while the last year used Fischer/LeBlanc (C
  31. version)).
  32.  
  33.     Basically, I'd agree with Brent's motives: it's very important to
  34. understand the theory of shift/reduce parsing and backing-up DFA lexing
  35. before one can use the lex/yacc family of tools effectively.  However, I
  36. don't think that necessarily means writing lexers/parsers by hand.
  37.  
  38.     Here at Hopkins we structure the course around the semester
  39. project, which traditionally has been writing a Toy-to-C translator, where
  40. Toy is a Pascal-like language with integer and function types, ref and
  41. array constructors, and first-class functions.  (Function closures are
  42. what make the translation non-trivial).  The first half of the
  43. semester-long course's lectures are all on parsing theory, using Gough's
  44. excellent "Syntax Analysis and Software Tools" as a supplemental text.
  45. However, the students build their lexers and parsers using C, lex, and
  46. yacc.  I really don't see that subjecting students to the torture of
  47. cranking out lexers for a grammar with something like thirty keywords
  48. accomplishes much other than convincing them one is a sadist.  Don't even
  49. think about LR parsers with non-trivial action functions; debugging even
  50. the machine- generated ones is a horror show.
  51.  
  52.     I think that it's much better to get the student's up and running
  53. with a useable parser in a short amount of time.  This lets them
  54. concentrate on the more interesting parts of the compiler, like the
  55. type-checker, and experiment with different run-time strategies.  Yes, the
  56. theory of LR parsing is very important to learn, but I don't believe that
  57. can only be done by "rolling your own."
  58. --
  59. Jack Eifrig (eifrig@cs.jhu.edu)       The Johns Hopkins University, C.S. Dept.
  60. -- 
  61. Send compilers articles to compilers@iecc.cambridge.ma.us or
  62. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  63.