Announcement

Collapse
No announcement yet.

Grammar Item Highlighting and Item Precedence

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Grammar Item Highlighting and Item Precedence

    If, within a given text format, there are grammar items with partially overlapping definitions, is there any way to specify which ones have precedence when assigning color syntax highlighting? Reordering the grammar items does not seem to affect the outcome.

    Here is my situation (build 456):

    Item 1) Standard Line Numbers Syntax Highlight - column 73 - 80

    Item 2) Standard Line Numbers Unimportant - regexp (\s*)|(\s*[0-9]{8})|([0-9]{8})$ (more than one minor variant of this regexp yields the same ignore results - I just picked the last one I used).

    I want to highlight item 1 text with both foreground and background shades. I want to leave item 2 text with default shades so that I won't highlight the background of the "trailing" whitespace before the numbers. No matter which order I specify items 1 and 2, the standard numbers will not highlight. If I delete item 2, then highlighting occurs. If I delete item 1 and specify highlighting for item 2, then "trailing" whitespace is highlighted along with the numbers.

    In the session settings, item 2 is unimportant. I cannot simply specify just Item 1 for both syntax highlighting and unimportant text because specifying Item 1 then introduces "trailing" whitespace up through column 72 which BC interprets as embedded whitespace - and I don't want ignore embedded whitespace.

    Any help is appreciated,

    Jerry

  • #2
    Feedback Requested

    Any ideas from the Scooter Team?

    Comment


    • #3
      Sorry for not responding to your question when you originally posted it.

      Grammar items only overlap if they match the same text. If the same text is matched, the grammar item that matches the most characters is used. If both grammar items match the same number of characters, then the first item in the list is used.

      As an example, have the first grammar in the list match the word "apple". The second grammar item in the list matches the word "applesauce". If your file has the text "applesauce", the second grammar item is used because it matches more characters than the first grammar item.

      In your example, the second item matches more characters, so it will always be used unless a line has a non-whitespace character in column 72.

      I'll do some testing to see if I can create a file format that does what you describe and then post a follow up to this thread.
      Chris K Scooter Software

      Comment


      • #4
        This is a tricky problem. It isn't possible for grammar elements to overlap, so you'll need something to match the whitespace before the line numbers without matching on the line numbers.

        If you only have one or two whitespace characters in the text you want to ignore, and more whitespace characters in the trailing whitespace before the line numbers, you could use a regular expression like "\s{4,}". This will match on any set of 4 or more white space characters.
        Chris K Scooter Software

        Comment

        Working...
        X