I decided to just make my own Lua module, by hacking an existing module and (for now) making up my own UUID. I'm 95% done, but for two (related) issues:
In Lua, you can have a multi-line string delimited by [[ ... ]]. For example:
local theMessage = [[ Hello world How are you doing? ]]
I've got that one covered. However, Lua is tricky and allows you to have nested [[..]] pairs within this block. So, for example:
local theExample = [[ Hello world In Lua, a string can contain nested [[...]] pairs. This includes a case like [[ hi [[ there ]] ]] More string]]
Is it possible to do this? I don't think so in general PCRE, but didn't know if TextMate or Oniguruma had some sweet balancing.
Right now I have: { name = 'string.quoted.multiline.lua'; begin = '(?<!--)[['; end = ']]'; swallow = '[[(.|\r)*?]]|\.'; }, which handles a single pair of [[..]] on the same line inside a block, but doesn't handle multiple nesting or (for reasons I don't understand) handle a single pair across multiple lines. Where can I find more information on the 'swallow' bit?
On Oct 7, 2005, at 11:54 PM, Gavin Kistner wrote:
{ name = 'string.quoted.multiline.lua'; begin = '(?<!--)\[\['; end = '\]\]'; swallow = '\[\[(.|\r)*?\]\]|\\.'; },
{ name = 'string.quoted.multiline.lua'; begin = '(?<!--)[['; end = ']]'; patterns = ( { include = "#nested-string-multiline"; }, ); }, repository = { "nested-string-multiline" = { name = "string.quoted.multiline.lua"; begin = '(?<!--)[['; end = ']]'; patterns = ( { include = "#nested-string-multiline"; }, ); }; };
Of course you could just make that into one repository item and make it even simpler...
On Oct 8, 2005, at 12:08 AM, Michael Sheets wrote:
{ name = 'string.quoted.multiline.lua'; begin = '(?<!--)[['; end = ']]'; patterns = ( { include = "#nested-string-multiline"; }, ); }, repository = { "nested-string-multiline" = { name = "string.quoted.multiline.lua"; begin = '(?<!--)[['; end = ']]'; patterns = ( { include = "#nested-string-multiline"; }, ); }; };
Tricky! Is there more documentation on the repository and patterns/ include items?
I'll try to see if I can re-use that cleanly with the --[[ ... [[ ... [[ .. ]] .. ]] .. ]] multi-line block comment, also.
Thanks :)
On 08/10/2005, at 22.30, Gavin Kistner wrote:
Tricky! Is there more documentation on the repository and patterns/ include items?
Help -> Syntax Highlight mentions it.
There's also this more tutorial style entry: http://macromates.com/ blog/archives/2005/06/23/language-grammars/
On 08/10/2005, at 10.39, Allan Odgaard wrote:
On 08/10/2005, at 6.54, Gavin Kistner wrote:
begin = '(?<!--)\[\[';
If the negative look-behind on “--” is to avoid “[[” in a comment, then just make a rule to match “--.*$” (or similar) and you won't need to resort to look-behind etc.
That's be begin = "--[[" for a multi-line comment with the same nesting as Michael Sheet showed (I seem to recall that multi-line comments can have some sort of nesting!?!)
On Oct 8, 2005, at 2:45 AM, Allan Odgaard wrote:
On 08/10/2005, at 10.39, Allan Odgaard wrote:
On 08/10/2005, at 6.54, Gavin Kistner wrote:
begin = '(?<!--)\[\[';
If the negative look-behind on “--” is to avoid “[[” in a comment, then just make a rule to match “--.*$” (or similar) and you won't need to resort to look-behind etc.
That's be begin = "--[[" for a multi-line comment with the same nesting as Michael Sheet showed (I seem to recall that multi-line comments can have some sort of nesting!?!)
Correct - Lua multi-line comments start with "--[[" and end with "]]", and (like multi-line strings) can contain nested [[ .. ]] pairs.