In Lua,
                -- Line comments look like this.
                --[[    and
                        block comments
                        look like this. ]]

Experimenting with PCRE in the Find dialog, I've determined that the PCRE
                (?s)(?<!-)--(\[\[)?(?(1).*?\]\]|.*?$)
detects both kinds. Yes the initial assertion, that block comments should begin with two hyphens, but not three, is necessary. Luanists will turn a block comment off by adding a third hyphen, turning "--[[" into "--""-[[", which line-comments the open-block out.

To clarify, the rest of the regex detects the [[. If it's there, it includes everything through the next ]]. If not, it only matches to the end of the line.

This pattern works in Find, and doesn't seem to spin.

In order to fit into an XML property list, the regex has to be altered, to turn the < into a &lt; :
      <key>Comment Pattern</key>
      <string>(?s)(?&lt;!-)--(\[\[)?(?(1).*?\]\]|.*?$)</string>

This doesn't work. Line comments are correct, and block comments are treated as line comments.

While writing this, I thought of another pattern:
                (?s)((--\[\[)|(--))(?(2)(.*?\]\])|(.*?$))
which looks for --[[ or -- (greed should prevent reading --[[ as --), and finishing out the comment conditionally as before. This one has no < in it. It works accurately in Find.

It doesn't work in the CLM. This time, the first line comment is extended through the next ]].

Am I missing something?

        — F


--
------------------------------------------------------------------
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