Sublime Forum

Debugging bad sublime-syntax

#1

On occasion I end up writing a bad pattern – or perhaps a bad context sequence? – causing recursion. Though the file saves and appears ‘valid’ it will cause Sublime to hang (and if I don’t get to that X fast enough, the operating system, too). This isn’t a bug in Sublime or anything, it’s means there’s a bug in my syntax file – but I’m wondering what I can do to suss out the offending parts? When my syntax file was smaller, it was possible to extract or comment-out chunks to track something down. Now that it’s large it seems nearly impossible to trace sometimes because of the interdependence of contexts. Are there any other tools or techniques to figure out where it recursed (assuming that’s what’s happening at all)?

0 Likes

#2

From what I understand, testing will be possible with the new YAML syntax definitions.

0 Likes

#3

Thanks. I saw that there was an adjunct testing language. I have a feeling – though I haven’t tried yet – that it won’t help me with the hanging problem. At this point I’ve rewritten mostly from scratch six times and I always inevitably run into it. Only once was I able to localize it, but I couldn’t fix it. I couldn’t find anything wrong with the context definition. Of course I may just not understand what to look for, but I tried many variations and rewriting the whole section several times and it would always be a snag point. I decided to ignore that part and move on with everything else, but then I would just hit it again with something new (which I couldn’t identify).

:cry:

I’m sad to say that after a week of obsessing over this that I think I have to give up (for now). I’ve been starting to wonder if, in some cases, what I’m encountering is a bug that isn’t my own. Not sure of course – it’s probably me – but the consistency with which I hit this wall on each try has made me uncertain enough that I’m worried I’m trying to do things that are currently impossible (possibly by design – maybe I have the wrong idea altogether). It is a new feature after all, and not even in the regular release, so if I hold off a while, once more people have started messing and releasing working sublime-syntax files I’ll be able to look at them and go “doh” and tackle it with a new approach.

0 Likes

#4

BTW, if it will help anyone else, I can supply what I’ve written. The approach I’d taken was to follow formal syntax definitions fairly closely so that I could achieve very accurate matches and ensure full coverage. That meant a lot of linear sequences and some sneaky patterns with a generally small context stack (transitions to siblings more than children, so that at any point if I hit an “invalid” token I could pop and recover gracefully without being as likely to create a cascade effect from malformed code). Pieces of it work beautifully with both valid and invalid code, achieving things tmLanguage never allowed, but whenever I get enough parts together in one file and everything is interconnected, that’s when I typically hit the wall. It could be that this sort of “fake parsing” approach is what’s getting me in trouble, but on the other hand the parts that work don’t seem laggy or anything.

0 Likes