Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2018
    Posts
    4

    Default Delimited Grammar matches when end delimiter not present

    Hello,

    I'm running Version 4.2.6 (build 23150) on MacOS High Siera (10.13.6) and I'm running into an issue with creating a Delimited Grammar to match across multiple lines.

    I want to match a <version> field only when nested directly inside a <parent> tag an as such I've defined the Delimited Grammar as follows:

    Text From: <version>
    To: </parent>

    Unfortunately it's matching any line with <version> in it, not just ones that have a </parent> following. I can confirm the behaviour by changing the 'To:' value to "never going to match anything" and yet it still matches the <version> line even when the 'To:' delimiter is not present in the file.

    See attached.

    Please advise.

    If multi-line regex were supported I could achieve this even better, but I at least thought a Delimited Grammar would help, but unfortunately not.

    Thanks,
    Dan

  2. #2
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    4,714

    Default

    Sorry, there isn't a good solution in the current version of Beyond Compare.

    A delimited grammar starts as soon as the "Text From" is matched. It ends when the "To" text is matched or at end of file.

    Nested grammar elements are on the feature wish list for a future version.
    Chris K Scooter Software

  3. #3
    Join Date
    Sep 2018
    Posts
    4

    Default

    Thanks for the quick reply Chris, but surely this is not an additional feature, but a bug with the current Delimited Grammar functionality?

    The amount of false positives/negatives that can arise from only matching on the start delimiter and just expecting to receive the end delimiter and selecting everything until then can be huge (it is in my case).

    I'm really struggling here. All I want to do is match a text block across multiple lines, and neither the regex option works (as it doesn't support multiline) or the Delimiter version work (since it matches false positives with no end delimiter present).

    What sort of support options are there available to resolve this? I've been a paid customer for many years but I'm concerned there's little I can do about bugs that have a large impact on my use of the tool. This tool is a mature product, being available for many many years, so I'm struggling with how this sort of bug or use case can be left unfixed with no resolution in sight.

    I'd appreciate any assistance available.

  4. #4
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,826

    Default

    Thanks for the feedback; we can investigate that option for the delimited grammar type, but that is not supported in the current version. If an unterminated grammar occurs, this will often show the rest of the file as different, since a difference in grammar counts as a difference even if the text appears equal. One side would be the unterminated grammar, while the other would be terminated, creating this difference between Left and Right starting at the beginning of the Delimited Grammar. This is usually a difference to resolve and fix by adding the terminator.
    Aaron P Scooter Software

  5. #5
    Join Date
    Sep 2018
    Posts
    4

    Default

    I can see in some situations having a missing end terminator would be a syntax error, but in a lot of cases, the start delimiter may be ambiguous by itself and so it should only match if both start and end delimiter are present.

    However, saying all that, the most valued improvement would be to support multi-line regex matching, as this would be SO flexible. Here's another example I ran into today that I want to match as a grammar so I can mark as unimportant, these copyright headers have been added in a newer codebase I'm comparing, but they are definitely minor changes since they don't affect functionality. Therefore I'd like to mark them as minor:

    Code:
    /**
     * Copyright (c) Example Inc., 2018
     */
    With a multi-line regex I could accomplish this quite easily, even though the regex would be a little tricky to read.

    With a Delimited grammar, it would be hard here because I want to match based on the middle of the comment (but match the entire block since the whole block is new).

    This above example is a great use case in my opinion for developing a solution using multi-line regex as that would be a really helpful solution I bet.
    Last edited by DanR; 07-Sep-2018 at 04:17 PM.

  6. #6
    Join Date
    Sep 2018
    Posts
    4

    Default

    I guess in response to my post, I can just simply use the Comment grammar and mark all comments as minor. So I'm unblocked again.

    Point still stands on how multi-line regexes would be a great solution to these sorts of things (xml, json files etc matching multi-line elements in a file).

  7. #7
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    4,714

    Default

    Thank you for all the great suggestions. Multi-line regexes are on the wish list for a future version. I've passed all your feedback on to our developers, we appreciate it.
    Chris K Scooter Software

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •