This commit is contained in:
73
vendor/github.com/alecthomas/chroma/lexers/d/d.go
generated
vendored
Normal file
73
vendor/github.com/alecthomas/chroma/lexers/d/d.go
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
package d
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// D lexer. https://dlang.org/spec/lex.html
|
||||
var D = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "D",
|
||||
Aliases: []string{"d"},
|
||||
Filenames: []string{"*.d", "*.di"},
|
||||
MimeTypes: []string{"text/x-d"},
|
||||
EnsureNL: true,
|
||||
},
|
||||
dRules,
|
||||
))
|
||||
|
||||
func dRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`[^\S\n]+`, Text, nil},
|
||||
|
||||
// https://dlang.org/spec/lex.html#comment
|
||||
{`//.*?\n`, CommentSingle, nil},
|
||||
{`/\*.*?\*/`, CommentMultiline, nil},
|
||||
{`/\+.*?\+/`, CommentMultiline, nil},
|
||||
|
||||
// https://dlang.org/spec/lex.html#keywords
|
||||
{`(asm|assert|body|break|case|cast|catch|continue|default|debug|delete|deprecated|do|else|finally|for|foreach|foreach_reverse|goto|if|in|invariant|is|macro|mixin|new|out|pragma|return|super|switch|this|throw|try|version|while|with)\b`, Keyword, nil},
|
||||
{`__(FILE|FILE_FULL_PATH|MODULE|LINE|FUNCTION|PRETTY_FUNCTION|DATE|EOF|TIME|TIMESTAMP|VENDOR|VERSION)__\b`, NameBuiltin, nil},
|
||||
{`__(traits|vector|parameters)\b`, NameBuiltin, nil},
|
||||
{`((?:(?:[^\W\d]|\$)[\w.\[\]$<>]*\s+)+?)((?:[^\W\d]|\$)[\w$]*)(\s*)(\()`, ByGroups(UsingSelf("root"), NameFunction, Text, Operator), nil},
|
||||
|
||||
// https://dlang.org/spec/attribute.html#uda
|
||||
{`@[\w.]*`, NameDecorator, nil},
|
||||
{`(abstract|auto|alias|align|const|delegate|enum|export|final|function|inout|lazy|nothrow|override|package|private|protected|public|pure|static|synchronized|template|volatile|__gshared)\b`, KeywordDeclaration, nil},
|
||||
|
||||
// https://dlang.org/spec/type.html#basic-data-types
|
||||
{`(void|bool|byte|ubyte|short|ushort|int|uint|long|ulong|cent|ucent|float|double|real|ifloat|idouble|ireal|cfloat|cdouble|creal|char|wchar|dchar|string|wstring|dstring)\b`, KeywordType, nil},
|
||||
{`(module)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")},
|
||||
{`(true|false|null)\b`, KeywordConstant, nil},
|
||||
{`(class|interface|struct|template|union)(\s+)`, ByGroups(KeywordDeclaration, Text), Push("class")},
|
||||
{`(import)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")},
|
||||
|
||||
// https://dlang.org/spec/lex.html#string_literals
|
||||
// TODO support delimited strings
|
||||
{`[qr]?"(\\\\|\\"|[^"])*"[cwd]?`, LiteralString, nil},
|
||||
{"(`)([^`]*)(`)[cwd]?", LiteralString, nil},
|
||||
{`'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'`, LiteralStringChar, nil},
|
||||
{`(\.)((?:[^\W\d]|\$)[\w$]*)`, ByGroups(Operator, NameAttribute), nil},
|
||||
{`^\s*([^\W\d]|\$)[\w$]*:`, NameLabel, nil},
|
||||
|
||||
// https://dlang.org/spec/lex.html#floatliteral
|
||||
{`([0-9][0-9_]*\.([0-9][0-9_]*)?|\.[0-9][0-9_]*)([eE][+\-]?[0-9][0-9_]*)?[fFL]?i?|[0-9][eE][+\-]?[0-9][0-9_]*[fFL]?|[0-9]([eE][+\-]?[0-9][0-9_]*)?[fFL]|0[xX]([0-9a-fA-F][0-9a-fA-F_]*\.?|([0-9a-fA-F][0-9a-fA-F_]*)?\.[0-9a-fA-F][0-9a-fA-F_]*)[pP][+\-]?[0-9][0-9_]*[fFL]?`, LiteralNumberFloat, nil},
|
||||
// https://dlang.org/spec/lex.html#integerliteral
|
||||
{`0[xX][0-9a-fA-F][0-9a-fA-F_]*[lL]?`, LiteralNumberHex, nil},
|
||||
{`0[bB][01][01_]*[lL]?`, LiteralNumberBin, nil},
|
||||
{`0[0-7_]+[lL]?`, LiteralNumberOct, nil},
|
||||
{`0|[1-9][0-9_]*[lL]?`, LiteralNumberInteger, nil},
|
||||
{`([~^*!%&\[\](){}<>|+=:;,./?-]|q{)`, Operator, nil},
|
||||
{`([^\W\d]|\$)[\w$]*`, Name, nil},
|
||||
{`\n`, Text, nil},
|
||||
},
|
||||
"class": {
|
||||
{`([^\W\d]|\$)[\w$]*`, NameClass, Pop(1)},
|
||||
},
|
||||
"import": {
|
||||
{`[\w.]+\*?`, NameNamespace, Pop(1)},
|
||||
},
|
||||
}
|
||||
}
|
||||
95
vendor/github.com/alecthomas/chroma/lexers/d/dart.go
generated
vendored
Normal file
95
vendor/github.com/alecthomas/chroma/lexers/d/dart.go
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
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},
|
||||
},
|
||||
}
|
||||
}
|
||||
33
vendor/github.com/alecthomas/chroma/lexers/d/diff.go
generated
vendored
Normal file
33
vendor/github.com/alecthomas/chroma/lexers/d/diff.go
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
package d
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Diff lexer.
|
||||
var Diff = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Diff",
|
||||
Aliases: []string{"diff", "udiff"},
|
||||
EnsureNL: true,
|
||||
Filenames: []string{"*.diff", "*.patch"},
|
||||
MimeTypes: []string{"text/x-diff", "text/x-patch"},
|
||||
},
|
||||
diffRules,
|
||||
))
|
||||
|
||||
func diffRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{` .*\n`, Text, nil},
|
||||
{`\+.*\n`, GenericInserted, nil},
|
||||
{`-.*\n`, GenericDeleted, nil},
|
||||
{`!.*\n`, GenericStrong, nil},
|
||||
{`@.*\n`, GenericSubheading, nil},
|
||||
{`([Ii]ndex|diff).*\n`, GenericHeading, nil},
|
||||
{`=.*\n`, GenericHeading, nil},
|
||||
{`.*\n`, Text, nil},
|
||||
},
|
||||
}
|
||||
}
|
||||
57
vendor/github.com/alecthomas/chroma/lexers/d/django.go
generated
vendored
Normal file
57
vendor/github.com/alecthomas/chroma/lexers/d/django.go
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
package d
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Django/Jinja lexer.
|
||||
var DjangoJinja = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Django/Jinja",
|
||||
Aliases: []string{"django", "jinja"},
|
||||
Filenames: []string{},
|
||||
MimeTypes: []string{"application/x-django-templating", "application/x-jinja"},
|
||||
DotAll: true,
|
||||
},
|
||||
djangoJinjaRules,
|
||||
))
|
||||
|
||||
func djangoJinjaRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`[^{]+`, Other, nil},
|
||||
{`\{\{`, CommentPreproc, Push("var")},
|
||||
{`\{[*#].*?[*#]\}`, Comment, nil},
|
||||
{`(\{%)(-?\s*)(comment)(\s*-?)(%\})(.*?)(\{%)(-?\s*)(endcomment)(\s*-?)(%\})`, ByGroups(CommentPreproc, Text, Keyword, Text, CommentPreproc, Comment, CommentPreproc, Text, Keyword, Text, CommentPreproc), nil},
|
||||
{`(\{%)(-?\s*)(raw)(\s*-?)(%\})(.*?)(\{%)(-?\s*)(endraw)(\s*-?)(%\})`, ByGroups(CommentPreproc, Text, Keyword, Text, CommentPreproc, Text, CommentPreproc, Text, Keyword, Text, CommentPreproc), nil},
|
||||
{`(\{%)(-?\s*)(filter)(\s+)([a-zA-Z_]\w*)`, ByGroups(CommentPreproc, Text, Keyword, Text, NameFunction), Push("block")},
|
||||
{`(\{%)(-?\s*)([a-zA-Z_]\w*)`, ByGroups(CommentPreproc, Text, Keyword), Push("block")},
|
||||
{`\{`, Other, nil},
|
||||
},
|
||||
"varnames": {
|
||||
{`(\|)(\s*)([a-zA-Z_]\w*)`, ByGroups(Operator, Text, NameFunction), nil},
|
||||
{`(is)(\s+)(not)?(\s+)?([a-zA-Z_]\w*)`, ByGroups(Keyword, Text, Keyword, Text, NameFunction), nil},
|
||||
{`(_|true|false|none|True|False|None)\b`, KeywordPseudo, nil},
|
||||
{`(in|as|reversed|recursive|not|and|or|is|if|else|import|with(?:(?:out)?\s*context)?|scoped|ignore\s+missing)\b`, Keyword, nil},
|
||||
{`(loop|block|super|forloop)\b`, NameBuiltin, nil},
|
||||
{`[a-zA-Z_][\w-]*`, NameVariable, nil},
|
||||
{`\.\w+`, NameVariable, nil},
|
||||
{`:?"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
|
||||
{`:?'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil},
|
||||
{`([{}()\[\]+\-*/,:~]|[><=]=?)`, Operator, nil},
|
||||
{`[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?`, LiteralNumber, nil},
|
||||
},
|
||||
"var": {
|
||||
{`\s+`, Text, nil},
|
||||
{`(-?)(\}\})`, ByGroups(Text, CommentPreproc), Pop(1)},
|
||||
Include("varnames"),
|
||||
},
|
||||
"block": {
|
||||
{`\s+`, Text, nil},
|
||||
{`(-?)(%\})`, ByGroups(Text, CommentPreproc), Pop(1)},
|
||||
Include("varnames"),
|
||||
{`.`, Punctuation, nil},
|
||||
},
|
||||
}
|
||||
}
|
||||
35
vendor/github.com/alecthomas/chroma/lexers/d/docker.go
generated
vendored
Normal file
35
vendor/github.com/alecthomas/chroma/lexers/d/docker.go
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
package d
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/b"
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
"github.com/alecthomas/chroma/lexers/j"
|
||||
)
|
||||
|
||||
// Docker lexer.
|
||||
var Docker = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Docker",
|
||||
Aliases: []string{"docker", "dockerfile"},
|
||||
Filenames: []string{"Dockerfile", "*.docker"},
|
||||
MimeTypes: []string{"text/x-dockerfile-config"},
|
||||
CaseInsensitive: true,
|
||||
},
|
||||
dockerRules,
|
||||
))
|
||||
|
||||
func dockerRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`#.*`, Comment, nil},
|
||||
{`(ONBUILD)((?:\s*\\?\s*))`, ByGroups(Keyword, Using(b.Bash)), nil},
|
||||
{`(HEALTHCHECK)(((?:\s*\\?\s*)--\w+=\w+(?:\s*\\?\s*))*)`, ByGroups(Keyword, Using(b.Bash)), nil},
|
||||
{`(VOLUME|ENTRYPOINT|CMD|SHELL)((?:\s*\\?\s*))(\[.*?\])`, ByGroups(Keyword, Using(b.Bash), Using(j.JSON)), nil},
|
||||
{`(LABEL|ENV|ARG)((?:(?:\s*\\?\s*)\w+=\w+(?:\s*\\?\s*))*)`, ByGroups(Keyword, Using(b.Bash)), nil},
|
||||
{`((?:FROM|MAINTAINER|EXPOSE|WORKDIR|USER|STOPSIGNAL)|VOLUME)\b(.*)`, ByGroups(Keyword, LiteralString), nil},
|
||||
{`((?:RUN|CMD|ENTRYPOINT|ENV|ARG|LABEL|ADD|COPY))`, Keyword, nil},
|
||||
{`(.*\\\n)*.+`, Using(b.Bash), nil},
|
||||
},
|
||||
}
|
||||
}
|
||||
73
vendor/github.com/alecthomas/chroma/lexers/d/dtd.go
generated
vendored
Normal file
73
vendor/github.com/alecthomas/chroma/lexers/d/dtd.go
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
package d
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Dtd lexer.
|
||||
var Dtd = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "DTD",
|
||||
Aliases: []string{"dtd"},
|
||||
Filenames: []string{"*.dtd"},
|
||||
MimeTypes: []string{"application/xml-dtd"},
|
||||
DotAll: true,
|
||||
},
|
||||
dtdRules,
|
||||
))
|
||||
|
||||
func dtdRules() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
Include("common"),
|
||||
{`(<!ELEMENT)(\s+)(\S+)`, ByGroups(Keyword, Text, NameTag), Push("element")},
|
||||
{`(<!ATTLIST)(\s+)(\S+)`, ByGroups(Keyword, Text, NameTag), Push("attlist")},
|
||||
{`(<!ENTITY)(\s+)(\S+)`, ByGroups(Keyword, Text, NameEntity), Push("entity")},
|
||||
{`(<!NOTATION)(\s+)(\S+)`, ByGroups(Keyword, Text, NameTag), Push("notation")},
|
||||
{`(<!\[)([^\[\s]+)(\s*)(\[)`, ByGroups(Keyword, NameEntity, Text, Keyword), nil},
|
||||
{`(<!DOCTYPE)(\s+)([^>\s]+)`, ByGroups(Keyword, Text, NameTag), nil},
|
||||
{`PUBLIC|SYSTEM`, KeywordConstant, nil},
|
||||
{`[\[\]>]`, Keyword, nil},
|
||||
},
|
||||
"common": {
|
||||
{`\s+`, Text, nil},
|
||||
{`(%|&)[^;]*;`, NameEntity, nil},
|
||||
{`<!--`, Comment, Push("comment")},
|
||||
{`[(|)*,?+]`, Operator, nil},
|
||||
{`"[^"]*"`, LiteralStringDouble, nil},
|
||||
{`\'[^\']*\'`, LiteralStringSingle, nil},
|
||||
},
|
||||
"comment": {
|
||||
{`[^-]+`, Comment, nil},
|
||||
{`-->`, Comment, Pop(1)},
|
||||
{`-`, Comment, nil},
|
||||
},
|
||||
"element": {
|
||||
Include("common"),
|
||||
{`EMPTY|ANY|#PCDATA`, KeywordConstant, nil},
|
||||
{`[^>\s|()?+*,]+`, NameTag, nil},
|
||||
{`>`, Keyword, Pop(1)},
|
||||
},
|
||||
"attlist": {
|
||||
Include("common"),
|
||||
{`CDATA|IDREFS|IDREF|ID|NMTOKENS|NMTOKEN|ENTITIES|ENTITY|NOTATION`, KeywordConstant, nil},
|
||||
{`#REQUIRED|#IMPLIED|#FIXED`, KeywordConstant, nil},
|
||||
{`xml:space|xml:lang`, KeywordReserved, nil},
|
||||
{`[^>\s|()?+*,]+`, NameAttribute, nil},
|
||||
{`>`, Keyword, Pop(1)},
|
||||
},
|
||||
"entity": {
|
||||
Include("common"),
|
||||
{`SYSTEM|PUBLIC|NDATA`, KeywordConstant, nil},
|
||||
{`[^>\s|()?+*,]+`, NameEntity, nil},
|
||||
{`>`, Keyword, Pop(1)},
|
||||
},
|
||||
"notation": {
|
||||
Include("common"),
|
||||
{`SYSTEM|PUBLIC`, KeywordConstant, nil},
|
||||
{`[^>\s|()?+*,]+`, NameAttribute, nil},
|
||||
{`>`, Keyword, Pop(1)},
|
||||
},
|
||||
}
|
||||
}
|
||||
76
vendor/github.com/alecthomas/chroma/lexers/d/dylan.go
generated
vendored
Normal file
76
vendor/github.com/alecthomas/chroma/lexers/d/dylan.go
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
package d
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Dylan lexer.
|
||||
var Dylan = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Dylan",
|
||||
Aliases: []string{"dylan"},
|
||||
Filenames: []string{"*.dylan", "*.dyl", "*.intr"},
|
||||
MimeTypes: []string{"text/x-dylan"},
|
||||
CaseInsensitive: true,
|
||||
},
|
||||
func() Rules {
|
||||
return Rules{
|
||||
"root": {
|
||||
{`\s+`, Whitespace, nil},
|
||||
{`//.*?\n`, CommentSingle, nil},
|
||||
{`([a-z0-9-]+:)([ \t]*)(.*(?:\n[ \t].+)*)`, ByGroups(NameAttribute, Whitespace, LiteralString), nil},
|
||||
Default(Push("code")),
|
||||
},
|
||||
"code": {
|
||||
{`\s+`, Whitespace, nil},
|
||||
{`//.*?\n`, CommentSingle, nil},
|
||||
{`/\*`, CommentMultiline, Push("comment")},
|
||||
{`"`, LiteralString, Push("string")},
|
||||
{`'(\\.|\\[0-7]{1,3}|\\x[a-f0-9]{1,2}|[^\\\'\n])'`, LiteralStringChar, nil},
|
||||
{`#b[01]+`, LiteralNumberBin, nil},
|
||||
{`#o[0-7]+`, LiteralNumberOct, nil},
|
||||
{`[-+]?(\d*\.\d+([ed][-+]?\d+)?|\d+(\.\d*)?e[-+]?\d+)`, LiteralNumberFloat, nil},
|
||||
{`[-+]?\d+`, LiteralNumberInteger, nil},
|
||||
{`#x[0-9a-f]+`, LiteralNumberHex, nil},
|
||||
|
||||
{`(\?\\?)([\w!&*<>|^$%@+~?/=-]+)(:)(token|name|variable|expression|body|case-body|\*)`,
|
||||
ByGroups(Operator, NameVariable, Operator, NameBuiltin), nil},
|
||||
{`(\?)(:)(token|name|variable|expression|body|case-body|\*)`,
|
||||
ByGroups(Operator, Operator, NameVariable), nil},
|
||||
{`(\?\\?)([\w!&*<>|^$%@+~?/=-]+)`, ByGroups(Operator, NameVariable), nil},
|
||||
|
||||
{`(=>|::|#\(|#\[|##|\?\?|\?=|\?|[(){}\[\],.;])`, Punctuation, nil},
|
||||
{`:=`, Operator, nil},
|
||||
{`#[tf]`, Literal, nil},
|
||||
{`#"`, LiteralStringSymbol, Push("symbol")},
|
||||
{`#[a-z0-9-]+`, Keyword, nil},
|
||||
{`#(all-keys|include|key|next|rest)`, Keyword, nil},
|
||||
{`[\w!&*<>|^$%@+~?/=-]+:`, KeywordConstant, nil},
|
||||
{`<[\w!&*<>|^$%@+~?/=-]+>`, NameClass, nil},
|
||||
{`\*[\w!&*<>|^$%@+~?/=-]+\*`, NameVariableGlobal, nil},
|
||||
{`\$[\w!&*<>|^$%@+~?/=-]+`, NameConstant, nil},
|
||||
{`(let|method|function)([ \t]+)([\w!&*<>|^$%@+~?/=-]+)`, ByGroups(NameBuiltin, Whitespace, NameVariable), nil},
|
||||
{`(error|signal|return|break)`, NameException, nil},
|
||||
{`(\\?)([\w!&*<>|^$%@+~?/=-]+)`, ByGroups(Operator, Name), nil},
|
||||
},
|
||||
"comment": {
|
||||
{`[^*/]`, CommentMultiline, nil},
|
||||
{`/\*`, CommentMultiline, Push()},
|
||||
{`\*/`, CommentMultiline, Pop(1)},
|
||||
{`[*/]`, CommentMultiline, nil},
|
||||
},
|
||||
"symbol": {
|
||||
{`"`, LiteralStringSymbol, Pop(1)},
|
||||
{`[^\\"]+`, LiteralStringSymbol, nil},
|
||||
},
|
||||
"string": {
|
||||
{`"`, LiteralString, Pop(1)},
|
||||
{`\\([\\abfnrtv"\']|x[a-f0-9]{2,4}|[0-7]{1,3})`, LiteralStringEscape, nil},
|
||||
{`[^\\"\n]+`, LiteralString, nil},
|
||||
{`\\\n`, LiteralString, nil},
|
||||
{`\\`, LiteralString, nil},
|
||||
},
|
||||
}
|
||||
},
|
||||
))
|
||||
Reference in New Issue
Block a user