[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Alex Baretta <alex@b...> |
| Subject: | Re: [Caml-list] Yacc limitations |
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) <http://www.asxcaml.org/> The FreerP Project <http://www.freerp.org/>