We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Fortran syntax Highlighting

Thread ID:

Created:

Updated:

Platform:

Replies:

96174 Aug 25,2010 03:00 PM UTC Jun 3,2013 03:38 PM UTC WinForms 9
loading
Tags: EditControl
Jim Bonomo
Asked On August 25, 2010 03:00 PM UTC

I am trying to create an xml sytax highlighting file for the Fortran language. I've got most of it to work but I can't get commenting to work correctly. In fortran, a "C" in column one indicates a comment line.



works fine if the second column contains a blank, but if the second column contains anything else, the line is not treated as a comment. For example:

C this is a comment

works but

CC this is a comment

does not.

Is there a way to make this work?

Thanks!

BTW, is there a more detailed description of how one builds a syntax highlight file than the one in the online docs?

Lingaraj S [Syncfusion]
Replied On August 30, 2010 12:17 PM UTC

Hi Jim,

Thank you for your interest in Syncfusion products.

1. Also try using Splits with this to achieve your requirement as shown below.





#region
c
#end region



2. Please refer the sample from our DashBoard shipped along with below location.
{Installed Directory}\EssentialStudio\8.3.0.21\Windows\Edit.Windows\Samples\2.0\Syntax Highlighting\Custom Config File

Please let me know if you have any queries.

Regards,
Lingaraj S.

Jim Bonomo
Replied On July 5, 2011 11:57 AM UTC

Thanks for your reply. Sorry it took so long to get back with this additional question. Your solution for the comment problem works well except for one thing. In fortran, comments start with a C in column 1. Your solution causes any line that starts with a C to be treated as a comment, even if this C is not in column 1. For example, this line should be treated as a comment

C This is a comment line

but this line should not:

C This is not a comment

due to the white space before the C.

Any suggestions on how to handle this?

Thanks!


Iniyen M A [Syncfusion]
Replied On July 8, 2011 06:53 AM UTC

Hi Jim,

Thanks for the update. Kindly have a following code snippet and let us know if this helps you.




#region
#end region


The above code will treat "c This is a comment line" sentence as a comment line but not "cThis is not a comment line" sentence.

Please let us know if i misunderstand your query or if you need further assistance.

Regards,
Iniyen M.A.



Jim Bonomo
Replied On July 13, 2011 06:41 PM UTC

I'm afraid this did not help. Also, I realized that my last example was probably confusing because the leading blanks were stripped from my message so let's try again.

Assume that the "&" character represents a space. In fortran, a "C" in column 1 means that the like is a comment. This works OK. However, executable statements in fortran start in column 7 or later. So the line

&&&&&&C this is not a comment

(again where "&" is a space)

should not be treated as a comment line as the "C" is in column 7 with 6 spaces before it. So the rule I need is: treat a line as a comment if it has a "C" in column 1 and not as a comment if the line starts with a "C" in columns 7 thru 72.

I hope this makes my problem clearer and that you can help me find a solution.

Thanks!


Iniyen M A [Syncfusion]
Replied On July 14, 2011 09:17 AM UTC

Hi Jim,

Thanks for the update.

You can achieve your requirement by using the following code snippet. Kindly note that if you type 'c' in column 1, then the whole row will be considered as comment line.

[Code Snippet]





Kindly have a look on the following sample which holds the above code snippet.

[Sample]
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=CustomConfig-1090532198.zip

Please let us know if you need further assistance.

Regards,
Iniyen M.A.



Jim Bonomo
Replied On July 14, 2011 07:50 PM UTC

Unfortunately, this does not work either.

If I change your lexem to




it works better but still does not work in all cases.

I am beginning to believe that it is not possible to use regex to do this. I realize that fortran is no longer considered a mainstream language but we use it quite alot and I was hoping to use your control to create my own editor. I believe it is possible to do syntax highlighting for fortran correctly as there are several editor out there the do it. At this point I do not know if it is feasible with your product.

Do you have any other suggestions?



Iniyen M A [Syncfusion]
Replied On July 19, 2011 04:41 AM UTC

Hi Jim,

Thanks for the update.

We have tested your modified code and it is working for the condition you have requested "C this is comment line" and "&&&&&&c this is not comment line" (& - refers space).

Could you please let me know the cases that it is not working. So that we can provide you the respective information accordingly.

We are glad to help you in this.

Regards,
Iniyen M.A.


Jason Sobell
Replied On May 29, 2013 06:11 AM UTC

Well, for starters, the first time you have a non-comment line you can never have another comment line.
Secondly, the code supplied prevents every subsequent lexem working in the config file.

I guess this all comes back to my question; how do you add a rule that detects the start of a line?
Some languages use the line-breaks to denote end of statements, but I can't get anything to detect these properly in a grammar file.

Jason

Paul Anderson S [Syncfusion]
Replied On June 3, 2013 03:38 PM UTC

Hi Jason,

Thanks for the update.

Currently there is no rule presen for detecting the line start in config file. Rather you can achieve your requirement by using the CurrentColumn or Goto() properties and methods in EditControl to detect whether it is a start of line or not.

Please let us know if you have any concerns.

Regards,
Paul Anderson S

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;