From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 29EE0BB81 for ; Fri, 23 Sep 2005 14:53:36 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j8NCrZNL005180 for ; Fri, 23 Sep 2005 14:53:35 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA18893 for ; Fri, 23 Sep 2005 14:53:35 +0200 (MET DST) Received: from alex.barettalocal.com (host180-185.pool8174.interbusiness.it [81.74.185.180]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j8NCrYxN005177 for ; Fri, 23 Sep 2005 14:53:34 +0200 Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by alex.barettalocal.com (Postfix) with ESMTP id DFC9D2BAB78; Fri, 23 Sep 2005 14:51:00 +0200 (CEST) Message-ID: <4333FA34.5000305@barettadeit.com> Date: Fri, 23 Sep 2005 14:51:00 +0200 From: Alex Baretta User-Agent: Debian Thunderbird 1.0.2 (X11/20050602) X-Accept-Language: en-us, en MIME-Version: 1.0 To: padator@wanadoo.fr Cc: Ocaml Subject: Re: [Caml-list] Yacc limitations References: <6807416.1127467797619.JavaMail.www@wwinf1502> In-Reply-To: <6807416.1127467797619.JavaMail.www@wwinf1502> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 4333FACF.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4333FACE.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; baretta:01 caml-list:01 grammar:01 ocamlyacc:01 context-free:01 token:01 grammar:01 token:01 expansions:01 syntax:01 semantics:01 parser:01 semantics:01 non-terminal:01 parser:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 yoann padioleau wrote: >>>What is the problem with your SQL grammar and with ocamlyacc ? >> >>The problem is that context-free is bad. Did you ever see or hear of any >>real language where the context of a token is not meaningful? > > > Even with a context free grammar I can capture the context of a token. > in > S -> A B token C Sometimes you can capture enough. Sometimes not enough. The point is that some of the alternative expansions of S are meaningful in some contexts and not in others. > Because grammar is about syntax, not semantics. The same is true for natural langage. Not quite. Remember "semantic actions"? A parser generator like yacc maps semantics onto a set of strings by recognizing structures generated by a grammar. We are hardly ever interested in recognizing but almost always in "semantizing" a string of a language. > Now let's say that you can write context free grammar for your SQL langage, what would you write ? > You now have the ability to put multiple non-terminal at the left of the rule, such as in > > A B C -> D > > What would you write for your SQL grammar ? I'm not sure what I would write in a generalized grammar framework. What I definitely sometimes feel the need for is the possibility of selecting within a semantic action the set of "active" productions which are the parser is "allowed" to use until further notice. This would allow me to provide an explicit distinction in cases where contextual information--implicitly available within the scope of a semantic action--allows to discriminate any ambiguity in the production rules. Alex -- ********************************************************************* http://www.barettadeit.com/ Baretta DE&IT A division of Baretta SRL tel. +39 02 370 111 55 fax. +39 02 370 111 54 Our technology: The Application System/Xcaml (AS/Xcaml) The FreerP Project