Re: Can syntax be enough? No need of semantics.

Quinn Tyler Jackson <quinn_jackson2004@yahoo.ca>
Fri, 18 Sep 2009 09:36:35 -0700

          From comp.compilers

Related articles
Can syntax be enough? No need of semantics. sinu.nayak2001@gmail.com (Srinu) (2009-09-13)
Re: Can syntax be enough? No need of semantics. quinn_jackson2004@yahoo.ca (Quinn Tyler Jackson) (2009-09-18)
Re: Can syntax be enough? No need of semantics. news@cuboid.co.uk (Andy Walker) (2009-09-18)
Re: Can syntax be enough? No need of semantics. anton@mips.complang.tuwien.ac.at (2009-09-18)
Re: Can syntax be enough? No need of semantics. news@cuboid.co.uk (Andy Walker) (2009-09-19)
Re: Can syntax be enough? No need of semantics. dot@dotat.at (Tony Finch) (2009-09-21)
Re: Can syntax be enough? No need of semantics. torbenm@pc-003.diku.dk (2009-09-23)
Re: Can syntax be enough? No need of semantics. gopi.onthemove@gmail.com (gopi) (2009-09-24)
[2 later articles]
| List of all articles for this month |

From: Quinn Tyler Jackson <quinn_jackson2004@yahoo.ca>
Newsgroups: comp.compilers
Date: Fri, 18 Sep 2009 09:36:35 -0700
Organization: Compilers Central
References: 09-09-062
Keywords: theory, semantics
Posted-Date: 18 Sep 2009 15:28:49 EDT

Srinivas asked:


> Can we have a language/grammar, which doesn't need any semantics
> checking for it to be able to correctly interpreted by its compiler? I
> mean, if some statement of this language/grammar satisfies the syntax
> of the grammar, then it is a perfect statement and a compiler can
> perform right things according to what the statement specifies.
> Compiler shall not need semantics checking. Idea is to remove
> semantics checking phase from a compiler.
>
> Can this be possible?


Our moderator noted:


> [I've never seen a grammar that could handle in a reasonable checks
> that variables are declared before use, and that types of subexpressions
> match. -John]


To which I reply:


It is entirely possible to put semantic checks into a grammar and
thereby avoid ad hockery.* I have a grammar that does what John is
talking about for a lab-language created for the purpose of
demonstrating variable declaration and type checking. I have also
demonstrated the grammar structures necessary for a more subtle case:
member variables in C++ classes can be declared *after* they are
referenced in inline member function blocks. In fact, doing as much as
possible in a grammar (rather than in attached semantic code) has been
one of my Holy Grails for some time. (The correct grammar-only
processing of C++, for instance.) Another example is the Perl grammar.


Language theorists will immediately recognize that this cannot be done
by Type 2 constructs. The kinds of semantic checking being discussed
*can* be handled by a Type 0 system, however, and the state of the art
in generally available parsing engines is a very small subset of Type
1, if even that.


Many of these things are discussed in my book (Adapting to Babel) ad
nauseam with the charts, examples, experimental results, et cetera.


Quinn Tyler Jackson


* Where here "ad hockery" is defined as "doing in code rather than in
the grammar."



Post a followup to this message

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