...

Source file src/github.com/alecthomas/chroma/lexers/p/powerquery.go

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

     1  package p
     2  
     3  import (
     4  	. "github.com/alecthomas/chroma" // nolint
     5  	"github.com/alecthomas/chroma/lexers/internal"
     6  )
     7  
     8  // PowerQuery lexer.
     9  var PowerQuery = internal.Register(MustNewLazyLexer(
    10  	&Config{
    11  		Name:            "PowerQuery",
    12  		Aliases:         []string{"powerquery", "pq"},
    13  		Filenames:       []string{"*.pq"},
    14  		MimeTypes:       []string{"text/x-powerquery"},
    15  		DotAll:          true,
    16  		CaseInsensitive: true,
    17  	},
    18  	powerqueryRules,
    19  ))
    20  
    21  func powerqueryRules() Rules {
    22  	return Rules{
    23  		"root": {
    24  			{`\s+`, Text, nil},
    25  			{`//.*?\n`, CommentSingle, nil},
    26  			{`/\*.*?\*/`, CommentMultiline, nil},
    27  			{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
    28  			{`(and|as|each|else|error|false|if|in|is|let|meta|not|null|or|otherwise|section|shared|then|true|try|type)\b`, Keyword, nil},
    29  			{`(#binary|#date|#datetime|#datetimezone|#duration|#infinity|#nan|#sections|#shared|#table|#time)\b`, KeywordType, nil},
    30  			{`(([a-zA-Z]|_)[\w|._]*|#"[^"]+")`, Name, nil},
    31  			{`0[xX][0-9a-fA-F][0-9a-fA-F_]*[lL]?`, LiteralNumberHex, nil},
    32  			{`([0-9]+\.[0-9]+|\.[0-9]+)([eE][0-9]+)?`, LiteralNumberFloat, nil},
    33  			{`[0-9]+`, LiteralNumberInteger, nil},
    34  			{`[\(\)\[\]\{\}]`, Punctuation, nil},
    35  			{`\.\.|\.\.\.|=>|<=|>=|<>|[@!?,;=<>\+\-\*\/&]`, Operator, nil},
    36  		},
    37  	}
    38  }
    39  

View as plain text