Re: Why context-free?

nmm1@cus.cam.ac.uk (Nick Maclaren)
9 Oct 2005 20:47:16 -0400

          From comp.compilers

Related articles
[3 earlier articles]
Re: Why context-free? rsc@swtch.com (Russ Cox) (2005-10-07)
Re: Why context-free? bobduff@shell01.TheWorld.com (Robert A Duff) (2005-10-07)
Re: Why context-free? nmm1@cus.cam.ac.uk (2005-10-08)
Re: Why context-free? vidyut.vidyut@gmail.com (2005-10-08)
Re: Why context-free? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2005-10-09)
Re: Why context-free? mpah@thegreen.co.uk (2005-10-09)
Re: Why context-free? nmm1@cus.cam.ac.uk (2005-10-09)
Re: Why context-free? rfigura@erbse.azagtoth.de (Robert Figura) (2005-10-10)
Re: Why context-free? boldyrev@cgitftp.uiggm.nsc.ru (Ivan Boldyrev) (2005-10-10)
Re: Why context-free? dot@dotat.at (Tony Finch) (2005-10-13)
Re: Why context-free? nmm1@cus.cam.ac.uk (2005-10-13)
Re: Why context-free? cfc@world.std.com (Chris F Clark) (2005-10-13)
Re: Why context-free? neelk@cs.cmu.edu (Neelakantan Krishnaswami) (2005-10-13)
[17 later articles]
| List of all articles for this month |
From: nmm1@cus.cam.ac.uk (Nick Maclaren)
Newsgroups: comp.compilers
Date: 9 Oct 2005 20:47:16 -0400
Organization: University of Cambridge, England
References: 05-10-053 05-10-055 05-10-064
Keywords: parse
Posted-Date: 09 Oct 2005 20:47:16 EDT

<vidyut.vidyut@gmail.com> wrote:
>One important thing he was saying was that some constraints like 'The
>type associated with the use of variable in an expression should
>always match with it's declared type' can't be expressed within a CFG
>itself ( although it can be achieved using attributes attached during
>syntax-directed translation ). Also he was saying that a
>context-sensitive grammar could express these kinds of constraints.
>
>Is the above assertion true ? If so, wouldn't using CSGs be more
>helpful for purposes like type checking etc ?


That is what two-level (van Wijngaarden) grammars were designed for
but, as I said, I know of no comprehensible description. I have found
nothing outside the "program proving" area that can handle scoping
etc., and it is a lifetime task to extract useful information from the
morass of obfuscated drivel that surrounds it.


It is very sad that there is such a gulf between theoreticians and
practitioners :-(


>[See my notes about two messages ago. Yes, you can build the types
>into the grammar by using context sensitivity, but no, it's not
>usually a good idea because it ruins the diagnotstics. Use
>attributes. That's what they're for. -John]


No, that is wrong. What you mean is that the parsing techniques that
produce reasonable diagnostics for CFGs cease doing so when such
context is added. There is no fundamental incompatibility between the
use of context and good diagnostics. ALGOL68C had good ones, and I
have also seen good ones in the very highly context-dependent
interpretive languages used in areas like statistics.


I fully agree that just bolting types onto an existing language and
parsing system will lead to poor diagnostics :-)




Regards,
Nick Maclaren.


Post a followup to this message

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