Fortran file format

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • deltaiv
    Visitor
    • Jul 2012
    • 6

    Fortran file format

    Hi,

    is there a Fortran 77 file format for Beyond Compare? I looked at the C/C++ one, but comments here are indicated by symbols that can be placed everywhere in the line. In f77, instead, comments are indicated by a C in column 1. If the C appears in column 16, for example, it doesn't indicate a comment. Awkward, indeed, but that's how it works...can you help me? Thanks,

    Best Regards

    Sergio
  • Aaron
    Team Scooter
    • Oct 2007
    • 16000

    #2
    Hello,

    We do not have a Fortran 77 file format, but BC3 does allow for the creation of custom file formats with user defined Grammar elements. Here is a KB article that goes into detail on how to define custom grammar elements and then mark them as Unimportant.
    http://www.scootersoftware.com/suppo..._unimportantv3

    You can use pre-existing names, such as "Comment" when creating a new element instead of the default name "New Element" if it matches that concept. All grammar elements named Comment are then treated with the same importance in the Session Settings and color settings in the Tools menu -> Options dialog. Alternatively, you can create new names for your grammar elements if they are a new concept.
    Aaron P Scooter Software

    Comment

    • deltaiv
      Visitor
      • Jul 2012
      • 6

      #3
      Hi, Aaron,

      thanks for the reply. I'm trying to build my Fortran grammar. How do I create a rule which says that a line beginning with C, or c, or *, is a comment? Would

      Comment=Text matching ^[Cc*]

      do it? Also, is there a way to tell BC to colour the comment line green, or some other user-defined colour?

      Thanks again

      Sergio

      Comment

      • deltaiv
        Visitor
        • Jul 2012
        • 6

        #4
        Ok, it doesn't work. The correct rule is:

        Comment=Text from ^[Cc*] to end of line

        The question about how to modify the highlitghing colours still applies, though

        Up to now I've been able to match comments, keywords, strings, identifiers and numbers. Lookin' good, lookin' good...

        Sergio

        Comment

        • Aaron
          Team Scooter
          • Oct 2007
          • 16000

          #5
          How about a new grammar element, type Delimited, that matches on:
          ^c
          to
          (leave blank)
          and enable "Stop at End of line" and "Regular Expression"?
          Aaron P Scooter Software

          Comment

          • Aaron
            Team Scooter
            • Oct 2007
            • 16000

            #6
            Hello,

            Custom coloring (including our defaults) is controlled in the Tools menu -> Options, File Views, Display section. Each grammar name appears in the Elements list, and can be customized.

            Edit: So, if you name your element Comments, it will have the same coloring as all other Comments in any other format (which, we have defined by default in a few). If you give it a custom name, like Fortran Comment, that custom name will appear here.
            Last edited by Aaron; 18-Jul-2012, 09:18 AM. Reason: Edit
            Aaron P Scooter Software

            Comment

            • deltaiv
              Visitor
              • Jul 2012
              • 6

              #7
              > How about a new grammar element, type Delimited, that matches on:
              > ^c
              > to
              > (leave blank)
              > and enable "Stop at End of line" and "Regular Expression"?

              Hi, Aaaron,

              good point: in meantime, I found out that a FORTRAN comment can start with C, c or *. So I think I should modify your suggestion to (please correct me if I'm wrong):

              type Delimited, matches on:
              ^[Cc\*]
              to
              (leave blank)
              and enable "Stop at End of line" and "Regular Expression"?

              I could also just match on ^[C\*], and disable "this element is case sensitive", but I think that explicitly showing which characters are to be matched in the regular expression, makes my rules more immediately readable.

              Thanks also for the answer on custom coloring. I see that in the same menu, the Editor font can also be changed. Does this affect also the HTML report?

              On a side note, impressive piece of software. It beats hands down all the other file comparison tools I've used up to now

              Comment

              • deltaiv
                Visitor
                • Jul 2012
                • 6

                #8
                Hmmm,

                something is not working here. I used your suggestion for the Comment element. Now, I have two files A and B, and the following line is present in file A only:

                c200 CONTINUE

                Since Comments are by default Unimportant (Session Settings\Importance), the line should be colored blue, instead it's colored red. Is this a bug? Thanks,

                Best Regards

                Sergio

                Comment

                • Aaron
                  Team Scooter
                  • Oct 2007
                  • 16000

                  #9
                  Hello,

                  Yes, that grammar looks like it would work. Another strategy would be to have multiple grammar elements with the same name "Comments", and each can be defined separately. Such as:
                  ^C to end of line
                  ^c to end of line
                  ^\* to end of line

                  If they all have the same name, the unimportance lists the name once. Obviously, C and c can be handled with the Case Sensitive option, but this is just to show it could be done.

                  The color should show up in the HTML color reports. Are you not seeing this behavior?
                  Aaron P Scooter Software

                  Comment

                  • Aaron
                    Team Scooter
                    • Oct 2007
                    • 16000

                    #10
                    Is the grammar element name unchecked in the Importance tab? You can click your mouse cursor into the word (ex: between the c and the 2 characters) and look in the bottom status bar of the pane. It should show the currently detected grammar name. This will let you know if the correct/expected element is found.
                    Aaron P Scooter Software

                    Comment

                    • deltaiv
                      Visitor
                      • Jul 2012
                      • 6

                      #11
                      Hi Aaron,

                      I found a grammar that works fine, shown in the image attached. Slowly but surely, I'm developing a full Fortran grammar

                      Comment

                      • AMSwain
                        Visitor
                        • Jun 2014
                        • 4

                        #12
                        I tried specifying:

                        ^C to end of line

                        It does not seem to work when I specify this as a "Comment". I made sure comments were un-checked in the Rules/Importance box.
                        In "Grammar Item" is it important to pick the right "Category"

                        Using BC4

                        AMSwain

                        Comment

                        • Aaron
                          Team Scooter
                          • Oct 2007
                          • 16000

                          #13
                          Hello,

                          It would probably be best to email us at [email protected] with an export of the format or your full BCSupport.zip (Help menu -> Support; Export), with a pair of sample files, and we can take a look why the grammar isn't detecting. Please include a link back to this forum thread for our reference.

                          Common issues are another grammar that also matches on the same section or surrounding section that swallows the definition. Or if you defined a regular expression but accidentally missed enabling the Regular Expression option in the grammar element. If you click the cursor into the text area, the bottom status bar will show the detected grammar item.

                          In case it helps, we have a full walkthrough/video guide for defining a grammar and marking it as unimportant here:
                          http://www.scootersoftware.com/suppo..._unimportantv3
                          Aaron P Scooter Software

                          Comment

                          Working...