BBEdit Language Module for LiveCode

Ben Rubinstein benr_mc at cogapp.com
Mon Dec 22 12:23:06 EST 2014


On 22/12/2014 16:56, J. Landman Gay wrote:
> Wouldn't "if" and "end if" be a code block delimiter? And the same for
"switch" and "end switch"?

"single block delimiter" = one open, one close.

At least that's my understanding.

In theory we could therefore select one block to fold inside functions - but 
in practise the end token would need to include a space (e.g. "end if") and 
elsewhere we've defined the set of characters that can be included in a 
LiveCode token, which does not include a space.  I did experiment with that 
(not for this purpose, but because we can't for the same reason teach BBEdit 
about multi-word keywords, e.g. "is not among the lines of") but it caused a 
lot more problems than it solved.

The para I quoted from the docs 
(http://www.barebones.com/support/develop/clm.html) is followed by this:
> Unfortunately, some languages (such as Python or Ruby) don’t have simple
paired delimiters. Single-token matching does not cover such situations, which 
is one reason BBEdit comes with coded language modules for these languages.

So, if anyone fancied programming a 'coded language module', it can do 
anything, including understanding that 'among the lines of' is a keyword, and 
that 'try' is a block closed by 'end try'... but until then, this is the cheap 
60% solution.


On 22/12/2014 16:56, J. Landman Gay wrote:
> Wouldn't "if" and "end if" be a code block delimiter? And the same for "switch" and "end switch"?
>
> On December 22, 2014 5:28:01 AM CST, Ben Rubinstein <benr_mc at cogapp.com> wrote:
>> It's not possible, I'm afraid.
>>
>> This is a "Codeless Language Module", which works by just declaring
>> keywords
>> and grep patterns.  It's limited in what it can achieve; and in
>> particular the
>> structural elements only work for languages which have a single block
>> delimiter.  Documentation:
>>> Many languages group statements by enclosing them in block delimiters
>> — { … } in C-family languages, or BEGIN … END in Pascal. These keys
>> specify the opening and closing tokens for such blocks. BBEdit detects
>> blocks (even nested ones) and makes it possible to fold them.
>>
>> Unfortunately as LiveCode isn't one of those languages, it's not
>> possible.
>>
>> A long time ago someone-who-I-have-forgotten wrote a full-on Language
>> Module
>> for Revolution (as it then was) - since it was custom coded with a full
>> parser
>> it could do anything.  Unfortunately several versions of BBEdit ago
>> there was
>> an incompatibility which meant that BBEdit crashed as soon as you made
>> a
>> change to a file which this module was applied to; and the latest
>> version of
>> BBEdit won't load it at all.
>>
>> It would still be possible for someone to repeat this task (and
>> arguably since
>> we now have access to the source code of the actual LiveCode parser
>> there
>> might be a place to start) - but I suspect that now that BB have
>> introduced
>> the Codeless Language Modules, its unlikely anyone will feel the the
>> small
>> extra gain is worth the very considerable extra effort.
>>
>> Ben
>>
>>
>> On 21/12/2014 01:06, Brahmanathaswami wrote:
>>> re: "if" and "switch" folding...
>>>
>>> I tried.  in the plist I had added this: under the language features
>> section/dict
>>>
>>> Devin Asay wrote:
>>>> Ben or Swami, do you know if it’s possible to add folding for repeat
>> loops
>>>> and if-then structures? It would sure be nice to collapse log,
>> nested
>>>> if-thens to get a sense of the whole handler or script flow.
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>





More information about the use-livecode mailing list