Ignore lines with a word or phrase with spaces in it?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KVS
    Visitor
    • Feb 2018
    • 6

    Ignore lines with a word or phrase with spaces in it?

    I set up a phrase to ignore a symbol in C code (.c file) with an underscore in it.

    This works

    .*SYMBOL_WITHUNDERSCORE.*

    Basic, match case, regular expression

    The entire line (the latter part of which contains the ignorable variance) works.

    I tried it with a phrase with a space in it, and it doesn't work.

    I tried it with a symbol without an underscore in it...and it doesn't work???



    To put it bluntly, I want to ignore an entire line that is described classically as having *SYMBOL* in it. Or even more simply, SYMBOL is in the line somewhere.


    There are no confusing issues here. I just want to ignore lines with that. Don't care if it's embedded inside another symbol, or abuts spaces, commas, tabs, anything. If that symbol is in that line, ignore the line.
  • Aaron
    Team Scooter
    • Oct 2007
    • 15997

    #2
    Hello,

    Defining a grammar surrounded by .* and .* is a simple Regular Expression to ignore the entire line if there is a symbol in it. At that point, you need to make sure the "symbol" is defined correctly so it'll match, and also that the symbol definition is not within a larger grammar definition that swallows it. Grammar searching has some complex logic to finding matches quickly, but you can click into the symbol text (blinking cursor) to see what the current grammar is detecting as in the bottom status bar of each pane. This should show your current Grammar Element Name, and if not, which is it showing (and does it make sense that it would match that)?

    Reordering the grammar elements in the file formats can help break 'ties', but if a larger element is found and swallows the entire smaller element, you'll need to alter the larger element or delete it to avoid it matching instead of your Symbol grammar element.
    Aaron P Scooter Software

    Comment

    • KVS
      Visitor
      • Feb 2018
      • 6

      #3
      Some text inside comments are important for differences, and other text not?

      Thank you.

      When I looked a seventeenth time, I realized this text was inside a multi-line /* */ comment, and "comment" was flagged as important under session settings, so pressing the "ignore unimportant differences" button didn't make it be blue unimportant, as would normally happen with a comment by default.

      In any case, the line I was trying to create was perfectly accurate, it's just that it doesn't apply inside of a block comment, which in turn overrode the "ignore unimportant differences" button because it was checked as important in session settings.

      I had turned on comment differences are important precisely because I wanted to look for differences inside comments.

      I haven't experimented with deleting the "comment" entry in session settings.
      However, can I do this: Ignore particular lines inside comments while finding other comment differences important?

      Comment

      • Aaron
        Team Scooter
        • Oct 2007
        • 15997

        #4
        No, grammars do not support multi-level or conditional definitions. You would have to remove the larger grammar element from the format to help this case. If needed, you can create a clone of the current format (Tools menu -> File Formats, select and Save As). Each version could have slightly different grammar elements, and whichever if the topmost on the list is the one used automatically; the other is selected manually after opening files.
        Aaron P Scooter Software

        Comment

        • KVS
          Visitor
          • Feb 2018
          • 6

          #5
          Originally posted by Aaron
          No, grammars do not support multi-level or conditional definitions. You would have to remove the larger grammar element from the format to help this case. If needed, you can create a clone of the current format (Tools menu -> File Formats, select and Save As). Each version could have slightly different grammar elements, and whichever if the topmost on the list is the one used automatically; the other is selected manually after opening files.

          Here's a use case where that is valuable: Generated code.


          Do: (Optionally) ignore timestamps, certain hex values, and so on inside comments.

          Don't: Ignore other comment differences, which from time to time happen due to updates to the code generator, or changes in the code generator configuration or inputs.



          When integrating generated code, you want to carry over the timestamp inside comments, other blabber, and so on. But later on, when verifying a re-generation to see differences, you don't want to see that and just want to see code diffs and non-timestampy things inside comments.

          These can lead to removing hundreds of red diffs inside a single file compare, depending on what the code generator does for individual function comments and massive data array initializations.
          Last edited by KVS; 27-Feb-2018, 01:19 PM.

          Comment

          • Aaron
            Team Scooter
            • Oct 2007
            • 15997

            #6
            Hello,

            Conditional or multi-level definitions is something on our wishlist, but not something BC4 supports in the current version. I'll add your notes to our entry on the subject.
            Aaron P Scooter Software

            Comment

            Working...