comp.lang.ada
 help / color / mirror / Atom feed
From: alex@MIMSY.CS.UMD.EDU  (Alex Blakemore)
Subject: Re: GNU-NYU Ada project
Date: 20 Nov 92 22:55:41 GMT	[thread overview]
Message-ID: <62223@mimsy.umd.edu> (raw)

dpoole@hydrogen.oscs.montana.edu (David Poole) writes:
[report about NYU GNU Ada Project]
> the parser uses recursive descent.  Why?  I thought LALR was the best possibl
e.

Thoretical answer at the end but in short in choosing between a LALR(1) and
recursive descent approach to a parser - there are tradeoffs on both sides.

LALR(1)
  + appropriate for a wide class of languages
  + usually constructed automatically from a grammar
  + easy to handle synthesized attributes
  - harder to handle inherited attributes
  - difficult to get good error messages and recovery

recursive descent (works for LL(1))
  + often faster (though parsing is not usually the compilation bottleneck)
  + easier to get good error messages and recover from syntax errors gracefully
  + easy to handle inherited attributes
  - harder to handle synthesized attributes
  - usually requires construction by hand
  - some grammars are not LL(1) but are LALR(1)

So we should be happy that the NYU GNAT team (really Robert Dewar in this case 
I think)
were willing to put in the effort to build a parser by hand so GNU Ada
would be faster and have very good error messages/recovery.

The class of language accepted is not as critical as one would think because
all practical compilers parse a language that includes strings (programs)  
that are not in the source language and then prune illegal programs via
semantic checks (conceptually after parsing phase).

LALR(1) is a very popular class of grammar because it includes a large class
of languages and there are efficient techniques/tools for automatically constru
cting
parsers for LALR(1) grammars.  It is not the _best possible_ assuming you mean
can parse the largest class of grammars.  I believe there exist languages for w
hich
there exist LR(1) grammars but not LALR(1) grammars for example.  Recursive des
cent
works for the class LL(1) which is smaller than LALR(1).
-- 
---------------------------------------------------
Alex Blakemore alex@cs.umd.edu   NeXT mail accepted

             reply	other threads:[~1992-11-20 22:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-11-20 22:55 Alex Blakemore [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-11-25 16:36 GNU-NYU Ada project cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!do
1992-11-20 21:02 Tucker Taft
1992-11-19 18:45 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!sgiblab!cs.u
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox