Announcement

Collapse
No announcement yet.

Debugging replacements

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • Debugging replacements

    I've created several replacements. Most of them work, but a few do not. I suspect the problem is that there is an error in those replacement definitions (I often use regex replacements so there's lots of potential for errors in the replacement definitions.) How can I debug replacements? Is there a way to get BC3 to display its replaced text buffer instead of the actual text?

  • #2
    Originally posted by slessard
    How can I debug replacements?
    You can test your regular expressions using the Search > Replace command.

    FYI, the View > Aligned Details command added in BC3.2 exposes the character alignment.

    Regards,
    Erik Scooter Software

    Comment


    • #3
      I already use RegexBuddy (a very powerful regex IDE) to debug my regular expressions. But debugging regular expressions is only a small piece of a larger debuggability problem. Grammar rules appear to have an order of precedence as do Replacement rules and it's not clear what the order of precedence is between Grammar rules and Replacement rules.

      Bottom line is that I have about 15 grammar rules and about 20 replacements rules. Based on my understanding of those rules and how they work some of the stuff I expect to match is not matching so I want to debug it all. How can I do that?

      Comment


      • #4
        I believe that grammar rules and replacements both short circuit. In other words, the list of rules are processed from top to bottom and when a match is found, BC looks no further.

        I also believe that grammar rules and replacement rules are processed independently from each other and only apply to the original text. In other words, modifying text with a replacement rule will never cause it to match a different grammar rule. Replacing sometext with "sometext", for example, will not cause syntax highlighting to color sometext as a quoted text string value.
        BC v4.0.7 build 19761
        ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

        Comment


        • #5
          Hello,

          The main factor is probably that the grammar list is not a strict priority list. Each line is searched for any of the matching grammar items, not necessarily in the order of the list. If a tie is found, the list is used to break the tie, but otherwise a grammar that is more to the left can be picked even if it is below in the grammar list.
          Aaron P Scooter Software

          Comment

          Working...
          X
          😀
          🥰
          🤢
          😎
          😡
          👍
          👎