What are the rules for what items from a language grammar appear in the symbol list? Some of the scope's I've defined ( for class and function ) appear in the symbol list but not others.
I've looked for a list or documentation of what will appear in the symbol list by default and can't find anything.
On Wed, Nov 30, 2011 at 04:38, Sean T Allen sean@monkeysnatchbanana.com wrote:
What are the rules for what items from a language grammar appear in the symbol list?
I think the `entity.name` scopes are included by default.
If you're defining a grammar for a class-based language (it sounds like you are) you might want to customize their appearance anyway, as described in [1]. (The Java bundle is a good example.)
Cheers, Martin
[1]: http://manual.macromates.com/en/navigation_overview#customizing_the_list
I'm trying to work an issue out...
It's a smalltalk grammar for redline smalltalk.
method start with either + or - to indicate class or instance
then all of the following are examples of valid smalltalk methods
string at: at:put:
textually those would be something like
- string
- at: anIndex
- at: anIndex put: aValue
The current rule I have to match that is:
method_definition = { begin = '^-|+\s'; end = '$'; patterns = ( { match = '((\w+:?)(\s*\w+)?)'; captures = { 2 = { name = 'entity.name.function.instance.smalltalk'; }; 3 = { name = 'variable.parameter.method.smalltalk'; }; }; }, { include = '#language_elements'; }, ); };
The problem really are ones like
at:put:
Keyword methods with more than a single keyword.
Textmate sees it not as
at:put:
But at: & put:
Highlighting works great but the naming isn't correct.
Can I mark
at: anIndex put: aValue
as the function then further say anIndex and aValue are method parameters?
then transforming into just at:put:
If that is a reasonable approach. What is the best way to match the variable number of keywords as a single run? I can get the one at a time in the above approach but I can't figure out a way to match all at once and still mark the individual method parameters.
On Wednesday, November 30, 2011 at 4:02 AM, Martin Kühl wrote:
On Wed, Nov 30, 2011 at 04:38, Sean T Allen <sean@monkeysnatchbanana.com (mailto:sean@monkeysnatchbanana.com)> wrote:
What are the rules for what items from a language grammar appear in the symbol list?
I think the `entity.name (http://entity.name)%60 scopes are included by default. If you're defining a grammar for a class-based language (it sounds like you are) you might want to customize their appearance anyway, as described in [1]. (The Java bundle is a good example.) Cheers, Martin [1]: http://manual.macromates.com/en/navigation_overview#customizing_the_list _______________________________________________ textmate mailing list textmate@lists.macromates.com (mailto:textmate@lists.macromates.com) http://lists.macromates.com/listinfo/textmate
On Wed, Nov 30, 2011 at 13:44, Sean T Allen sean@monkeysnatchbanana.com wrote:
I'm trying to work an issue out...
It's a smalltalk grammar for redline smalltalk.
method start with either + or - to indicate class or instance
then all of the following are examples of valid smalltalk methods
string at: at:put:
textually those would be something like
string
at: anIndex
at: anIndex put: aValue
The current rule I have to match that is:
method_definition = { begin = '^-|+\s'; end = '$'; patterns = ( { match = '((\w+:?)(\s*\w+)?)'; captures = { 2 = { name = 'entity.name.function.instance.smalltalk'; }; 3 = { name = 'variable.parameter.method.smalltalk'; }; }; }, { include = '#language_elements'; }, ); };
The problem really are ones like
at:put:
Keyword methods with more than a single keyword.
Textmate sees it not as
at:put:
But at: & put:
Highlighting works great but the naming isn't correct.
Can I mark
at: anIndex put: aValue
as the function then further say anIndex and aValue are method parameters?
then transforming into just at:put:
If that is a reasonable approach. What is the best way to match the variable number of keywords as a single run? I can get the one at a time in the above approach but I can't figure out a way to match all at once and still mark the individual method parameters.
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?
Cheers, Martin
[1]: https://github.com/mkhl/maude.tmbundle/blob/master/Syntaxes/Maude.tmLanguage
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.
On Wed, Nov 30, 2011 at 15:52, Sean T Allen sean@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