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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5412c98a3943e746 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.220.229 with SMTP id pz5mr3098842pbc.5.1331151461964; Wed, 07 Mar 2012 12:17:41 -0800 (PST) Path: h9ni50872pbe.0!nntp.google.com!news2.google.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Verified compilers? Date: Wed, 7 Mar 2012 21:17:34 +0100 Organization: cbb software GmbH Message-ID: <1psd0g0womgxi.1sle7ol12x3d5.dlg@40tude.net> References: <9207716.776.1331054644462.JavaMail.geo-discussion-forums@ynaz38> <4edda5mav3cf$.149pbgyxl1wx5.dlg@40tude.net> <9rplcgF5a2U1@mid.individual.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: /bBpnkeEm9kG1v1C1CjDFw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-03-07T21:17:34+01:00 List-Id: On Wed, 07 Mar 2012 19:49:04 +0200, Niklas Holsti wrote: > On 12-03-07 11:12 , Dmitry A. Kazakov wrote: > >> I was always wondering why people bother to study grammars, LR, LL parsers >> and other useless stuff. > > Grammars and the notion of parsing (derivations) rigorously define what > a given string of characters means, in some formally defined language. No. A grammar defines some formal language: a set of strings. The meaning (program language semantics) is defined informally or else by another language into which these strings are translated. The grammar defines only syntax. Even that is defined incompletely for most cases, e.g. X : constant := 10**(10**(10**10)). Though nobody sheds a tear about it. An attempt to render all errors as syntax errors would reach nothing but unreadable diagnostics. Semantic error messages are much easier to understand. So syntax error messages are few and trivial, e.g. "end if expected." If I needed to recognize the infamous {ab, aabb, aaabbb, ...} why should I bother about the grammar? I would count a's and b's and compare two numbers. That is. Furthermore the merits of formal grammar definitions are debatable, because the complexity of grammar descriptions usually make it impossible to judge if a given string do belong to the formal language or not. Normally BNF is all one needs to define syntax. > As far as I can see, the only alternative would be to define the meaning > of a language by defining a specific interpreter as the standard > interpreter, and defining the meaning of a sentence as whatever this > interpreter does, when interpreting this sentence. Rather translation is the only way to formally define the semantics. >> This is a great example of making a "science" out >> of nothing and for nothing. > > The various types of grammars and the corresponding parsing procedures > help us understand which parsing methods work for which kinds of > grammars. Maybe, but they are totally irrelevant for the grammars of real programming languages. On one hand these classes do not capture real differences between syntaxes of programming languages. On the other hand, the classes they do describe have no other practical interest than torturing students of CS classes. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de