[SVN] Regular Expression Language Grammar
Michael Sheets
mummer at whitefalls.org
Wed Jun 14 22:44:16 UTC 2006
> # Included language missing in scope #
>
> The Regular Expression Language would be included with something like
>
> include = 'source.regexp';
That's very intentional; wouldn't work the other way around. For
instance the HTML bundle includes PHP, that doesn't make the entire
document PHP just once a php tag is matched.
The way it would work is you'd probably have a begin/end in the
language to match the regex boundaries, that's where the scope would
come from, that match would have the name, then include your syntax
inside the string.
> # Conditional pattern matches #
>
> Since most programming languages use very similar regular
> expressions, this language would be a candidate for inclusion in a
> number of languages. However most languages add their own quirks to
> regular expressions (eg variables). These would have to be listed
> at strategic locations inside the regular expression grammar,
> otherwise we end up copying the entire RegExp grammar for all these
> languages and adding the exceptions.
Sound pretty good to me, I've been longing for better Regex markup in
my themes because I find them exceedingly hard to parse without
coloring and currently they can't be colored much. The dynamic scopes
will even help with this (I can make the colors more vibrant when the
caret is inside the string.)
> So it would be great if there were conditional pattern matches,
> something along the lines of
>
> scope_contains = ( 'source.perl', 'source.ruby' );
I think that's actually a very poor way to do it, what I've longed
for with the HTML syntax (and bugged allan about ;) ) is to be able
to include a repository item as an include. So for instance...
include = 'source.regex#ruby';
That would only source the specific ruby repository item, then in
that you include only the things that would be relevant to Ruby, etc.
Now just join me in bugging allan about it. ;)
> # Names and coloring #
> string.regexp.escaped_char.newline
vs
> string.newline
Definitely the second is better, you have less to color if you are
generic as possible. Remember you can use the descendant selector to
match it already.
string.regex string.newline
Etc. However you can always get more specific on the other end...
string.escaped_char.newline.regexp.ruby
> # Include and Match/Captures #
>
> Is there any workaround for patterns like these?
Don't follow you at all here. ;)
More information about the textmate-dev
mailing list