Re: LR(n) parsers

anw@maths.nott.ac.uk (Dr A. N. Walker)
Mon, 14 Oct 1991 16:58:03 GMT

          From comp.compilers

Related articles
LR(n) parsers whatis@ucsd.edu (Steve Boswell) (1991-10-10)
Re: LR(n) parsers KARSTEN@tfl.dk (Karsten Nyblad, TFL, Denmark) (1991-10-13)
Re: LR(n) parsers goer@midway.uchicago.edu (1991-10-14)
Re: LR(n) parsers sra@ecs.soton.ac.uk (1991-10-14)
Re: LR(n) parsers anw@maths.nott.ac.uk (1991-10-14)
Re: LR(n) parsers bburshte@pyrps5.eng.pyramid.com (1991-10-14)
Re: LR(n) parsers mareb@levels.unisa.edu.au (1991-10-15)
Re: LR(n) parsers nickh@harlqn.co.uk (Nick Haines) (1991-10-16)
Re: LR(n) parsers mtxinu!angular!jas@uunet.uu.net (1991-10-18)
Re: LR(n) parsers rockwell@socrates.umd.edu (Raul Deluth Miller-Rockwell) (1991-10-19)
Re: LR(n) parsers schoebel@bs5.informatik.uni-stuttgart.de (Thomas Schoebel) (1991-10-19)
[6 later articles]
| List of all articles for this month |
Newsgroups: comp.compilers
From: anw@maths.nott.ac.uk (Dr A. N. Walker)
Keywords: parse, algol68
Organization: Maths Dept., Nott'm Univ., UK.
References: 91-10-036
Date: Mon, 14 Oct 1991 16:58:03 GMT

In article 91-10-036 Steve Boswell <whatis@ucsd.edu> writes:
>What sort of easily-describable or commonly-occuring grammars are
>ambiguous for any amount of lookahead?


I don't know whether it could still be described as "common" or
as "easily describable", but Algol [68, of course] is full of such things.
To give three simple examples:


      a) In "BEGIN A a; B b; C c; D d; ....", A, B, C, D, ... could be mode
[type] names, in which case we are declaring identifiers a, b, c, d;
or they could [any or all of them] be monadic operators operating
[and presumably having side-effects] on the global variables a, b,
c, d. You can't in general tell until you reach the end of the
program, as the declarations of A, B, C, D don't have to precede
their uses.


      b) Both "BEGIN lots of grunge END" and "IF lots of grunge THEN ...."
may be abbreviated to "( lots of grunge ..." except that "END"
will be abbreviated to ")" and "THEN" to "|". This can't be
disambiguated until you get to the ")" or "|", and "lots of grunge"
may include arbitrarily many declarations and statements.


      c) "(foo, bar, baz, ...", where "foo" etc could be arbitrarily messy
units, could be the start of a collateral clause, or could be the
start of an abbreviation for "[1:foo, 1:bar, ...] SOMEMODE a",
declaring an array.


On the other hand, all of these ambiguities are "easily" resolved
in a multi-pass compiler; which surely is the usual resolution of a need
for long lookaheads.


--
Andy Walker, Maths Dept., Nott'm Univ., UK.
anw@maths.nott.ac.uk
--


Post a followup to this message

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