Hi all,
when using TextMate2 with (modern) Fortran I found that the implementation of derived types does not support the access attributes. For example,
type node integer :: i end type node
looks nice, while inserting the "public" or "private" attributes as in
type, public :: node integer :: i end type node
does not produce a consistent coloring (see also the attached screenshot1.png).
In an first attempt to resolve the problem, I changed the the corresponding entry in the Fortran-Modern Grammar from
{ name = 'meta.type-definition.fortran.modern'; comment = 'Type definition'; begin = '(?x: # extended mode ^\s* # begining of line and some space (?i:(type)) # 1: word type \s+ # some space ([a-zA-Z_][a-zA-Z0-9_]*) # 2: type name )'; end = '(?x: ((?i:end)) # 1: the word end \s* # possibly some space (?i:(type))? # 2: possibly the word type (\s+[A-Za-z_][A-Za-z0-9_]*)? # 3: possibly the name )'; beginCaptures = { 1 = { name = 'storage.type.fortran.modern'; }; 2 = { name = 'entity.name.type.fortran.modern'; }; }; endCaptures = { 1 = { name = 'keyword.other.fortran'; }; 2 = { name = 'storage.type.fortran.modern'; }; 3 = { name = 'entity.name.type.end.fortran.modern'; }; };
to
{ name = 'meta.type-definition.fortran.modern'; comment = 'Type definition'; begin = '(?x: # extended mode ^\s* # begining of line and some space (?i:(type)) # 1: word type (,*(?i:(public|private)?)) # 2: optional access attribute \s+ # some space ([a-zA-Z_][a-zA-Z0-9_]*) # 3: type name )'; end = '(?x: ((?i:end)) # 1: the word end \s* # possibly some space (?i:(type))? # 2: possibly the word type (\s+[A-Za-z_][A-Za-z0-9_]*)? # 3: possibly the name )'; beginCaptures = { 1 = { name = 'storage.type.fortran.modern'; }; 2 = { name = 'storage.modifier.fortran.modern'; }; 3 = { name = 'entity.name.type.fortran.modern'; }; }; endCaptures = { 1 = { name = 'keyword.other.fortran'; }; 2 = { name = 'storage.type.fortran.modern'; }; 3 = { name = 'entity.name.type.end.fortran.modern'; }; };
which made things even worse (screenshot2.png). I tried several other versions, with no essential improvement.
Can anybody give me a hint how to resolve the problem?
Regards, Joerg
On Mar 5, 2013, at 4:39 PM, Jörg Stiller joerg.stiller@tu-dresden.de wrote:
[…] the implementation of derived types does not support the access attributes […] inserting the "public" or "private" attributes as in
type, public :: node integer :: i end type node
does not produce a consistent coloring (see also the attached screenshot1.png).
In an first attempt to resolve the problem, I changed the the corresponding entry […] to
begin = '(?x: # extended mode ^\s* # begining of line and some space (?i:(type)) # 1: word type (,*(?i:(public|private)?)) # 2: optional access attribute \s+ # some space ([a-zA-Z_][a-zA-Z0-9_]*) # 3: type name )';
Can anybody give me a hint how to resolve the problem?
You need to change ‘*’ into ‘\s*’ and your added rule has the comma as mandatory but keyword as optional. Also, it introduce two captures, by using (capturing) parentheses for both entire pattern and the keyword, I suggest:
(?i:,\s*(public|private))? # 2: optional access attribute
Hi Allan,
many thanks for the hint. Finally I used
(?i:,\s*(public|private)\s*::)? # 2: optional access attribute
where I just added the double colon, which yields the desired behavior.
Cheers, Joerg
Am 06.03.2013 um 10:42 schrieb Allan Odgaard mailinglist@textmate.org:
On Mar 5, 2013, at 4:39 PM, Jörg Stiller joerg.stiller@tu-dresden.de wrote:
[…] the implementation of derived types does not support the access attributes […] inserting the "public" or "private" attributes as in
type, public :: node integer :: i end type node
does not produce a consistent coloring (see also the attached screenshot1.png).
In an first attempt to resolve the problem, I changed the the corresponding entry […] to
begin = '(?x: # extended mode ^\s* # begining of line and some space (?i:(type)) # 1: word type (,*(?i:(public|private)?)) # 2: optional access attribute \s+ # some space ([a-zA-Z_][a-zA-Z0-9_]*) # 3: type name )';
Can anybody give me a hint how to resolve the problem?
You need to change ‘*’ into ‘\s*’ and your added rule has the comma as mandatory but keyword as optional. Also, it introduce two captures, by using (capturing) parentheses for both entire pattern and the keyword, I suggest:
(?i:,\s*(public|private))? # 2: optional access attribute
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate