Ray Denenberg wrote:
>See if this is readable (from a different mailer)
>Does this produce unambiguous cql?
The CQL grammar describes what I'd like to support. However, it is
>(And I think I have my email settings corrected. We'll see.)
> >dc1="core-v1" dc1.title=first and dc1.title=second
>Is the second dc1 governed by the first assignment? If so, is that
>the first assignment is "global" (and if so how do we know that) or
>it is the most recent assignment for dc1?
There are two principal ways this query can be interpreted. The first is:
(>dc1="core-v1" dc1.title=first) and dc1.title=second
and the second is:
>dc1="core-v1" (dc1.title=first and dc1.title=second)
The second is of preference. And it's what we've implemented. The reason
for for choosing the second is that it allows you to do
where A is any query. And A does not have to be in parantheses.
> >dc1="core-v1" dc1.title=first and >dc1="core-v1a" dc1.title=second
With this in mind, the above is:
>dc1="core-v1" (dc1.title=first and >dc1="core-v1a" (dc1.title=second
Hence, core-v1 is applied to the first. core-v1a is applied to second
>The third occurence of dc1 -- is it governed by the first or second
>I suppose the only workable rule is that a prefix in a search clause
>an assignment is governed by the most recent assignment for that
>(thus no global assignment at the beginning of the query).
>Anyway, I don't have any objection to this as long as we know (and
>with) the semantics.
Thanks. Very much appreciated. And you're on the spot on the ambiguity.
In a LR parser this ambiguity is seen as a shift/reduce conflict. For
the CWL grammar, a
shift is chosen. The shift makes CQL choose the second interpretation as
Usually shift/reduce conflicts are best avoided. But they are inevitable
for many (programming) languages. The most common, I suspect is the
if-else ambiguity as used in many programming languages.
Note that the introduction of "global" prefixes definitions does not
really make sense. prefix definitions apply to the right hand side of
the definition (but can be overriden). Just like local variables in
programming languages and like XML namespace definitions in XML.