home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / compiler / 1546 < prev    next >
Encoding:
Text File  |  1992-09-12  |  1.7 KB  |  38 lines

  1. Newsgroups: comp.compilers
  2. Path: sparky!uunet!world!iecc!compilers-sender
  3. From: drw@euclid.mit.edu (Dale R. Worley)
  4. Subject: Re: Introducing new operators (was: Re: Scientists as Programmers)
  5. Reply-To: drw@euclid.mit.edu (Dale R. Worley)
  6. Organization: MIT Dept. of Tetrapilotomy, Cambridge, MA, USA
  7. Date: Fri, 11 Sep 1992 18:11:33 GMT
  8. Approved: compilers@iecc.cambridge.ma.us
  9. Message-ID: <92-09-065@comp.compilers>
  10. Followup-To: comp.compilers
  11. References: <1992Sep3.112944.20996@dbsun.uucp> <92-09-053@comp.compilers>
  12. Keywords: parse, design, algol68
  13. Sender: compilers-sender@iecc.cambridge.ma.us
  14. Lines: 22
  15.  
  16. fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
  17.  
  18. >If your compiler uses ANY kind of table-driven parsing scheme, it is
  19. >next to impossible to allow programmer-defined operators. ...
  20.  
  21.    I think that "next to impossible" is perhaps overstating the case a
  22.    little.  If you have a small number of precedence levels (eg. Haskell has
  23.    only 10 or 16 I think), then it is quite possible to code up each of these
  24.    precedences as a production in the grammar.
  25.  
  26. Yes.  I once wrote an Algol 68 front-end, and the scanner simply
  27. translated all operators into one of 11 tokens (ten tokens for the ten
  28. precedence levels of binary operators and one token for unary operators).
  29. The tricky part was that Algol 68 allows one to use a user-defined
  30. operator before declaring it, so you have to pre-scan the text to build
  31. the part of the symbol table that defines the operator precedences, and
  32. then on a second pass actually parse the expressions.
  33.  
  34. Dale Worley        Dept. of Math., MIT        drw@math.mit.edu
  35. -- 
  36. Send compilers articles to compilers@iecc.cambridge.ma.us or
  37. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  38.