[TxMt] Ordering in language grammar

Jacob Carlborg doob at me.com
Wed Mar 25 21:12:49 UTC 2015


I'm trying to match the following code in the D language grammar:

static if (true) {}

void foo ()
{
     static if (true) {}
}

The first static-if is correctly recognized as 
"keyword.control.conditional.d". But the static-if inside "foo" is 
recognized as a method "meta.definition.method.d". I managed to get the 
top level static-if correctly recognized by moving the pattern for the 
static-if before the pattern for a method. But I don't understand why 
that doesn't work inside "foo".

The full scope of the static-if inside "foo" is:

source.d
meta.block.d
meta.definition.method.d
entity.name.function.d

The language grammar is available here [1]. Are the patterns evaluated 
in the wrong order or something like that?

Another thing I noticed is the "static if" on the top level seems to be 
recognized as a single word. When I use the hot keys for moving the 
cursor a word it jumps from the start of "static" to the end of "if", 
instead of to the end of "static".

[1] 
https://github.com/jacob-carlborg/d.tmbundle/blob/d2/Syntaxes/D.tmLanguage#L38-L43

-- 
/Jacob Carlborg



More information about the textmate mailing list