Re: Have I discovered something new?

"Robert Corbett" <robert.corbett@sun.com>
31 Jul 2002 00:32:29 -0400

          From comp.compilers

Related articles
Have I discovered something new? steve.horne@iris.co.uk (Stephen Horne) (2002-07-15)
Re: Have I discovered something new? torbenm@diku.dk (Torben Ægidius Mogensen) (2002-07-21)
Re: Have I discovered something new? joachim_d@gmx.de (Joachim Durchholz) (2002-07-21)
Have I discovered something new? cfc@world.std.com (Chris F Clark) (2002-07-21)
Re: Have I discovered something new? kgw-news@stiscan.com (2002-07-21)
Re: Have I discovered something new? whopkins@alpha2.csd.uwm.edu (Mark) (2002-07-24)
Re: Have I discovered something new? steve@lurking.demon.co.uk (Steve Horne) (2002-07-25)
Re: Have I discovered something new? robert.corbett@sun.com (Robert Corbett) (2002-07-31)
Re: Have I discovered something new? whopkins@alpha2.csd.uwm.edu (Mark) (2002-07-31)
Re: Have I discovered something new? cfc@shell01.TheWorld.com (Chris F Clark) (2002-08-04)
Re: Have I discovered something new? whopkins@alpha2.csd.uwm.edu (Mark) (2002-08-04)
| List of all articles for this month |

From: "Robert Corbett" <robert.corbett@sun.com>
Newsgroups: comp.compilers
Date: 31 Jul 2002 00:32:29 -0400
Organization: http://groups.google.com/
References: 02-07-057 02-07-079
Keywords: parse
Posted-Date: 31 Jul 2002 00:32:28 EDT

"Chris F Clark" <cfc@world.std.com> wrote in message news:02-07-079...


> > It will certainly handle any grammar that a Tomita parser will
> > handle, and do so without needing stack duplication.
>
> At one level I believe your claim for this, because we have an
> (unpublished) algorithm implemented in an experimental version of
> Yacc++ that does roughly this. (We call our technique LR(infinity)
> because it effectively extends the lookahead of the parser out in an
> unbounded fashion.) The idea is that instead of duplicating the stack
> at runtime as a Tomita parser does, one precomputes the stack
> extensions at compile time (the same way that an LR parser does
> relative to an LL one).
>
> I believe for non-ambiguous grammar the process of doing so always
> terminates.


I doubt it. Consider the grammar


        S -> aSa | a


This grammar is unambiguous, but it features unbounded nondeterminism.


Parsing this grammar requires finding the middle of the input string.
Finding the middle using a left-to-right parser requires pairing off
the terminal symbols to the left and right of the current point of the
parse. The information that must be saved essentially amounts to
counting the number of terminal symbols in the input string. Thus,
the amount information needed is unbounded. Precomputing an unbounded
amount of information is likely to take a long time.


The language generated by the grammar can be recognized in linear
time. The grammar can be parsed in linear time using a two-headed
bi-directional parsing automaton if the automaton can tell when the
two heads are positioned on the same input symbol.


Determinisic grammars and grammars with bounded nondeterminism can be
parsed in linear time. That is an old result. I learned it thirty
years ago.


A problem with parsing ambiguous grammars is choosing a suitable
representation for the derivations. Consider the grammar


        S -> S | a


The single string generated by this grammar has an infinite number of
derivations.


                                                                                        Sincerely,
                                                                                        Bob Corbett


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.