home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / edu / 1582 < prev    next >
Encoding:
Text File  |  1992-09-08  |  1.8 KB  |  39 lines

  1. Newsgroups: comp.edu
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!malgudi.oar.net!caen!sdd.hp.com!decwrl!deccrl!news.crl.dec.com!news!nntpd.lkg.dec.com!math.zko.dec.com!edp
  3. From: edp@math.zko.dec.com (Eric Postpischil)
  4. Subject: Re: Re: Scientists as Programmers (was Re: Small Language Wanted)
  5. Message-ID: <1992Sep8.204155.2983@nntpd.lkg.dec.com>
  6. Sender: usenet@nntpd.lkg.dec.com (USENET News System)
  7. Reply-To: edp@math.zko.dec.com (Eric Postpischil)
  8. Organization: Digital Equipment Corporation
  9. References: <1992Sep3.112944.20996@dbsun.uucp> <Bu08uF.HBC@mentor.cc.purdue <KERS.92Sep4154056@cdollin.hpl.hp.com> <135691@lll-winken.LLNL.GOV>
  10. Distribution: na
  11. Date: Tue, 8 Sep 1992 20:41:55 GMT
  12. Lines: 25
  13.  
  14. In article <135691@lll-winken.LLNL.GOV>, blair@lll-crg.llnl.gov (Gary
  15. Blair) writes:
  16.  
  17. >Wrong.  If your compiler uses ANY kind of table-driven parsing scheme, it is
  18. >next to impossible to allow programmer-defined operators.  The parser must
  19. >know what an operator looks like, and what precedence it has  with respect
  20. >to all other operators.  This is usually predetermined, at
  21. >compiler-generation time.
  22.  
  23. Nah, it's trivial.  You do the operator recognition in the lexical
  24. analyzer, which then passes a token of type "operator" to the parser. 
  25. Thus, a program would declare the operator.  The compiler stores
  26. knowledge about the operator in some data structure.  From then on, the
  27. analyzer recognizes the operator as an operator from the knowledge in
  28. the data structure.
  29.  
  30. Handling precedence is a bit trickier.  But if you are willing to stick
  31. with a number of levels determined at compiler-generation time (by
  32. encoding them into the grammar), it's trivial to give any operator any
  33. precedence at compile time.
  34.  
  35.  
  36.                                 -- edp (Eric Postpischil)
  37.                                 "Always mount a scratch monkey."
  38.                                 edp@alien.enet.dec.com
  39.