home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / edu / 1612 < prev    next >
Encoding:
Internet Message Format  |  1992-09-10  |  2.3 KB

  1. Xref: sparky comp.edu:1612 comp.compilers:1534
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!udel!gvls1!faatcrl!iecc!compilers-sender
  3. From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
  4. Newsgroups: comp.edu,comp.compilers
  5. Subject: Introducing new operators (was: Re: Scientists as Programmers)
  6. Keywords: parse, design
  7. Message-ID: <92-09-053@comp.compilers>
  8. Date: 8 Sep 92 17:49:50 GMT
  9. References: <1992Sep3.112944.20996@dbsun.uucp> <135691@lll-winken.LLNL.GOV>
  10. Sender: compilers-sender@iecc.cambridge.ma.us
  11. Reply-To: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
  12. Followup-To: comp.compilers
  13. Organization: Computer Science, University of Melbourne, Australia
  14. Lines: 33
  15. Approved: compilers@iecc.cambridge.ma.us
  16.  
  17. blair@lll-crg.llnl.gov (Gary Blair) writes:
  18.  
  19. >kers@hplb.hpl.hp.com (Chris Dollin) writes:
  20. >>In article ... fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
  21. >>
  22. >>   C++ allows you to overload existing operators, although to make compiler
  23. >>   writer's jobs easier, it does not allow you to introduce new operators.
  24. >>
  25. >>Make that ``trivially easier''. ...
  26. >
  27. >Wrong.  If your compiler uses ANY kind of table-driven parsing scheme, it is
  28. >next to impossible to allow programmer-defined operators.  The parser must
  29. >know what an operator looks like, and what precedence it has  with respect
  30. >to all other operators.  This is usually predetermined, at
  31. >compiler-generation time.  
  32.  
  33. I think that "next to impossible" is perhaps overstating the case a
  34. little.  If you have a small number of precedence levels (eg. Haskell has
  35. only 10 or 16 I think), then it is quite possible to code up each of these
  36. precedences as a production in the grammar. The difficulty with knowing
  37. what precedence a given operator has, or indeed exactly which characters
  38. constitute an operator, is then exactly analagous to the "typedef" problem
  39. in C (determining whether an identifier is a type name or not), and can be
  40. handled with the same sort of hack (feeding information from the parser
  41. back into the lexer).
  42.  
  43. All the same, it is not trivial. If you also have to worry about backwards
  44. compatability with C, it becomes very difficult indeed, I suspect.
  45. -- 
  46. Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
  47. -- 
  48. Send compilers articles to compilers@iecc.cambridge.ma.us or
  49. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  50.