Sublime Forum

Looking for help with a LiveCode language package

#1

Hi,

I’m looking for help with fixing issues in a language file I’ve started for LiveCode. I’ve created a repository for it here: https://github.com/trevordevore/livecode-sublimetext. Details follow.

I recently started using Sublime Text and I am really enjoying it. I use the LiveCode development tool and I have started working on a .sublime-syntax file for it as I’m doing the bulk of my coding in Sublime Text now. LiveCode is similar to AppleScript and so I have been pulling parts from the AppleScript package that comes with Sublime Text.

So far my package works for basic files but on more complex files syntax highlighting and handler recognition break part way through the file. I think it has to do with if/then statements but I’m not sure.

One of my public repositories is a LiveCode project. Here is a file that loses syntax highlighting and stops recognizing handlers around line 972:

If anyone has some time to help me out I would really appreciate it.

0 Likes

#2

looks like your syntax definition doesn’t handle ifthen statements where an expression follows the then on the same line, and thus doesn’t require an end if

you can see this on line 36, the scope is source.livecode meta.function.positional.livecode meta.block.if.livecode meta.block.if.livecode when should just be source.livecode meta.function.positional.livecode meta.block.if.livecode

eventually, after enough of these, you end up with a large stack of scopes, that is too large for ST to use to highlight the file.

you can see how the ASP package handles this here:

0 Likes

#3

Thanks @kingkeith. I just tested with an AppleScript file and the language package that ships with Sublime Text for AppleScript has the same problem. The following AppleScript will result in two meta.block.if.applescript entries on line 13:

property defaultClientName : "Mary Smith"
 
on greetClient(nameOfClient)
    display dialog ("Hello " & nameOfClient & "!")
end greetClient
 
script testGreet
    greetClient(defaultClientName)

    if "1" then "2"

    if "2" then "1"

end script
 
run testGreet --result: "Hello Mary Smith!"
greetClient("Joe Jones") --result: "Hello Joe Jones!"

It looks like I should rework my language file based on the ASP one.

0 Likes

#4

Not sure if they solved it better, but I found https://github.com/peter-b/atom-language-livecode/blob/master/grammars/lcb.cson

If you are lucky you can actually find the complete grammar tree of the language. A quick google search did not result in anything viable though. An example would be Javas Language Specification https://docs.oracle.com/javase/specs/jls/se7/html/jls-2.html#jls-2.2

0 Likes

#5

Thanks for the links @thatsIch. I’m familiar with the Atom package as I use Atom for developing Livecode modules (different than the traditional LiveCode language). Yesterday I pulled some of the linter code from the Atom package and put together a linter for SublimeLinter.

With help from @kingkeith there is now a LiveCode package with syntax highlighting. Here are links to the repositories. Both are still a work in progress but I’m using both in my daily development and they are working quite well.

Package:

Linter:

0 Likes

#6

Update: The LiveCode package is now available through Package Control.

https://packagecontrol.io/packages/LiveCode

I have a linter that I’ve submitted tor SublimeLinter3 but it hasn’t been incorporated yet.

0 Likes