Village Pump:Home/Syntax Highlighting ( archived 2009-06-18 ): Difference between revisions

→‎Highlighting of Tcl: reorganize for better readability, and state what the comment RE should be.
(→‎Highlighting of Tcl: reorganize for better readability, and state what the comment RE should be.)
Line 307:
 
==Highlighting of [[Tcl]]==
===Braces aren't comments===
Is it possible to change the highlighting of Tcl so that sequences where there is an open and close brace on the same line are not highlighted as (presumably) comments? This makes expressions and one-liners much more difficult to read than they otherwise would be. For example, this is a one line <tt>if</tt>:
<lang tcl>if {[incr $a] == [list $b $c]} {puts [$d $a]} {error "$e $a"}</lang>
It's probably best for “{…}” to be not treated specially at all. (At some point we could also do with updating the list of ”keywords”, but that's nothing like as important.) —[[User:Dkf|Dkf]] 09:07, 22 May 2009 (UTC)
:Thanks for fixing this. —[[User:Dkf|Donal Fellows]] 14:34, 17 June 2009 (UTC)
:The current list of "keywords" for Tcl 8.6 (which is quite a bit longer than for previous versions) is:
===Keywords===
::'''Normal Keywords:''' append apply bgerror break catch cd class close concat constructor continue copy define deletemethod destructor else elseif eof error eval exec exit export expr fblocked fconfigure fcopy fileevent filter finally flush for foreach format gets glob if incr join lappend lassign lindex linsert list llength load lrange lrepeat lreplace lreverse lsearch lset lsort mixin my next objdefine object on open parray pid puts pwd read regexp regsub rename renamemethod return scan seek self set socket source split subst superclass switch tell then throw time trap try unexport unload unset uplevel vwait while
:The current list of "keywords" for Tcl 8.6 (which is quite a bit longer than for previous versions) is:
::'''Function Definition Keywords:''' create forward method new proc
::'''Normal Keywords:''' append apply bgerror break catch cd class close concat constructor continue copy define deletemethod destructor else elseif eof error eval exec exit export expr fblocked fconfigure fcopy fileevent filter finally flush for foreach format gets glob if incr join lappend lassign lindex linsert list llength load lrange lrepeat lreplace lreverse lsearch lset lsort mixin my next objdefine object on open parray pid puts pwd read regexp regsub rename renamemethod return scan seek self set socket source split subst superclass switch tell then throw time trap try unexport unload unset uplevel vwait while
::'''Variable Definition Keywords:''' global upvar variable
::'''Function Definition Keywords:''' create forward method new proc
::'''Compound Keywords:''' after array binary chan clock dde dict encoding file info interp namespace package prefix registry string trace update zlib
::'''Variable Definition Keywords:''' global upvar variable
:(With compound keywords, the word after the listed keyword should also be highlighted.) OK, they're not formally keywords, but they should be formatted like they are. Also, “{...}” is ''never'' an indication of a comment, and “$” followed by alphanumerics should be formatted as a variable reference. —[[User:Dkf|Donal Fellows]] 09:58, 17 June 2009 (UTC)
::'''Compound Keywords:''' after array binary chan clock dde dict encoding file info interp namespace package prefix registry string trace update zlib
::The following words are linkable to <code><nowiki>http://www.tcl.tk/man/tcl8.6/TclCmd/</nowiki>''blah''<nowiki>.htm</nowiki></code>:
:(With compound keywords, the word after the listed keyword should also be highlighted.) OK, they're not formally keywords, but they should be formatted like they are. Also, “{...}” is ''never'' an indication of a comment, and “$” followed by alphanumerics should be formatted as a variable reference. —[[User:Dkf|Donal Fellows]] 09:58, 17 June 2009 (UTC)
:::proc global upvar variable after append apply array bgerror binary break catch cd chan clock close concat continue dde dict encoding eof error eval exec exit expr fblocked fconfigure fcopy file fileevent flush for foreach format gets glob if incr info interp join lappend lassign lindex linsert list llength load lrange lrepeat lreplace lreverse lsearch lset lsort my namespace next open package parray pid prefix puts pwd read regexp registry regsub rename return scan seek self set socket source split string subst switch tell throw time trace try unload unset update uplevel vwait while zlib
::The following words are linkable to <code><nowiki>http://www.tcl.tk/man/tcl8.6/TclCmd/</nowiki>''blah''<nowiki>.htm</nowiki></code>:
::Alternatively go to <code><nowiki>http://wiki.tcl.tk/</nowiki>''blah''</code> for any identified keyword and, if the page isn't there now it soon will be... ;-) (and thanks for fixing the oneliner highlighting) —[[User:Dkf|Donal Fellows]] 14:14, 17 June 2009 (UTC)
:::proc global upvar variable after append apply array bgerror binary break catch cd chan clock close concat continue dde dict encoding eof error eval exec exit expr fblocked fconfigure fcopy file fileevent flush for foreach format gets glob if incr info interp join lappend lassign lindex linsert list llength load lrange lrepeat lreplace lreverse lsearch lset lsort my namespace next open package parray pid prefix puts pwd read regexp registry regsub rename return scan seek self set socket source split string subst switch tell throw time trace try unload unset update uplevel vwait while zlib
::Alternatively go to <code><nowiki>http://wiki.tcl.tk/</nowiki>''blah''</code> for any identified keyword and, if the page isn't there now it soon will be... ;-) (and thanks for fixing the oneliner highlighting) —[[User:Dkf|Donal Fellows]] 14:14, 17 June 2009 (UTC)
===Variables===
A “$” followed by alphanumerics should be highlighted as a variable reference (if you highlight such things in other languages, of course). —[[User:Dkf|Donal Fellows]] 14:34, 17 June 2009 (UTC)
===Comments===
The comment regexp should (probably) be:
(?:^|[[{;])[ \t]*(#[^\n]*)
(However that is encoded in PHP, I don't know.) It doesn't handle multi-line comments but we're not really using those on RC anyway. —[[User:Dkf|Donal Fellows]] 14:34, 17 June 2009 (UTC)
 
==Java5 messed up==
Anonymous user