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

  1. Xref: sparky comp.compilers:1533 comp.human-factors:2171
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!udel!gvls1!faatcrl!iecc!compilers-sender
  3. From: torbenm@diku.dk (Torben AEgidius Mogensen)
  4. Newsgroups: comp.compilers,comp.human-factors
  5. Subject: Re: language design tradeoffs
  6. Keywords: design, parse
  7. Message-ID: <92-09-052@comp.compilers>
  8. Date: 8 Sep 92 11:07:58 GMT
  9. References: <92-09-048@comp.compilers>
  10. Sender: compilers-sender@iecc.cambridge.ma.us
  11. Reply-To: torbenm@diku.dk (Torben AEgidius Mogensen)
  12. Organization: Department of Computer Science, U of Copenhagen
  13. Lines: 37
  14. Approved: compilers@iecc.cambridge.ma.us
  15.  
  16. kotula@cs.umn.edu asks about languages with EOL as command separator
  17. contra using a visible character (like ;).
  18.  
  19. Several languages (e.g. Miranda) use EOL as separator. It gives an
  20. uncluttered syntax, but requires special structure if command or
  21. expressions can't fit on a line. Some languages (Haskell and some versions
  22. of BASIC) allow both EOL and e.g. ; as separators, thus allowing mixed
  23. notation.
  24.  
  25. It is even possible to make grouping dependent on indentation: if the next
  26. line is indented more than the present, it is considered an extension of
  27. the present line. This approach is used in Haskell and something similar
  28. applies in Miranda (though the indentation is dependent on the position of
  29. keywords on the previous line).
  30.  
  31. An example of this (in no particular language) is the following
  32. command/expression
  33.  
  34.     f
  35.       g
  36.           x
  37.          y
  38.       z
  39.  
  40. which is equivalent to
  41.  
  42.     f(g(x,y),z)
  43.  
  44. As for specifying a grammar for this, I believe it is better to handle the
  45. problem during the lexical analysis, making each new line generate one or
  46. more separators: "," if the indentation is the same, "(" if it is greater,
  47. and one or more ")" if it is smaller.
  48.  
  49.     Torben Mogensen (torbenm@diku.dk)
  50. -- 
  51. Send compilers articles to compilers@iecc.cambridge.ma.us or
  52. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  53.