Hi all,
I would like to colorize the name of the do and if loops in Fortran... Those loops looks like this :
the_name:do i=1,10 some code here … enddo the_name
and similar for the if loops. I tried to give a scope to those loop names but with my poor knowledge of RegExp, I cannot achieve something satisfactory...
Any help is much appreciated :)
Thanks in advance.
On 15/9/2006, at 18:02, guerom00 wrote:
[...] I tried to give a scope to those loop names but with my poor knowledge of RegExp, I cannot achieve something satisfactory...
So you want the language grammar to scope labels?
A regexp like: ^[A-Za-z_]+: should match them, assuming here labels can only hold those characters.
Allan Odgaard <throw-away-1@...> writes:
On 15/9/2006, at 18:02, guerom00 wrote:
[...] I tried to give a scope to those loop names but with my poor knowledge of RegExp, I cannot achieve something satisfactory...
So you want the language grammar to scope labels?
A regexp like: ^[A-Za-z_]+: should match them, assuming here labels can only hold those characters.
Thank you very much, Allan. So here is what I did : { match = '(^[\t ]*)([A-Za-z_]+)(\s*:\b)'; captures = { 2 = { name = 'name.loop'; }; }; }, { match = '(^[\t ]*(?i:enddo|endif|end\sdo|end\sif)\s*\b)([A-Za-z_]+)(\b.*$)'; captures = { 2 = { name = 'name.loop'; }; }; }, Here is a screenshot of what happens : http://img96.imageshack.us/img96/5107/image1wn1.jpg You see that's pretty much OK except for the “enddo”, “endif” words which lose their color as they are not anymore in the 'keyword.other.Executable.fortran' scope... Can anything be done about that ?
On 16/9/2006, at 14:59, guerom00 wrote:
[...] what I did : { match = '(^[\t ]*)([A-Za-z_]+)(\s*:\b)'; captures = { 2 = { name = 'name.loop'; }; }; }, { match = '(^[\t ]*(?i:enddo|endif|end\sdo|end\sif)\s*\b)([A-Za-z_] +)(\b.*$)'; captures = { 2 = { name = 'name.loop'; }; }; }, Here is a screenshot of what happens : http://img96.imageshack.us/img96/5107/image1wn1.jpg You see that's pretty much OK except for the “enddo”, “endif” words which lose their color as they are not anymore in the 'keyword.other.Executable.fortran' scope... Can anything be done about that ?
Yes, the captures key is used to assign properties (names) to each of the captures, so in the second rule, let it be:
captures = { 2 = { name = 'keyword.other.Executable.fortran'; }; 3 = { name = 'name.loop'; }; };
I noticed that you had capture #2 be the name of the loop, but I count that as being capture #3, and #2 being the keyword.
Btw: I would probably use a name of entity.name.type.loop.fortran for the loop label.