[TxMt] Language grammar problems
Curt Sellmer
sellmerfud at gmail.com
Fri Feb 24 02:17:26 UTC 2012
I have the following language grammar defined for Java Properties files.
This grammar works as expected in TM-1, however, there are two
separate problems when using this grammar with TM-2.
1. The end capture for a 'Property Definition' does not properly skip a
newline preceded by a backslash and thus does not recognize continued lines.
2. The pattern '\{\d+\}' is not being recognized to set the
'entity.name.variable.java-props'
scope. This pattern does match
properly in a simple grammar where it is the only pattern however. (This
pattern is not part of java properties but I'm using the property files
to store strings that will be used with the java.text formatters.)
Perhaps there is a better way to describe this grammar, I'm no expert. But
since it does work correctly in TM-1 I wanted to report it as potential
defects in TM-2.
Thanks,
Curt
{ scopeName = 'source.java-props';
fileTypes = ( 'properties' );
patterns = (
{ name = 'comment.line.number-sign.java-props';
match = '^\s*([#!])(.+)?$\n?';
captures = { 1 = { name = 'punctuation.definition.comment.java-props'; }; };
},
{ comment = 'Empty Property Definition';
match = '^\s*((?:\\:|\\=|[^:=\s])+)\s*([:=])\s*$';
captures = {
1 = { name = 'keyword.other.java-props'; };
2 = { name = 'punctuation.separator.key-value.java-props'; };
};
},
{ comment = 'Property Definition';
begin = '^\s*((?:\\:|\\=|[^:=\s])+)\s*([:=])\s*';
end = '(?<!\\{1})$\n?';
beginCaptures = {
1 = { name = 'keyword.other.java-props'; };
2 = { name = 'punctuation.separator.key-value.java-props'; };
};
patterns = (
{ name = 'entity.name.variable.java-props';
match = '\{\d+\}';
},
{ comment = 'Leading space on a continued line is ignored';
match = '^\s*';
},
{ name = 'punctuation.separator.continuation.java-props';
match = '(\\)(?=$\n)';
},
{ name = 'constant.character.escape.java-props';
match = '\\(?:[\\nt\"'']|u[0-9A-Fa-f]{4})';
},
{ name = 'invalid.illegal.character.escape.java-props';
match = '\\.';
},
{ name = 'string.java-props';
match = '.';
},
);
},
{ comment = 'Ignore blank lines';
match = '^\s*$';
},
{ name = 'invalid.illegal.java-props';
comment = 'Anything else is illegal';
match = '.*';
},
);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20120223/74407002/attachment.html>
More information about the textmate
mailing list