...

Source file src/github.com/alecthomas/chroma/lexers/t/tcsh.go

Documentation: github.com/alecthomas/chroma/lexers/t

     1  package t
     2  
     3  import (
     4  	. "github.com/alecthomas/chroma" // nolint
     5  	"github.com/alecthomas/chroma/lexers/internal"
     6  )
     7  
     8  // Tcsh lexer.
     9  var Tcsh = internal.Register(MustNewLazyLexer(
    10  	&Config{
    11  		Name:      "Tcsh",
    12  		Aliases:   []string{"tcsh", "csh"},
    13  		Filenames: []string{"*.tcsh", "*.csh"},
    14  		MimeTypes: []string{"application/x-csh"},
    15  	},
    16  	tcshRules,
    17  ))
    18  
    19  func tcshRules() Rules {
    20  	return Rules{
    21  		"root": {
    22  			Include("basic"),
    23  			{`\$\(`, Keyword, Push("paren")},
    24  			{`\$\{#?`, Keyword, Push("curly")},
    25  			{"`", LiteralStringBacktick, Push("backticks")},
    26  			Include("data"),
    27  		},
    28  		"basic": {
    29  			{`\b(if|endif|else|while|then|foreach|case|default|continue|goto|breaksw|end|switch|endsw)\s*\b`, Keyword, nil},
    30  			{`\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},
    31  			{`#.*`, Comment, nil},
    32  			{`\\[\w\W]`, LiteralStringEscape, nil},
    33  			{`(\b\w+)(\s*)(=)`, ByGroups(NameVariable, Text, Operator), nil},
    34  			{`[\[\]{}()=]+`, Operator, nil},
    35  			{`<<\s*(\'?)\\?(\w+)[\w\W]+?\2`, LiteralString, nil},
    36  			{`;`, Punctuation, nil},
    37  		},
    38  		"data": {
    39  			{`(?s)"(\\\\|\\[0-7]+|\\.|[^"\\])*"`, LiteralStringDouble, nil},
    40  			{`(?s)'(\\\\|\\[0-7]+|\\.|[^'\\])*'`, LiteralStringSingle, nil},
    41  			{`\s+`, Text, nil},
    42  			{"[^=\\s\\[\\]{}()$\"\\'`\\\\;#]+", Text, nil},
    43  			{`\d+(?= |\Z)`, LiteralNumber, nil},
    44  			{`\$#?(\w+|.)`, NameVariable, nil},
    45  		},
    46  		"curly": {
    47  			{`\}`, Keyword, Pop(1)},
    48  			{`:-`, Keyword, nil},
    49  			{`\w+`, NameVariable, nil},
    50  			{"[^}:\"\\'`$]+", Punctuation, nil},
    51  			{`:`, Punctuation, nil},
    52  			Include("root"),
    53  		},
    54  		"paren": {
    55  			{`\)`, Keyword, Pop(1)},
    56  			Include("root"),
    57  		},
    58  		"backticks": {
    59  			{"`", LiteralStringBacktick, Pop(1)},
    60  			Include("root"),
    61  		},
    62  	}
    63  }
    64  

View as plain text