1package t
2
3import (
4 . "github.com/alecthomas/chroma" // nolint
5 "github.com/alecthomas/chroma/lexers/internal"
6)
7
8// Tcsh lexer.
9var Tcsh = internal.Register(MustNewLexer(
10 &Config{
11 Name: "Tcsh",
12 Aliases: []string{"tcsh", "csh"},
13 Filenames: []string{"*.tcsh", "*.csh"},
14 MimeTypes: []string{"application/x-csh"},
15 },
16 Rules{
17 "root": {
18 Include("basic"),
19 {`\$\(`, Keyword, Push("paren")},
20 {`\$\{#?`, Keyword, Push("curly")},
21 {"`", LiteralStringBacktick, Push("backticks")},
22 Include("data"),
23 },
24 "basic": {
25 {`\b(if|endif|else|while|then|foreach|case|default|continue|goto|breaksw|end|switch|endsw)\s*\b`, Keyword, nil},
26 {`\b(alias|alloc|bg|bindkey|break|builtins|bye|caller|cd|chdir|complete|dirs|echo|echotc|eval|exec|exit|fg|filetest|getxvers|glob|getspath|hashstat|history|hup|inlib|jobs|kill|limit|log|login|logout|ls-F|migrate|newgrp|nice|nohup|notify|onintr|popd|printenv|pushd|rehash|repeat|rootnode|popd|pushd|set|shift|sched|setenv|setpath|settc|setty|setxvers|shift|source|stop|suspend|source|suspend|telltc|time|umask|unalias|uncomplete|unhash|universe|unlimit|unset|unsetenv|ver|wait|warp|watchlog|where|which)\s*\b`, NameBuiltin, nil},
27 {`#.*`, Comment, nil},
28 {`\\[\w\W]`, LiteralStringEscape, nil},
29 {`(\b\w+)(\s*)(=)`, ByGroups(NameVariable, Text, Operator), nil},
30 {`[\[\]{}()=]+`, Operator, nil},
31 {`<<\s*(\'?)\\?(\w+)[\w\W]+?\2`, LiteralString, nil},
32 {`;`, Punctuation, nil},
33 },
34 "data": {
35 {`(?s)"(\\\\|\\[0-7]+|\\.|[^"\\])*"`, LiteralStringDouble, nil},
36 {`(?s)'(\\\\|\\[0-7]+|\\.|[^'\\])*'`, LiteralStringSingle, nil},
37 {`\s+`, Text, nil},
38 {"[^=\\s\\[\\]{}()$\"\\'`\\\\;#]+", Text, nil},
39 {`\d+(?= |\Z)`, LiteralNumber, nil},
40 {`\$#?(\w+|.)`, NameVariable, nil},
41 },
42 "curly": {
43 {`\}`, Keyword, Pop(1)},
44 {`:-`, Keyword, nil},
45 {`\w+`, NameVariable, nil},
46 {"[^}:\"\\'`$]+", Punctuation, nil},
47 {`:`, Punctuation, nil},
48 Include("root"),
49 },
50 "paren": {
51 {`\)`, Keyword, Pop(1)},
52 Include("root"),
53 },
54 "backticks": {
55 {"`", LiteralStringBacktick, Pop(1)},
56 Include("root"),
57 },
58 },
59))