gitea/vendor/github.com/alecthomas/chroma/lexers/d/dart.go
6543 86e2789960
Vendor Update (#16121)
* update github.com/PuerkitoBio/goquery

* update github.com/alecthomas/chroma

* update github.com/blevesearch/bleve/v2

* update github.com/caddyserver/certmagic

* update github.com/go-enry/go-enry/v2

* update github.com/go-git/go-billy/v5

* update github.com/go-git/go-git/v5

* update github.com/go-redis/redis/v8

* update github.com/go-testfixtures/testfixtures/v3

* update github.com/jaytaylor/html2text

* update github.com/json-iterator/go

* update github.com/klauspost/compress

* update github.com/markbates/goth

* update github.com/mattn/go-isatty

* update github.com/mholt/archiver/v3

* update github.com/microcosm-cc/bluemonday

* update github.com/minio/minio-go/v7

* update github.com/prometheus/client_golang

* update github.com/unrolled/render

* update github.com/xanzy/go-gitlab

* update github.com/yuin/goldmark

* update github.com/yuin/goldmark-highlighting

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-10 16:44:25 +02:00

95 lines
3.2 KiB
Go
Vendored

package d
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
// Dart lexer.
var Dart = internal.Register(MustNewLazyLexer(
&Config{
Name: "Dart",
Aliases: []string{"dart"},
Filenames: []string{"*.dart"},
MimeTypes: []string{"text/x-dart"},
DotAll: true,
},
dartRules,
))
func dartRules() Rules {
return Rules{
"root": {
Include("string_literal"),
{`#!(.*?)$`, CommentPreproc, nil},
{`\b(import|export)\b`, Keyword, Push("import_decl")},
{`\b(library|source|part of|part)\b`, Keyword, nil},
{`[^\S\n]+`, Text, nil},
{`//.*?\n`, CommentSingle, nil},
{`/\*.*?\*/`, CommentMultiline, nil},
{`\b(class)\b(\s+)`, ByGroups(KeywordDeclaration, Text), Push("class")},
{`\b(assert|break|case|catch|continue|default|do|else|finally|for|if|in|is|new|return|super|switch|this|throw|try|while)\b`, Keyword, nil},
{`\b(abstract|async|await|const|extends|factory|final|get|implements|native|operator|set|static|sync|typedef|var|with|yield)\b`, KeywordDeclaration, nil},
{`\b(bool|double|dynamic|int|num|Object|String|void)\b`, KeywordType, nil},
{`\b(false|null|true)\b`, KeywordConstant, nil},
{`[~!%^&*+=|?:<>/-]|as\b`, Operator, nil},
{`[a-zA-Z_$]\w*:`, NameLabel, nil},
{`[a-zA-Z_$]\w*`, Name, nil},
{`[(){}\[\],.;]`, Punctuation, nil},
{`0[xX][0-9a-fA-F]+`, LiteralNumberHex, nil},
{`\d+(\.\d*)?([eE][+-]?\d+)?`, LiteralNumber, nil},
{`\.\d+([eE][+-]?\d+)?`, LiteralNumber, nil},
{`\n`, Text, nil},
},
"class": {
{`[a-zA-Z_$]\w*`, NameClass, Pop(1)},
},
"import_decl": {
Include("string_literal"),
{`\s+`, Text, nil},
{`\b(as|show|hide)\b`, Keyword, nil},
{`[a-zA-Z_$]\w*`, Name, nil},
{`\,`, Punctuation, nil},
{`\;`, Punctuation, Pop(1)},
},
"string_literal": {
{`r"""([\w\W]*?)"""`, LiteralStringDouble, nil},
{`r'''([\w\W]*?)'''`, LiteralStringSingle, nil},
{`r"(.*?)"`, LiteralStringDouble, nil},
{`r'(.*?)'`, LiteralStringSingle, nil},
{`"""`, LiteralStringDouble, Push("string_double_multiline")},
{`'''`, LiteralStringSingle, Push("string_single_multiline")},
{`"`, LiteralStringDouble, Push("string_double")},
{`'`, LiteralStringSingle, Push("string_single")},
},
"string_common": {
{`\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u\{[0-9A-Fa-f]*\}|[a-z'\"$\\])`, LiteralStringEscape, nil},
{`(\$)([a-zA-Z_]\w*)`, ByGroups(LiteralStringInterpol, Name), nil},
{`(\$\{)(.*?)(\})`, ByGroups(LiteralStringInterpol, UsingSelf("root"), LiteralStringInterpol), nil},
},
"string_double": {
{`"`, LiteralStringDouble, Pop(1)},
{`[^"$\\\n]+`, LiteralStringDouble, nil},
Include("string_common"),
{`\$+`, LiteralStringDouble, nil},
},
"string_double_multiline": {
{`"""`, LiteralStringDouble, Pop(1)},
{`[^"$\\]+`, LiteralStringDouble, nil},
Include("string_common"),
{`(\$|\")+`, LiteralStringDouble, nil},
},
"string_single": {
{`'`, LiteralStringSingle, Pop(1)},
{`[^'$\\\n]+`, LiteralStringSingle, nil},
Include("string_common"),
{`\$+`, LiteralStringSingle, nil},
},
"string_single_multiline": {
{`'''`, LiteralStringSingle, Pop(1)},
{`[^\'$\\]+`, LiteralStringSingle, nil},
Include("string_common"),
{`(\$|\')+`, LiteralStringSingle, nil},
},
}
}