GNOME Bugzilla – Bug 168090
Recognise fortran line comments better
Last modified: 2006-09-29 19:08:19 UTC
Patch follows.
Created attachment 37758 [details] [review] Recognise fixed-form line comments more effectively, add "stop" keyword - <start-regex>!|(^C)</start-regex> + <start-regex>!|(^[Cc][^A-Z^a-z])</start-regex> This avoids thinking that "COMMON" is a comment line. This patch also sneaks in the "STOP" keyword, which I'd missed out before for some reason.
I'm not sure about this patch since, AFAIK, something like: CIAO should be considered a comment. Does the compiler consider COMMON a comment or a valid instruction? In the case is a valid instruction I think we should try to manage "COMMON" as a special case. I'm adding the "STOP" keyword to the current .lang file.
Created attachment 48226 [details] [review] Committed patch I have committed the attached patch.
In fixed source form, the first 6 characters on each line are special, so "^COMMON" is a comment, while "^ COMMON" is a valid keyword. In free source form, C is not used for comments at all. So the answer to whether "^COMMON" is a comment or an instruction is "it depends". The reason I had it look for whitespace after the [Cc] is that it's very conventional in fixed source form to have at least one space after the C. I'm not sure it's worth maintaining separate specs for fixed and free form fortran: it's only a funny few cases like this where they diverge.
Sorry for the very late reply. I'm going to modify the .lang file in the following way: <!-- Note: contains an hack to avoid considering ^COMMON a comment --> <line-comment _name = "Line Comment" style= "Comment"> <start-regex>!|(^[Cc](\b|[^Oo]))</start-regex> </line-comment> I know it is not the perfect solution, but I think it is simple and quite effective. The only drawback is the comment starting with "CO" are not marked as comment. But I think it is more important to mark "COMMON" as a keyword. Closing as FIXED. 2005-12-31 Paolo Maggi <paolo@gnome.org> * gtksourceview/language-specs/fortran.lang: does not mark "^COMMON" as a comment. Based on a patch by John Spray <jcs116@york.ac.uk>. Fixes bug #168090 (Recognise fortran line comments better) John: feel free to reopen this bug if you think my solution has problems.
Created attachment 73668 [details] [review] Refine fortran line-comment regex After some more experience with gedit/fortran as a user, I think we just have to assume that comments starting with a 'c' have a word break before the comment itself -- otherwise we catch even things like "character" and "close", if the source is not at all indented (read: nasty). This patch takes us to what I think is the best compromise.