Sublime Forum

Syntax highlight, incrementally addition of matching rules

#1

Hi,

I initially posted this in the technical support forum but I think this would be a better place for it… Sorry for the duplicity.

I’m writing my own package hoping to release it to the public once I’m satisfied with it. Right now, I am struggling to do something … weird. As most of us are fluent in C, I will explain this as if I was writing a C syntax highlight plugin.

I would like to be able to let’s say write:

#include <stdio.h> #include <math.h>

Now, I could write:

printf("Testing: %f\n", log10(3));

Now, I would like to have functions (printf and log10) highlighted when both includes are specified but not when their related include isn’t there or commented out.

I have played quite a lot with recurrence, with rules inclusion and $self/$base but can’t get the proper behavior. The problem being that once inside an included rule, matches outside this rule are forgotten.

This means that if I have a super rule which defines two sub-rules, one for stdio and the other for math, once inside the sub-rules I can’t get matches from the other one. I will always end up getting either one or the other sub-rule.

Hence the title of this post: being able to add rules when a match occurs.

Thanks.

0 Likes