Print

Print


> Date: Tue, 9 Sep 2003 17:59:14 +0100
> From: Robert Sanderson <[log in to unmask]>
>
> > How about:
> >  >dc1="core-v1"  dc1.title=first and >dc1="core-v1a" dc1.title=second
> > and dc1.title=third
>
> Lets remove the mappings and put in the parens:
>
> ((dc1.title=first and dc1.title=second) and dc1.title=third)
>
> And put back the mappings:
>
> >dc1=v1 ((dc1.title=first and >dc1=v1a dc1.title=second) and
>           dc1.title=third)

Oooh, no, you can't do it like that.  The prefix mappings _change_ the
bindings.

> > The third occurence of dc1 -- is it governed by the first or second
> > assignment?
>
> First, due to the left to right ordering of parens.

Nope, the last, because it's closest to the operand.

$ cat query
>dc1="core-v1" dc1.title=first and >dc1="core-v1a" dc1.title=second and dc1.title=third
$ CQLParser -c < query
>dc1="core-v1" ((dc1.title = first) and (>dc1="core-v1a" ((dc1.title = second) and (dc1.title = third))))
$

Have you actually tried this in your own parser?  I bet it does the
right thing.  XCQL for you to diff against follows my signature.  For
what it's worth (I've tested it), Adam's parser emits the same output.

 _/|_    _______________________________________________________________
/o ) \/  Mike Taylor  <[log in to unmask]>  http://www.miketaylor.org.uk
)_v__/\  "Take the cheese to sick bay" -- Belana Tores, Snr. Engineer,
         Star Trek Voyager (Episode: "Learning Curve")

--
<triple>
  <prefixes>
    <prefix>
      <name>dc1</name>
      <identifier>core-v1</identifier>
    </prefix>
  </prefixes>
  <boolean>
    <value>and</value>
  </boolean>
  <leftOperand>
    <searchClause>
      <index>dc1.title</index>
      <relation>
        <value>=</value>
      </relation>
      <term>first</term>
    </searchClause>
  </leftOperand>
  <rightOperand>
    <triple>
      <prefixes>
        <prefix>
          <name>dc1</name>
          <identifier>core-v1a</identifier>
        </prefix>
      </prefixes>
      <boolean>
        <value>and</value>
      </boolean>
      <leftOperand>
        <searchClause>
          <index>dc1.title</index>
          <relation>
            <value>=</value>
          </relation>
          <term>second</term>
        </searchClause>
      </leftOperand>
      <rightOperand>
        <searchClause>
          <index>dc1.title</index>
          <relation>
            <value>=</value>
          </relation>
          <term>third</term>
        </searchClause>
      </rightOperand>
    </triple>
  </rightOperand>
</triple>