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: 103376,c89a4b067758a6e1 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!60g2000hsy.googlegroups.com!not-for-mail From: "=?ISO-8859-1?Q?Hibou57_(Yannick_Duch=EAne)?=" Newsgroups: comp.lang.ada Subject: Re: Is it really Ok to assert that the Ada syntax is a context-free grammar ? Date: Wed, 20 Feb 2008 16:30:01 -0800 (PST) Organization: http://groups.google.com Message-ID: <515c696b-e051-41f1-93dc-000b5b308494@60g2000hsy.googlegroups.com> References: <4a448c5c-a4ed-446f-bb8b-67c5ba99927a@f47g2000hsd.googlegroups.com> <47bbfb5b$1@news.post.ch> <37b7e369-01c8-4adf-8d1e-c40fa7e51cea@f47g2000hsd.googlegroups.com> <9012d70c-8d61-4e2e-9eda-c12d48f1d9e1@s19g2000prg.googlegroups.com> <47bc40e7$0$21890$4f793bc4@news.tdc.fi> <47bc9f09@news.upm.es> NNTP-Posting-Host: 86.66.190.2 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1203553801 6145 127.0.0.1 (21 Feb 2008 00:30:01 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 21 Feb 2008 00:30:01 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 60g2000hsy.googlegroups.com; posting-host=86.66.190.2; posting-account=vrfdLAoAAAAauX_3XwyXEwXCWN3A1l8D User-Agent: G2/1.0 X-HTTP-UserAgent: Opera/9.23 (Windows NT 5.1; U; fr),gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:19928 Date: 2008-02-20T16:30:01-08:00 List-Id: On 20 f=E9v, 22:38, Manuel Collado wrote: > Weel, the fact is that the Pascal grammar *is ambiguous*. Have you ever > heard the term "dangling else"? I like to read this.... this recall some good old memories from 15 years ago :) Yes I do, with TurbotPascal. There was a special note in the TurboPascal intergrated help, which said that the disambiguation was done by getting the longest construct (as with token scaning). There was a special rule, thus this was not considered ambigous, while for purist it was (and formaly speaking, it was, but in practice, it was not). Down to earth, if my memory is right, the construct IF Cond1 THEN IF Cond2 THEN Sttm1 ELSE Sttm2; was interpreted as IF Cond1 THEN BEGIN IF Cond2 THEN BEGIN Sttm1; END ELSE BEGIN Sttm2; END; END; instead of IF Cond1 THEN BEGIN IF Cond2 THEN BEGIN Sttm1; END; END ELSE BEGIN Sttm2; END; It was then recommended to always use begin/end to be more explicit and avoid bad surprises. Of course at the begining I get some (... bad surprises). From this time, I never leave the habitude to always use begin/end. Ada is pleasant in this area, beceause it drop the need of a "begin" for compound statement (single statement are treated like compound), and the mandatory "end if" to terminate the if_statement construct ([ARM 5.3], for peoples who love formalities), will have avoid the ambiguity. With Ada we will have either if Cond1 then if Cond2 then Sttm1; else Sttm2; end if; end if; or if Cond1 then if Cond2 then Sttm1; end if; else Sttm2; end if; or .... a syntax error :D Indeed, although while I came back to pascal during the past and actual year, I did not ever more though about it, beceause it has since this time become a provoked reflexe to me, but I must say I "hate" this part of the Pascal syntax, and the one of Ada is really nicer to me. Your post Manuel, was the occasion for a nice come back into old memories, ... so thanks to you this little moment.