home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / function / 1347 < prev    next >
Encoding:
Internet Message Format  |  1992-11-10  |  2.0 KB

  1. Path: sparky!uunet!pipex!warwick!mrccrc!doc.ic.ac.uk!agate!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!spool.mu.edu!hri.com!noc.near.net!lynx!random.ccs.northeastern.edu!news
  2. From: wand@dec5120z.ccs.northeastern.edu (Mitchell Wand)
  3. Newsgroups: comp.lang.functional
  4. Subject: Re: Functional Parsers
  5. Message-ID: <WAND.92Nov10135223@dec5120z.ccs.northeastern.edu>
  6. Date: 10 Nov 92 18:52:23 GMT
  7. References: <1992Nov3.145117.21227@eng.cam.ac.uk> <1992Nov3.160104.5305@odin.diku.dk>
  8.     <1992Nov4.153220.8174@eng.cam.ac.uk>
  9.     <1992Nov10.170123.107@eng.cam.ac.uk>
  10. Sender: news@random.ccs.northeastern.edu
  11. Organization: College of Computer Science, Northeastern University
  12. Lines: 34
  13. In-Reply-To: ptb@eng.cam.ac.uk's message of 10 Nov 92 17: 01:23 GMT
  14. Nntp-Posting-Host: dec5120z.ccs.northeastern.edu
  15.  
  16. In article <1992Nov10.170123.107@eng.cam.ac.uk> ptb@eng.cam.ac.uk (P.T.
  17. Breuer) writes:
  18.  
  19.  
  20.    Thanks to Debora Weber-Wulff for offering a test case.
  21.    The language { a^n b^n | n>=0 } apparently definitely has no LL grammar
  22.    (but does have a LR(0) one) and is specifiable in pre-cc. But not all
  23.    LR(0) grammars are acceptable for precc, because LR(0) presentations can be
  24.    left recursive. 
  25.  
  26. a^n b^n not LL ?  Here's a grammar:
  27.  
  28. S -> A -|   (endmarker)
  29. A -> a A b
  30. A -> e
  31.  
  32. You can tell which of the two productions for to use for A: if it's an "a",
  33. you use the first, if it's "b" or the endmarker you use the second. (In other
  34. words, the FIRST sets of the 2 A-productions are disjoint, as needed for
  35. LL(1)-ness).  Am I missing something here?
  36.  
  37.    I think all LR(0) languages are expressible, though,
  38.    if you choose the right grammar presentation.
  39.  
  40. There's a theorem that says that any deterministic context-free language (ie
  41. acceptable by some deterministic PDA) is expressible by some LR(0) grammar.
  42. However, the grammar may be pretty ugly.
  43.  
  44. --Mitch 
  45. --
  46. Mitchell Wand
  47. College of Computer Science, Northeastern University
  48. 360 Huntington Avenue #161CN, Boston, MA 02115     Phone: (617) 437 2072
  49. Internet: wand@flora.ccs.northeastern.edu          Fax:   (617) 437 5121
  50.