Do not know if there is a better way, but this script was created to help detect unused tokens in source:
lassign $argv head while { [gets stdin line] >= 0 } { lappend fileLines $line foreach word [regexp -all -inline {[A-Za-z0-9]+} $line] { dict incr wordcount [string tolower $word] } } set fp [open "freq1.html" w] puts $fp "<html>" puts $fp "<head>" puts $fp " <title>Singletons are highlighted</title>" puts $fp " <meta charset=\"utf-8\">" puts $fp "</head><body>" foreach line $fileLines { set text "<pre>" set strLength [string length $line] for {set i 0} {$i < $strLength} {} { if {![string is alnum [string index $line $i]]} { append text [string index $line $i] incr i } else { set word [regexp -inline {[A-Za-z0-9]+} [string range $line $i end]] if {[dict exists $wordcount $word] && [dict get $wordcount $word] == 1} { append text "<span style=background-color:yellow>" $word "</span>" } else { append text $word } incr i [string length $word] } } append text "</pre>" puts $fp $text } puts $fp "</body>" puts $fp "</html>" close $fp
execute with "tclsh freq1.tcl < draftCode.tcl" and all singleton tokens will appear highlighted in context.