Related articles |
---|
Why context-free? nmm1@cus.cam.ac.uk (2005-10-06) |
Re: Why context-free? cfc@shell01.TheWorld.com (Chris F Clark) (2005-10-07) |
Re: Why context-free? torbenm@app-4.diku.dk (2005-10-07) |
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) |
[20 later articles] |
From: | vidyut.vidyut@gmail.com |
Newsgroups: | comp.compilers |
Date: | 8 Oct 2005 17:28:11 -0400 |
Organization: | http://groups.google.com |
References: | 05-10-05305-10-055 |
Keywords: | parse |
Posted-Date: | 08 Oct 2005 17:28:11 EDT |
Hi,
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 ?
Thanks.
[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]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.