Sublime Forum

Nested paranthesis matching fails with Tcl syntax

#1

I often experience issue with nested paranthesis matching with Tcl syntax in ST.
I tried to brake it down to a simple example:

set list_of_lists [list {test1 test2} {{test3 arg1 arg2} test4}]

None of the paranthesis above are matched.

It would be cool, if somebody could look behind the scenes and see what’s happening there.

Many thanks
Alexandru

0 Likes

#2

ST’s Tcl syntax definition uses various heuristics to guess what type a token might be of as the dynamic nature of the language makes it impossible to reliably highlight it by a static/stateless single-run syntax highlighting engine such as TextMate’s or ST’s one.

In the given example {test1 test2} is scoped as literal string. Same happens to {{test3 arg1 arg2}. As the syntax definition doesn’t take nested braces into account, the string stops at the first closing brace.

You’d need to add spaces to get them highlighted as normal braced expressions.

set list_of_lists [list { test1 test2 } { { test3 arg1 arg2 } test4 }]
0 Likes

#3

Thanks! While I’m thankfull for the workarround, it forces to me tu use a style, that I don’t like. Tcl makes alot use of currly braces not only for lists but also for IF, WHILE, FOR constructs. And I always don’t use empty spaces after an opening brage or before a closing brace. That’s a stile thing.
I hope, this issue is recognized as such and maybe the logic can be improved.

0 Likes

#4

TCL is more or less unmaintained at the moment. So it’s unlikely something changes anytime soon.

I’ve made an attempt to improve the syntax years ago, but gave up as more and more issues came up the more I digged into it.

0 Likes