# [TxMt] Re: formal definition of scope selector syntax?

Matt Neuburg matt at tidbits.com
Sun Jun 29 16:41:28 UTC 2008

```On 6/29/08 4:06 AM, in article
B8C096E6-5D62-4577-81ED-1CB6E863E1FC at textmate.org, "Allan Odgaard"
<mailinglist at textmate.org> wrote:

> On 27 Jun 2008, at 00:40, Matt Neuburg wrote:
>
>> [...] My last question would then be how all of that
>> ranking
>> selectors. I see how one can use those rules to rank two selectors
>> [...]
>>
>> But how on earth is one to make sense of the concept "the element
>> deepest
>> down" when a selector is of the form
>>
>> a - b | c & d, e - f | g & h
>>
>> ?? [...]
>
> In practice a numeric score is calculated for a scope selector match.
>
> The score will be 1.0 for full overlap between scope and scope
> selector, 0.0 for no overlap (i.e. empty scope selector), and below
> zero for ³negative overlap² (i.e. the scope selector has elements not
> part of the scope). The values between 0.0 and 1.0 are calculated
> corresponding to the rules given in 13.5 (done by effectively
> converting each fragment of the scope to a fraction and have all those
> numbers form a harmonic serie and then add the fractions that
> correspond to fragments matched by the scope selector).
>
> With a numeric score for each scope selector match it is trivial to
> calculate the score of a compound expression. E.g.: score(a | b) =
> max(score(a), score(b)).

And what about score(a & b)? You say "trivial" but it is not at all obvious
to me what scoring strategy is right to adopt here.

And I repeat, what about rule 3 in section 13.5? Suppose

score ((a | b) & c) == score ((d & e) | f)

In order to choose between them, we are now to recurse, trying again with a
shorter selector expression ("removing the deepest element"). What selector
expression am I to shorten? I see how to shorten a simple descendant
selector:

string source => string

But I do not see how to shorten

((string source) & ruby)

m.

--
matt neuburg, phd = matt at tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>

```