Article View: comp.lang.functional
Article #563Re: Functional Parsers
From: Mitchell Wand
Date: Tue, 10 Nov 1992 18:52
Date: Tue, 10 Nov 1992 18:52
34 lines
2137 bytes
2137 bytes
In article <1992Nov10.170123.107@eng.cam.ac.uk> ptb@eng.cam.ac.uk (P.T.
Breuer) writes:
Thanks to Debora Weber-Wulff for offering a test case.
The language { a^n b^n | n>=0 } apparently definitely has no LL grammar
(but does have a LR(0) one) and is specifiable in pre-cc. But not all
LR(0) grammars are acceptable for precc, because LR(0) presentations can be
left recursive.
a^n b^n not LL ? Here's a grammar:
S -> A -| (endmarker)
A -> a A b
A -> e
You can tell which of the two productions for to use for A: if it's an "a",
you use the first, if it's "b" or the endmarker you use the second. (In other
words, the FIRST sets of the 2 A-productions are disjoint, as needed for
LL(1)-ness). Am I missing something here?
I think all LR(0) languages are expressible, though,
if you choose the right grammar presentation.
There's a theorem that says that any deterministic context-free language (ie
acceptable by some deterministic PDA) is expressible by some LR(0) grammar.
However, the grammar may be pretty ugly.
--Mitch
--
Mitchell Wand
College of Computer Science, Northeastern University
360 Huntington Avenue #161CN, Boston, MA 02115 Phone: (617) 437 2072
Internet: wand@flora.ccs.northeastern.edu Fax: (617) 437 5121
Technical Details
Message-ID:
<WAND.92Nov10135223@dec5120z.ccs.northeastern.edu>Path:
arc1-ca.pugleaf.net!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!newsReferences:
<1992Nov3.145117.21227@eng.cam.ac.uk> <1992Nov3.160104.5305@odin.diku.dk> <1992Nov4.153220.8174@eng.cam.ac.uk> <1992Nov10.170123.107@eng.cam.ac.uk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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 From: wand@dec5120z.ccs.northeastern.edu (Mitchell Wand) Newsgroups: comp.lang.functional Subject: Re: Functional Parsers Message-ID: <WAND.92Nov10135223@dec5120z.ccs.northeastern.edu> Date: 10 Nov 92 18:52:23 GMT References: <1992Nov3.145117.21227@eng.cam.ac.uk> <1992Nov3.160104.5305@odin.diku.dk> <1992Nov4.153220.8174@eng.cam.ac.uk> <1992Nov10.170123.107@eng.cam.ac.uk> Sender: news@random.ccs.northeastern.edu Organization: College of Computer Science, Northeastern University Lines: 34 In-Reply-To: ptb@eng.cam.ac.uk's message of 10 Nov 92 17: 01:23 GMT Nntp-Posting-Host: dec5120z.ccs.northeastern.edu