From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,4fd338e56f592cfb X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 X-Received: by 10.66.8.69 with SMTP id p5mr5617056paa.46.1367665453329; Sat, 04 May 2013 04:04:13 -0700 (PDT) Path: ln4ni1321pbb.0!nntp.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed.news.ucla.edu!nrc-news.nrc.ca!News.Dal.Ca!news.litech.org!news.stack.nl!aioe.org!.POSTED!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: LALR parser question Date: Tue, 30 Apr 2013 06:11:06 +0200 Organization: Ada @ Home Message-ID: References: <85sj2aydwi.fsf@stephe-leake.org> NNTP-Posting-Host: ZXqOjp+NNxswgqXUj66j5g.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.15 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 X-Received-Bytes: 3734 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable Date: 2013-04-30T06:11:06+02:00 List-Id: Le Tue, 30 Apr 2013 04:03:13 +0200, John B. Matthews = a =C3=A9crit: > In article , > Yannick Duch=C3=AAne (Hibou57) wrote: > >> Note: GNAT uses a hand-written parser (I'm pretty sure to remember >> I've seen it somewhere). > > See also GNAT: The GNU Ada Compiler, =C2=A72.2 The Parser, cited here:= > > > While hand=E2=80=91written parser is not the only worth choice, a good r= eason for = this choice is as they say: =E2=80=9CGNU Ada Compiler, =C2=A72.2 The Parser=E2=80=9D: > At the architectural level the main subprogram of the > GNAT parser is an Ada function (Par) that is called to > analyze each compilation unit. The parser code is organized > as a set of packages (subunits of the top-level function) > each of which contains the parsing routines associated with > one chapter of the Ada Reference Manual [AAR95]. You can't do this with a parser generated automatically from a grammar, = = you can't split the generated parser as it's an automata generated as a = = indivisible whole. There are still some points I don't agree with=E2=80=A6 > Better error messages. GNAT generates clear andprecise error messages There is a common idiom with automatically generated parsers, to complet= e = the grammar so that it include wrong production, which normally does not= = introduce ambiguities, as these are wrong and normally not recognized by= = the grammar. But I agree this is easier with a hand=E2=80=91written pars= er. > Clarity. The GNAT parser follows faithfully the > grammar given in the Ada Reference Manual [AAR95] You get the same from an AST produced by an automatically generated = parser; clarity just happens to be visible more later. > Performance. The GNAT parser is as fast as any Ada > table driven parser, and arguably faster than a > LALR parser. The main issue with this argument, is that performance isn't a big issue= = at this stage. What comes next =E2=80=94 analyses, transformations, code= = generation =E2=80=94 is more important for the overall performance of a = compiler. = Then anyway, being exact is far more important than being fast, for a = compiler, and in that matter, the two previous points values a lot more = = (the points about clarity and precision). -- = =E2=80=9CSyntactic sugar causes cancer of the semi-colons.=E2=80=9D [1] =E2=80=9CStructured Programming supports the law of the excluded muddle.= =E2=80=9D [1] [1]: Epigrams on Programming =E2=80=94 Alan J. =E2=80=94 P. Yale Univers= ity