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
ambiguous.
>Consider:
>
>(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
>because
>the first assignment is "global" (and if so how do we know that) or
>because
>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
>prefix=uri A
where A is any query. And A does not have to be in parantheses.
>
>How about:
> >dc1="core-v1" dc1.title=first and >dc1="core-v1a" dc1.title=second
>and dc1.title=third
>
With this in mind, the above is:
>dc1="core-v1" (dc1.title=first and >dc1="core-v1a" (dc1.title=second
and dc1.title=third))
Hence, core-v1 is applied to the first. core-v1a is applied to second
and third.
>
>The third occurence of dc1 -- is it governed by the first or second
>assignment?
>
core-v1a.
>
>I suppose the only workable rule is that a prefix in a search clause
>without
>an assignment is governed by the most recent assignment for that
>prefix
>(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
>agree
>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
outlined
above.
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.
-- Adam
>
>--Ray
>
>
>
|