...

Source file src/github.com/alecthomas/chroma/lexers/r/regedit.go

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

     1  package r
     2  
     3  import (
     4  	. "github.com/alecthomas/chroma" // nolint
     5  	"github.com/alecthomas/chroma/lexers/internal"
     6  )
     7  
     8  // Reg lexer.
     9  var Reg = internal.Register(MustNewLazyLexer(
    10  	&Config{
    11  		Name:      "reg",
    12  		Aliases:   []string{"registry"},
    13  		Filenames: []string{"*.reg"},
    14  		MimeTypes: []string{"text/x-windows-registry"},
    15  	},
    16  	regRules,
    17  ))
    18  
    19  func regRules() Rules {
    20  	return Rules{
    21  		"root": {
    22  			{`Windows Registry Editor.*`, Text, nil},
    23  			{`\s+`, Text, nil},
    24  			{`[;#].*`, CommentSingle, nil},
    25  			{`(\[)(-?)(HKEY_[A-Z_]+)(.*?\])$`, ByGroups(Keyword, Operator, NameBuiltin, Keyword), nil},
    26  			{`("(?:\\"|\\\\|[^"])+")([ \t]*)(=)([ \t]*)`, ByGroups(NameAttribute, Text, Operator, Text), Push("value")},
    27  			{`(.*?)([ \t]*)(=)([ \t]*)`, ByGroups(NameAttribute, Text, Operator, Text), Push("value")},
    28  		},
    29  		"value": {
    30  			{`-`, Operator, Pop(1)},
    31  			{`(dword|hex(?:\([0-9a-fA-F]\))?)(:)([0-9a-fA-F,]+)`, ByGroups(NameVariable, Punctuation, LiteralNumber), Pop(1)},
    32  			{`.+`, LiteralString, Pop(1)},
    33  			Default(Pop(1)),
    34  		},
    35  	}
    36  }
    37  

View as plain text