Seth Dillingham <[EMAIL PROTECTED]> wrote on 9/11/06 at 2:03 PM:

> There are at least two other supported patterns: one for 
> strings, and one for comments.
> 
> Here's an example string pattern which supports both single and 
> double quotes, and forces strings to stop at the end of the line.
> 
> <key>String Pattern</key>
> <string>(?x:
>      (?&gt;  '   (?s: \\.  | [^'] )*?    (?: ' | $ ) ) |
>      (?&gt;  "   (?s: \\.  | [^"] )*?    (?: " | $ ) )
> )</string>

Thanks for the info on this, Seth.


> The "(?x:" puts the pattern into extended mode (I think that's 
> what it's called), and remember the "(?&gt;" is just the 
> XML-entity version of "(?>" because the above is taken from a 
> .plist XML file.

One thing I've found is that the old-style ASCII plist format is a
lot more readable and writable, especially when specifying grep
patterns. In the ASCII format, you only have to worry about
double-backslashing every backslash, and your quote delimiters. No
need to turn '>' into '&gt;', etc.


> Comments work the same way. Here's a pattern that supports both 
> /* inline */ and // rest-of-line comment syntax:
> 
> <key>Comment Pattern</key>

Are these two constructs, "String Pattern" and "Comment Pattern",
not documented because they're not officially supported yet? Or is
their lack of documentation an omission?

What I'm seeing is that if you use either of these grep-enabled
versions, then BBEdit will ignore any other (non-grep) string or
comment language keys defined in your language module.

For example, consider the following test CLM (this is the ASCII
plist format, by the way, and constitutes the entire "Test.plist"
CLM):

    {
        BBEditDocumentType = CodelessLanguageModule; 
        BBLMColorsSyntax = 1; 
        BBLMIsCaseSensitive = 0; 
        BBLMKeywordList = (); 
        BBLMLanguageCode = Test; 
        BBLMLanguageDisplayName = "Test Language Module"; 
        BBLMScansFunctions = 0; 
        BBLMSuffixMap = ({BBLMLanguageSuffix = ".test"; }); 
        "Language Features" = {
            "Open Strings 1"                = "("; 
            "Close Strings 1"               = ")"; 
            "End-of-line Ends Strings 1"    = 0; 
            "Escape Char in Strings 1"      = ""; 
    
            "Open Strings 2"                = "["; 
            "Close Strings 2"               = "]"; 
            "End-of-line Ends Strings 2"    = 0; 
            "Escape Char in Strings 2"      = "";
        }; 
    }

This CLM does just two things: it colors (parenthesized) and
[bracketed] text as strings.

If I add a "String Pattern" key to the module to also color <angle
bracketed text>, like this:

    {
        BBEditDocumentType = CodelessLanguageModule; 
        BBLMColorsSyntax = 1; 
        BBLMIsCaseSensitive = 0; 
        BBLMKeywordList = (); 
        BBLMLanguageCode = Test; 
        BBLMLanguageDisplayName = "Test Language Module"; 
        BBLMScansFunctions = 0; 
        BBLMSuffixMap = ({BBLMLanguageSuffix = ".test"; }); 
        "Language Features" = {
            "Open Strings 1"                = "("; 
            "Close Strings 1"               = ")"; 
            "End-of-line Ends Strings 1"    = 0; 
            "Escape Char in Strings 1"      = ""; 
    
            "Open Strings 2"                = "["; 
            "Close Strings 2"               = "]"; 
            "End-of-line Ends Strings 2"    = 0; 
            "Escape Char in Strings 2"      = "";
    
            "String Pattern"                = "<.+?>";
        }; 
    }

then, after quitting and relaunching BBEdit to load the change,
the only one of those keys that is effective is the String Pattern
one.

This can be worked around, I suppose, by crafting a single regular
expression that handles *all* of the string formats you wish to
color, but it seems a shame that simple string (and comment)
formats can't be defined using the older, simpler keys, while
still using the new grep-enabled keys to match more complicated
language constructs.

So I guess my questions are, (a) are these keys actually
supported?, and (b) am I right that if you use them, the older
non-grep keys are ignored?

-J.G.

--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>

Reply via email to