mirror of
https://github.com/cheat/cheat.git
synced 2024-11-16 08:58:28 +01:00
55b18b4897
commit 95479c8ad744db48386a5c78e54ef8da80e9120b Author: Chris Lane <chris@chris-allen-lane.com> Date: Wed Apr 28 12:26:32 2021 -0400 chore(version): bump version to 4.2.1 commit6956f51cae
Author: Chris Lane <chris@chris-allen-lane.com> Date: Wed Apr 28 12:24:21 2021 -0400 fix(Makefile): `vendor-update` Update the `vendor-update` build target to run `go mod vendor` after updating dependencies. commit0aca411279
Author: Chris Lane <chris@chris-allen-lane.com> Date: Wed Apr 28 12:23:24 2021 -0400 chore(deps): update dependencies commite847956b02
Author: Chris Lane <chris@chris-allen-lane.com> Date: Wed Apr 28 08:26:51 2021 -0400 chore(deps): build updates - Upgrade `go` to `1.16.3` - Attempt to fix build errors regarding dependencies
120 lines
7.2 KiB
Go
120 lines
7.2 KiB
Go
package t
|
|
|
|
import (
|
|
. "github.com/alecthomas/chroma" // nolint
|
|
"github.com/alecthomas/chroma/lexers/internal"
|
|
)
|
|
|
|
// Tcl lexer.
|
|
var Tcl = internal.Register(MustNewLazyLexer(
|
|
&Config{
|
|
Name: "Tcl",
|
|
Aliases: []string{"tcl"},
|
|
Filenames: []string{"*.tcl", "*.rvt"},
|
|
MimeTypes: []string{"text/x-tcl", "text/x-script.tcl", "application/x-tcl"},
|
|
},
|
|
tclRules,
|
|
))
|
|
|
|
func tclRules() Rules {
|
|
return Rules{
|
|
"root": {
|
|
Include("command"),
|
|
Include("basic"),
|
|
Include("data"),
|
|
{`\}`, Keyword, nil},
|
|
},
|
|
"command": {
|
|
{Words(`\b`, `\b`, `after`, `apply`, `array`, `break`, `catch`, `continue`, `elseif`, `else`, `error`, `eval`, `expr`, `for`, `foreach`, `global`, `if`, `namespace`, `proc`, `rename`, `return`, `set`, `switch`, `then`, `trace`, `unset`, `update`, `uplevel`, `upvar`, `variable`, `vwait`, `while`), Keyword, Push("params")},
|
|
{Words(`\b`, `\b`, `append`, `bgerror`, `binary`, `cd`, `chan`, `clock`, `close`, `concat`, `dde`, `dict`, `encoding`, `eof`, `exec`, `exit`, `fblocked`, `fconfigure`, `fcopy`, `file`, `fileevent`, `flush`, `format`, `gets`, `glob`, `history`, `http`, `incr`, `info`, `interp`, `join`, `lappend`, `lassign`, `lindex`, `linsert`, `list`, `llength`, `load`, `loadTk`, `lrange`, `lrepeat`, `lreplace`, `lreverse`, `lsearch`, `lset`, `lsort`, `mathfunc`, `mathop`, `memory`, `msgcat`, `open`, `package`, `pid`, `pkg::create`, `pkg_mkIndex`, `platform`, `platform::shell`, `puts`, `pwd`, `re_syntax`, `read`, `refchan`, `regexp`, `registry`, `regsub`, `scan`, `seek`, `socket`, `source`, `split`, `string`, `subst`, `tell`, `time`, `tm`, `unknown`, `unload`), NameBuiltin, Push("params")},
|
|
{`([\w.-]+)`, NameVariable, Push("params")},
|
|
{`#`, Comment, Push("comment")},
|
|
},
|
|
"command-in-brace": {
|
|
{Words(`\b`, `\b`, `after`, `apply`, `array`, `break`, `catch`, `continue`, `elseif`, `else`, `error`, `eval`, `expr`, `for`, `foreach`, `global`, `if`, `namespace`, `proc`, `rename`, `return`, `set`, `switch`, `then`, `trace`, `unset`, `update`, `uplevel`, `upvar`, `variable`, `vwait`, `while`), Keyword, Push("params-in-brace")},
|
|
{Words(`\b`, `\b`, `append`, `bgerror`, `binary`, `cd`, `chan`, `clock`, `close`, `concat`, `dde`, `dict`, `encoding`, `eof`, `exec`, `exit`, `fblocked`, `fconfigure`, `fcopy`, `file`, `fileevent`, `flush`, `format`, `gets`, `glob`, `history`, `http`, `incr`, `info`, `interp`, `join`, `lappend`, `lassign`, `lindex`, `linsert`, `list`, `llength`, `load`, `loadTk`, `lrange`, `lrepeat`, `lreplace`, `lreverse`, `lsearch`, `lset`, `lsort`, `mathfunc`, `mathop`, `memory`, `msgcat`, `open`, `package`, `pid`, `pkg::create`, `pkg_mkIndex`, `platform`, `platform::shell`, `puts`, `pwd`, `re_syntax`, `read`, `refchan`, `regexp`, `registry`, `regsub`, `scan`, `seek`, `socket`, `source`, `split`, `string`, `subst`, `tell`, `time`, `tm`, `unknown`, `unload`), NameBuiltin, Push("params-in-brace")},
|
|
{`([\w.-]+)`, NameVariable, Push("params-in-brace")},
|
|
{`#`, Comment, Push("comment")},
|
|
},
|
|
"command-in-bracket": {
|
|
{Words(`\b`, `\b`, `after`, `apply`, `array`, `break`, `catch`, `continue`, `elseif`, `else`, `error`, `eval`, `expr`, `for`, `foreach`, `global`, `if`, `namespace`, `proc`, `rename`, `return`, `set`, `switch`, `then`, `trace`, `unset`, `update`, `uplevel`, `upvar`, `variable`, `vwait`, `while`), Keyword, Push("params-in-bracket")},
|
|
{Words(`\b`, `\b`, `append`, `bgerror`, `binary`, `cd`, `chan`, `clock`, `close`, `concat`, `dde`, `dict`, `encoding`, `eof`, `exec`, `exit`, `fblocked`, `fconfigure`, `fcopy`, `file`, `fileevent`, `flush`, `format`, `gets`, `glob`, `history`, `http`, `incr`, `info`, `interp`, `join`, `lappend`, `lassign`, `lindex`, `linsert`, `list`, `llength`, `load`, `loadTk`, `lrange`, `lrepeat`, `lreplace`, `lreverse`, `lsearch`, `lset`, `lsort`, `mathfunc`, `mathop`, `memory`, `msgcat`, `open`, `package`, `pid`, `pkg::create`, `pkg_mkIndex`, `platform`, `platform::shell`, `puts`, `pwd`, `re_syntax`, `read`, `refchan`, `regexp`, `registry`, `regsub`, `scan`, `seek`, `socket`, `source`, `split`, `string`, `subst`, `tell`, `time`, `tm`, `unknown`, `unload`), NameBuiltin, Push("params-in-bracket")},
|
|
{`([\w.-]+)`, NameVariable, Push("params-in-bracket")},
|
|
{`#`, Comment, Push("comment")},
|
|
},
|
|
"command-in-paren": {
|
|
{Words(`\b`, `\b`, `after`, `apply`, `array`, `break`, `catch`, `continue`, `elseif`, `else`, `error`, `eval`, `expr`, `for`, `foreach`, `global`, `if`, `namespace`, `proc`, `rename`, `return`, `set`, `switch`, `then`, `trace`, `unset`, `update`, `uplevel`, `upvar`, `variable`, `vwait`, `while`), Keyword, Push("params-in-paren")},
|
|
{Words(`\b`, `\b`, `append`, `bgerror`, `binary`, `cd`, `chan`, `clock`, `close`, `concat`, `dde`, `dict`, `encoding`, `eof`, `exec`, `exit`, `fblocked`, `fconfigure`, `fcopy`, `file`, `fileevent`, `flush`, `format`, `gets`, `glob`, `history`, `http`, `incr`, `info`, `interp`, `join`, `lappend`, `lassign`, `lindex`, `linsert`, `list`, `llength`, `load`, `loadTk`, `lrange`, `lrepeat`, `lreplace`, `lreverse`, `lsearch`, `lset`, `lsort`, `mathfunc`, `mathop`, `memory`, `msgcat`, `open`, `package`, `pid`, `pkg::create`, `pkg_mkIndex`, `platform`, `platform::shell`, `puts`, `pwd`, `re_syntax`, `read`, `refchan`, `regexp`, `registry`, `regsub`, `scan`, `seek`, `socket`, `source`, `split`, `string`, `subst`, `tell`, `time`, `tm`, `unknown`, `unload`), NameBuiltin, Push("params-in-paren")},
|
|
{`([\w.-]+)`, NameVariable, Push("params-in-paren")},
|
|
{`#`, Comment, Push("comment")},
|
|
},
|
|
"basic": {
|
|
{`\(`, Keyword, Push("paren")},
|
|
{`\[`, Keyword, Push("bracket")},
|
|
{`\{`, Keyword, Push("brace")},
|
|
{`"`, LiteralStringDouble, Push("string")},
|
|
{`(eq|ne|in|ni)\b`, OperatorWord, nil},
|
|
{`!=|==|<<|>>|<=|>=|&&|\|\||\*\*|[-+~!*/%<>&^|?:]`, Operator, nil},
|
|
},
|
|
"data": {
|
|
{`\s+`, Text, nil},
|
|
{`0x[a-fA-F0-9]+`, LiteralNumberHex, nil},
|
|
{`0[0-7]+`, LiteralNumberOct, nil},
|
|
{`\d+\.\d+`, LiteralNumberFloat, nil},
|
|
{`\d+`, LiteralNumberInteger, nil},
|
|
{`\$([\w.:-]+)`, NameVariable, nil},
|
|
{`([\w.:-]+)`, Text, nil},
|
|
},
|
|
"params": {
|
|
{`;`, Keyword, Pop(1)},
|
|
{`\n`, Text, Pop(1)},
|
|
{`(else|elseif|then)\b`, Keyword, nil},
|
|
Include("basic"),
|
|
Include("data"),
|
|
},
|
|
"params-in-brace": {
|
|
{`\}`, Keyword, Push("#pop", "#pop")},
|
|
Include("params"),
|
|
},
|
|
"params-in-paren": {
|
|
{`\)`, Keyword, Push("#pop", "#pop")},
|
|
Include("params"),
|
|
},
|
|
"params-in-bracket": {
|
|
{`\]`, Keyword, Push("#pop", "#pop")},
|
|
Include("params"),
|
|
},
|
|
"string": {
|
|
{`\[`, LiteralStringDouble, Push("string-square")},
|
|
{`(?s)(\\\\|\\[0-7]+|\\.|[^"\\])`, LiteralStringDouble, nil},
|
|
{`"`, LiteralStringDouble, Pop(1)},
|
|
},
|
|
"string-square": {
|
|
{`\[`, LiteralStringDouble, Push("string-square")},
|
|
{`(?s)(\\\\|\\[0-7]+|\\.|\\\n|[^\]\\])`, LiteralStringDouble, nil},
|
|
{`\]`, LiteralStringDouble, Pop(1)},
|
|
},
|
|
"brace": {
|
|
{`\}`, Keyword, Pop(1)},
|
|
Include("command-in-brace"),
|
|
Include("basic"),
|
|
Include("data"),
|
|
},
|
|
"paren": {
|
|
{`\)`, Keyword, Pop(1)},
|
|
Include("command-in-paren"),
|
|
Include("basic"),
|
|
Include("data"),
|
|
},
|
|
"bracket": {
|
|
{`\]`, Keyword, Pop(1)},
|
|
Include("command-in-bracket"),
|
|
Include("basic"),
|
|
Include("data"),
|
|
},
|
|
"comment": {
|
|
{`.*[^\\]\n`, Comment, Pop(1)},
|
|
{`.*\\\n`, Comment, nil},
|
|
},
|
|
}
|
|
}
|