...

Source file src/github.com/alecthomas/chroma/lexers/s/snobol.go

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

     1  package s
     2  
     3  import (
     4  	. "github.com/alecthomas/chroma" // nolint
     5  	"github.com/alecthomas/chroma/lexers/internal"
     6  )
     7  
     8  // Snobol lexer.
     9  var Snobol = internal.Register(MustNewLazyLexer(
    10  	&Config{
    11  		Name:      "Snobol",
    12  		Aliases:   []string{"snobol"},
    13  		Filenames: []string{"*.snobol"},
    14  		MimeTypes: []string{"text/x-snobol"},
    15  	},
    16  	snobolRules,
    17  ))
    18  
    19  func snobolRules() Rules {
    20  	return Rules{
    21  		"root": {
    22  			{`\*.*\n`, Comment, nil},
    23  			{`[+.] `, Punctuation, Push("statement")},
    24  			{`-.*\n`, Comment, nil},
    25  			{`END\s*\n`, NameLabel, Push("heredoc")},
    26  			{`[A-Za-z$][\w$]*`, NameLabel, Push("statement")},
    27  			{`\s+`, Text, Push("statement")},
    28  		},
    29  		"statement": {
    30  			{`\s*\n`, Text, Pop(1)},
    31  			{`\s+`, Text, nil},
    32  			{`(?<=[^\w.])(LT|LE|EQ|NE|GE|GT|INTEGER|IDENT|DIFFER|LGT|SIZE|REPLACE|TRIM|DUPL|REMDR|DATE|TIME|EVAL|APPLY|OPSYN|LOAD|UNLOAD|LEN|SPAN|BREAK|ANY|NOTANY|TAB|RTAB|REM|POS|RPOS|FAIL|FENCE|ABORT|ARB|ARBNO|BAL|SUCCEED|INPUT|OUTPUT|TERMINAL)(?=[^\w.])`, NameBuiltin, nil},
    33  			{`[A-Za-z][\w.]*`, Name, nil},
    34  			{`\*\*|[?$.!%*/#+\-@|&\\=]`, Operator, nil},
    35  			{`"[^"]*"`, LiteralString, nil},
    36  			{`'[^']*'`, LiteralString, nil},
    37  			{`[0-9]+(?=[^.EeDd])`, LiteralNumberInteger, nil},
    38  			{`[0-9]+(\.[0-9]*)?([EDed][-+]?[0-9]+)?`, LiteralNumberFloat, nil},
    39  			{`:`, Punctuation, Push("goto")},
    40  			{`[()<>,;]`, Punctuation, nil},
    41  		},
    42  		"goto": {
    43  			{`\s*\n`, Text, Pop(2)},
    44  			{`\s+`, Text, nil},
    45  			{`F|S`, Keyword, nil},
    46  			{`(\()([A-Za-z][\w.]*)(\))`, ByGroups(Punctuation, NameLabel, Punctuation), nil},
    47  		},
    48  		"heredoc": {
    49  			{`.*\n`, LiteralStringHeredoc, nil},
    50  		},
    51  	}
    52  }
    53  

View as plain text