sublimehq / Packages

Syntax highlighting files shipped with Sublime Text and Sublime Merge
https://sublimetext.com
Other
2.95k stars 587 forks source link

[TCL] Inline comment for syntax wrong implementation #1837

Open Meshparts opened 5 years ago

Meshparts commented 5 years ago

In Tcl, # is the comment sign at the begining of a line. # This is a Tcl comment

If I want inline comments, the user must end the line with ; and then write the comment: # Define a variable "v" = 10 and write a comment at the end of the line: set v 10; # this is variable v

At the same time, the actual comment sign can be part of the variable definition, or other expressions:

# this is a valid variable: set #v 10

Unfortunately, ST does not know about those things. The syntax highlighter shows everything after the # in the above expression as an comment, which is anoying.

deathaxe commented 5 years ago

As other old syntaxes TCL suffers from a couple of issues.

I started reworking TCL with current concepts and possibilities of ST months ago to address all the open issues in this repo, but already almost gave up in December '18 when I came to try to find a solution to highlight the foreach function. It is unable for ST's lexer to decide, which braces contain variables, expressions or contain statements. Even counting braces doesn't work as foreach can have any number of iterator/pattern pairs. Horrible.

It is nearly impossible to provide a good experience.

It is a chaotic language. It consists only of 12 language rules which are promoted to make the language simple, but it's just anarchy. Each command can interpret its parameters as wanted. No consistent set of rules to apply generally. We need to count braces and brackets to guess what they might want to mean. You need to do so for each command on its own.

I don't use that language my own, and I can't understand anybody does.

Meshparts commented 5 years ago

This answer doen't help. But anyway, even it is off topic, I would like to show an example where this sentence is true: "Even counting braces doesn't work as foreach can have any number of iterator/pattern pairs."

deathaxe commented 5 years ago

My current state of work about TCL can be found at https://github.com/deathaxe/Packages/tree/wip-tcl-rewrite. You may have a look into the TCL folder of that branch.

It is just a intermediate state, which is IMHO still a bit messy and needs more work.

Meshparts commented 5 years ago

I'll take a look. I asked the Tcl community about their opinion regarding these issues in ST and the answer ist basically, that you cannot fully implement Tcl syntax in ST, because it is statical. Tcl instead has a dynamic, context dependent syntax. If you want to read more: https://groups.google.com/forum/#!topic/comp.lang.tcl/pWmrd35jOEI

On the other side, I mostly have only few issues in ST with Tcl. One of those is described in the original post. I think, this issue can be solved in ST.

deathaxe commented 5 years ago

Your issue and a couple more are actually in the linked wip branch. Came to the same result with regards of fully supporting that syntax seems impossible. Maybe most general use-cases can though.

Bogdan107 commented 2 years ago

Geany correctly highlight the code "set #v 10". May be Sublime-Text use the part of syntax highlighting code from Geany?

deathaxe commented 2 years ago

Geany uses scintilla, the same text editor engine which powers Notepad++. Scintilla's syntax highlighting relies on lexers written in C++. As it works fundamentally different, nothing of it can be re-used in ST.