Re: Why context-free?
8 Oct 2005 17:28:11 -0400

          From comp.compilers

Related articles
Why context-free? (2005-10-06)
Re: Why context-free? (Chris F Clark) (2005-10-07)
Re: Why context-free? (2005-10-07)
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)
[20 later articles]
| List of all articles for this month |

Newsgroups: comp.compilers
Date: 8 Oct 2005 17:28:11 -0400
References: 05-10-05305-10-055
Keywords: parse
Posted-Date: 08 Oct 2005 17:28:11 EDT

        Just a curious question : Some time back one of we had a similiar
question to which one of my classmates was telling us that

(1) Regular grammars are not sufficient for generating programming
languages since in most of the PLs we need matching procedure
call-return structures, many balanced structures for statements like
if-then-else etc which a PDA can easily keep track of.

(2) Well known parsing algorithms are known to exist for CFLs.

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 ?

[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]

Post a followup to this message

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