Re: Why context-free? (Nick Maclaren)
9 Oct 2005 20:47:16 -0400

          From comp.compilers

Related articles
[3 earlier articles]
Re: Why context-free? (Russ Cox) (2005-10-07)
Re: Why context-free? (Robert A Duff) (2005-10-07)
Re: Why context-free? (2005-10-08)
Re: Why context-free? (2005-10-08)
Re: Why context-free? (glen herrmannsfeldt) (2005-10-09)
Re: Why context-free? (2005-10-09)
Re: Why context-free? (2005-10-09)
Re: Why context-free? (Robert Figura) (2005-10-10)
Re: Why context-free? (Ivan Boldyrev) (2005-10-10)
Re: Why context-free? (Tony Finch) (2005-10-13)
Re: Why context-free? (2005-10-13)
Re: Why context-free? (Chris F Clark) (2005-10-13)
Re: Why context-free? (Neelakantan Krishnaswami) (2005-10-13)
[17 later articles]
| List of all articles for this month |

From: (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

<> 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 :-)

Nick Maclaren.

Post a followup to this message

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