After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 168090 - Recognise fortran line comments better
Recognise fortran line comments better
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: Syntax files
git master
Other Linux
: Normal normal
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2005-02-21 21:53 UTC by John Spray
Modified: 2006-09-29 19:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Recognise fixed-form line comments more effectively, add "stop" keyword (819 bytes, patch)
2005-02-21 21:56 UTC, John Spray
needs-work Details | Review
Committed patch (1.50 KB, patch)
2005-06-23 18:51 UTC, Paolo Maggi
committed Details | Review
Refine fortran line-comment regex (642 bytes, patch)
2006-09-29 19:08 UTC, John Spray
none Details | Review

Description John Spray 2005-02-21 21:53:43 UTC
Patch follows.
Comment 1 John Spray 2005-02-21 21:56:58 UTC
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.
Comment 2 Paolo Maggi 2005-06-23 18:50:20 UTC
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.



Comment 3 Paolo Maggi 2005-06-23 18:51:17 UTC
Created attachment 48226 [details] [review]
Committed patch

I have committed the attached patch.
Comment 4 John Spray 2005-06-24 19:22:52 UTC
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.
Comment 5 Paolo Maggi 2005-12-31 15:18:02 UTC
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.

Comment 6 John Spray 2006-09-29 19:08:19 UTC
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.