[TxMt] Re: Symbol list & Language grammar

Martin Kühl martin.kuehl at gmail.com
Wed Nov 30 15:45:19 UTC 2011


On Wed, Nov 30, 2011 at 15:52, Sean T Allen <sean at monkeysnatchbanana.com> wrote:
>
> The way to do this is by having a scope that matches the whole method
> "head" (`at: anIndex put: aValue`, say) and add that to the symbol list
> with a transformation removing the parameters.
>
> This is not generally a trivial task, but it can be done if you can
> either find a simpler matcher (usually a match instead of a begin/end
> pair) or a clean separator between a method's head and body (the "hard"
> way), or if you're fine without having separate scopes for method head,
> body and (complete) definition.
>
> In your example, if you can do without the `'#language_elements`
> inclusion you could try a matcher like
> ^([-+])\s+((\w+:?)(\s*\w+)?)+
> to match the whole line at once and assign some scope to the 0 capture.
>
> I'll have to document the "hard" way properly some day, but the gist is
> you can match a construct of the form `X stuff Y more Z` with a pair
> of begin/end matchers for X and Z and then including nested begin/end
> matchers for X to Y and Y to Z using lots of lookaheads and -behinds.
>
> An example is included in my Maude grammar[1] as the `#operator` rule
> with a matcher for the whole operator construct and nested matchers for
> its range, domain and definition.
>
> Hope that helps anyway?
>
>
> 1: yeah language elements is left over from a previous attempt at something
> else that I need to return to. Not needed here. Should have clipped.
>
> I've managed to do... add to symbol list or highlight syntax correctly but
> not both at once.
>
> Perhaps there is an answer above and I missed it, but is there a way to:
>
> match entire thing and transform symbol <-- yes because i have done that
> but also have highlighting so that
>
> at: anIndex put: aValue
>
> has at: and put: marked as 'function'
> &
> anIndex and aValue marked as 'parameters'
>
> AND
>
> then remove at: & put: from the symbol list?
>
> I can do highlighting. I can do symbols. I can't figure out how to combine
> the 2 together.

You need to assign some scope to `at: anIndex put: aValue` and another
scope to both `at:` and `put:`.
Then you add two preference items to your bundle, one for each of those
scopes. The one for the whole thing includes `showInSymbolList = 1;` and
the transformation, the other includes `showInSymbolList = 0;`.

Martin


More information about the textmate mailing list