...

Source file src/github.com/alecthomas/chroma/lexers/a/abnf.go

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

     1  package a
     2  
     3  import (
     4  	. "github.com/alecthomas/chroma" // nolint
     5  	"github.com/alecthomas/chroma/lexers/internal"
     6  )
     7  
     8  // Abnf lexer.
     9  var Abnf = internal.Register(MustNewLazyLexer(
    10  	&Config{
    11  		Name:      "ABNF",
    12  		Aliases:   []string{"abnf"},
    13  		Filenames: []string{"*.abnf"},
    14  		MimeTypes: []string{"text/x-abnf"},
    15  	},
    16  	abnfRules,
    17  ))
    18  
    19  func abnfRules() Rules {
    20  	return Rules{
    21  		"root": {
    22  			{`;.*$`, CommentSingle, nil},
    23  			{`(%[si])?"[^"]*"`, Literal, nil},
    24  			{`%b[01]+\-[01]+\b`, Literal, nil},
    25  			{`%b[01]+(\.[01]+)*\b`, Literal, nil},
    26  			{`%d[0-9]+\-[0-9]+\b`, Literal, nil},
    27  			{`%d[0-9]+(\.[0-9]+)*\b`, Literal, nil},
    28  			{`%x[0-9a-fA-F]+\-[0-9a-fA-F]+\b`, Literal, nil},
    29  			{`%x[0-9a-fA-F]+(\.[0-9a-fA-F]+)*\b`, Literal, nil},
    30  			{`\b[0-9]+\*[0-9]+`, Operator, nil},
    31  			{`\b[0-9]+\*`, Operator, nil},
    32  			{`\b[0-9]+`, Operator, nil},
    33  			{`\*`, Operator, nil},
    34  			{Words(``, `\b`, `ALPHA`, `BIT`, `CHAR`, `CR`, `CRLF`, `CTL`, `DIGIT`, `DQUOTE`, `HEXDIG`, `HTAB`, `LF`, `LWSP`, `OCTET`, `SP`, `VCHAR`, `WSP`), Keyword, nil},
    35  			{`[a-zA-Z][a-zA-Z0-9-]+\b`, NameClass, nil},
    36  			{`(=/|=|/)`, Operator, nil},
    37  			{`[\[\]()]`, Punctuation, nil},
    38  			{`\s+`, Text, nil},
    39  			{`.`, Text, nil},
    40  		},
    41  	}
    42  }
    43  

View as plain text