1
0
Fork 0
forked from forgejo/forgejo

Update Vendor (#16325)

* Add Dependencie Update Script

* update gitea.com/lunny/levelqueue

* 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-redis/redis/v8

* update github.com/hashicorp/golang-lru

* update github.com/klauspost/compress

* update github.com/markbates/goth

* update github.com/mholt/archiver/v3

* update github.com/microcosm-cc/bluemonday

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

* update github.com/olivere/elastic/v7

* update github.com/xanzy/go-gitlab

* update github.com/yuin/goldmark
This commit is contained in:
6543 2021-07-04 04:06:10 +02:00 committed by GitHub
parent 65ae46bc20
commit fae07cbc8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
319 changed files with 33568 additions and 21050 deletions

View file

@ -3,6 +3,9 @@
The tests in this directory feed a known input `testdata/<name>.actual` into the parser for `<name>` and check
that its output matches `<name>.exported`.
It is also possible to perform several tests on a same parser `<name>`, by placing know inputs `*.actual` into a
directory `testdata/<name>/`.
## Running the tests
Run the tests as normal:

View file

@ -10,8 +10,8 @@ var C = internal.Register(MustNewLazyLexer(
&Config{
Name: "C",
Aliases: []string{"c"},
Filenames: []string{"*.c", "*.h", "*.idc"},
MimeTypes: []string{"text/x-chdr", "text/x-csrc"},
Filenames: []string{"*.c", "*.h", "*.idc", "*.x[bp]m"},
MimeTypes: []string{"text/x-chdr", "text/x-csrc", "image/x-xbitmap", "image/x-xpixmap"},
EnsureNL: true,
},
cRules,
@ -43,7 +43,7 @@ func cRules() Rules {
{`[~!%^&*+=|?:<>/-]`, Operator, nil},
{`[()\[\],.]`, Punctuation, nil},
{Words(``, `\b`, `asm`, `auto`, `break`, `case`, `const`, `continue`, `default`, `do`, `else`, `enum`, `extern`, `for`, `goto`, `if`, `register`, `restricted`, `return`, `sizeof`, `static`, `struct`, `switch`, `typedef`, `union`, `volatile`, `while`), Keyword, nil},
{`(bool|int|long|float|short|double|char|unsigned|signed|void)\b`, KeywordType, nil},
{`(bool|int|long|float|short|double|char((8|16|32)_t)?|unsigned|signed|void|u?int(_fast|_least|)(8|16|32|64)_t)\b`, KeywordType, nil},
{Words(``, `\b`, `inline`, `_inline`, `__inline`, `naked`, `restrict`, `thread`, `typename`), KeywordReserved, nil},
{`(__m(128i|128d|128|64))\b`, KeywordReserved, nil},
{Words(`__`, `\b`, `asm`, `int8`, `based`, `except`, `int16`, `stdcall`, `cdecl`, `fastcall`, `int32`, `declspec`, `finally`, `int64`, `try`, `leave`, `wchar_t`, `w64`, `unaligned`, `raise`, `noop`, `identifier`, `forceinline`, `assume`), KeywordReserved, nil},

View file

@ -13,11 +13,12 @@ var PHTML = internal.Register(DelegatingLexer(h.HTML, MustNewLazyLexer(
&Config{
Name: "PHTML",
Aliases: []string{"phtml"},
Filenames: []string{"*.phtml"},
MimeTypes: []string{"application/x-php", "application/x-httpd-php", "application/x-httpd-php3", "application/x-httpd-php4", "application/x-httpd-php5"},
Filenames: []string{"*.phtml", "*.php", "*.php[345]", "*.inc"},
MimeTypes: []string{"application/x-php", "application/x-httpd-php", "application/x-httpd-php3", "application/x-httpd-php4", "application/x-httpd-php5", "text/x-php"},
DotAll: true,
CaseInsensitive: true,
EnsureNL: true,
Priority: 2,
},
phtmlRules,
).SetAnalyser(func(text string) float32 {

View file

@ -6,7 +6,7 @@ import (
)
// Dylan lexer.
var Dylan = internal.Register(MustNewLexer(
var Dylan = internal.Register(MustNewLazyLexer(
&Config{
Name: "Dylan",
Aliases: []string{"dylan"},
@ -14,61 +14,63 @@ var Dylan = internal.Register(MustNewLexer(
MimeTypes: []string{"text/x-dylan"},
CaseInsensitive: true,
},
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},
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},
{`(\?\\?)([\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},
},
{`(=>|::|#\(|#\[|##|\?\?|\?=|\?|[(){}\[\],.;])`, 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},
},
}
},
))

View file

@ -17,11 +17,32 @@ var Fish = internal.Register(MustNewLazyLexer(
))
func fishRules() Rules {
keywords := []string{
`begin`, `end`, `if`, `else`, `while`, `break`, `for`, `return`, `function`, `block`,
`case`, `continue`, `switch`, `not`, `and`, `or`, `set`, `echo`, `exit`, `pwd`, `true`,
`false`, `cd`, `cdh`, `count`, `test`,
}
keywordsPattern := Words(`\b`, `\b`, keywords...)
builtins := []string{
`alias`, `bg`, `bind`, `breakpoint`, `builtin`, `argparse`, `abbr`, `string`, `command`,
`commandline`, `complete`, `contains`, `dirh`, `dirs`, `disown`, `emit`, `eval`, `exec`,
`fg`, `fish`, `fish_add_path`, `fish_breakpoint_prompt`, `fish_command_not_found`,
`fish_config`, `fish_git_prompt`, `fish_greeting`, `fish_hg_prompt`, `fish_indent`,
`fish_is_root_user`, `fish_key_reader`, `fish_mode_prompt`, `fish_opt`, `fish_pager`,
`fish_prompt`, `fish_right_prompt`, `fish_status_to_signal`, `fish_svn_prompt`,
`fish_title`, `fish_update_completions`, `fish_vcs_prompt`, `fishd`, `funced`,
`funcsave`, `functions`, `help`, `history`, `isatty`, `jobs`, `math`, `mimedb`, `nextd`,
`open`, `prompt_pwd`, `realpath`, `popd`, `prevd`, `psub`, `pushd`, `random`, `read`,
`set_color`, `source`, `status`, `suspend`, `trap`, `type`, `ulimit`, `umask`, `vared`,
`fc`, `getopts`, `hash`, `kill`, `printf`, `time`, `wait`,
}
return Rules{
"root": {
Include("basic"),
Include("data"),
Include("interp"),
Include("data"),
},
"interp": {
{`\$\(\(`, Keyword, Push("math")},
@ -29,13 +50,20 @@ func fishRules() Rules {
{`\$#?(\w+|.)`, NameVariable, nil},
},
"basic": {
{`\b(begin|end|if|else|while|break|for|in|return|function|block|case|continue|switch|not|and|or|set|echo|exit|pwd|true|false|cd|count|test)(\s*)\b`, ByGroups(Keyword, Text), nil},
{`\b(alias|bg|bind|breakpoint|builtin|command|commandline|complete|contains|dirh|dirs|emit|eval|exec|fg|fish|fish_config|fish_indent|fish_pager|fish_prompt|fish_right_prompt|fish_update_completions|fishd|funced|funcsave|functions|help|history|isatty|jobs|math|mimedb|nextd|open|popd|prevd|psub|pushd|random|read|set_color|source|status|trap|type|ulimit|umask|vared|fc|getopts|hash|kill|printf|time|wait)\s*\b(?!\.)`, NameBuiltin, nil},
{Words(`(?<=(?:^|\A|;|&&|\|\||\||`+keywordsPattern+`)\s*)`, `(?=;?\b)`, keywords...), Keyword, nil},
{`(?<=for\s+\S+\s+)in\b`, Keyword, nil},
{Words(`\b`, `\s*\b(?!\.)`, builtins...), NameBuiltin, nil},
{`#!.*\n`, CommentHashbang, nil},
{`#.*\n`, Comment, nil},
{`\\[\w\W]`, LiteralStringEscape, nil},
{`(\b\w+)(\s*)(=)`, ByGroups(NameVariable, Text, Operator), nil},
{`[\[\]()=]`, Operator, nil},
{`[\[\]()={}]`, Operator, nil},
{`(?<=\[[^\]]+)\.\.|-(?=[^\[]+\])`, Operator, nil},
{`<<-?\s*(\'?)\\?(\w+)[\w\W]+?\2`, LiteralString, nil},
{`(?<=set\s+(?:--?[^\d\W][\w-]*\s+)?)\w+`, NameVariable, nil},
{`(?<=for\s+)\w[\w-]*(?=\s+in)`, NameVariable, nil},
{`(?<=function\s+)\w(?:[^\n])*?(?= *[-\n])`, NameFunction, nil},
{`(?<=(?:^|\b(?:and|or|sudo)\b|;|\|\||&&|\||\(|(?:\b\w+\s*=\S+\s)) *)\w[\w-]*`, NameFunction, nil},
},
"data": {
{`(?s)\$?"(\\\\|\\[0-7]+|\\.|[^"\\$])*"`, LiteralStringDouble, nil},
@ -43,10 +71,11 @@ func fishRules() Rules {
{`(?s)\$'(\\\\|\\[0-7]+|\\.|[^'\\])*'`, LiteralStringSingle, nil},
{`(?s)'.*?'`, LiteralStringSingle, nil},
{`;`, Punctuation, nil},
{`&|\||\^|<|>`, Operator, nil},
{`&&|\|\||&|\||\^|<|>`, Operator, nil},
{`\s+`, Text, nil},
{`\d+(?= |\Z)`, LiteralNumber, nil},
{"[^=\\s\\[\\]{}()$\"\\'`\\\\<&|;]+", Text, nil},
{`\b\d+\b`, LiteralNumber, nil},
{`--?[^\d][\w-]*`, NameAttribute, nil},
{".+?", Text, nil},
},
"string": {
{`"`, LiteralStringDouble, Pop(1)},

View file

@ -0,0 +1,39 @@
package f
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
// FortranFixed lexer.
var FortranFixed = internal.Register(MustNewLazyLexer(
&Config{
Name: "FortranFixed",
Aliases: []string{"fortranfixed"},
Filenames: []string{"*.f", "*.F"},
MimeTypes: []string{"text/x-fortran"},
NotMultiline: true,
CaseInsensitive: true,
},
func() Rules {
return Rules{
"root": {
{`[C*].*\n`, Comment, nil},
{`#.*\n`, CommentPreproc, nil},
{`[\t ]*!.*\n`, Comment, nil},
{`(.{5})`, NameLabel, Push("cont-char")},
{`.*\n`, Using(Fortran), nil},
},
"cont-char": {
{` `, Text, Push("code")},
{`0`, Comment, Push("code")},
{`.`, GenericStrong, Push("code")},
},
"code": {
{`(.{66})(.*)(\n)`, ByGroups(Using(Fortran), Comment, Text), Push("root")},
{`.*\n`, Using(Fortran), Push("root")},
Default(Push("root")),
},
}
},
))

47
vendor/github.com/alecthomas/chroma/lexers/g/groff.go generated vendored Normal file
View file

@ -0,0 +1,47 @@
package g
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
// Groff lexer.
var Groff = internal.Register(MustNewLazyLexer(
&Config{
Name: "Groff",
Aliases: []string{"groff", "nroff", "man"},
Filenames: []string{"*.[1-9]", "*.1p", "*.3pm", "*.man"},
MimeTypes: []string{"application/x-troff", "text/troff"},
},
func() Rules {
return Rules{
"root": {
{`(\.)(\w+)`, ByGroups(Text, Keyword), Push("request")},
{`\.`, Punctuation, Push("request")},
{`[^\\\n]+`, Text, Push("textline")},
Default(Push("textline")),
},
"textline": {
Include("escapes"),
{`[^\\\n]+`, Text, nil},
{`\n`, Text, Pop(1)},
},
"escapes": {
{`\\"[^\n]*`, Comment, nil},
{`\\[fn]\w`, LiteralStringEscape, nil},
{`\\\(.{2}`, LiteralStringEscape, nil},
{`\\.\[.*\]`, LiteralStringEscape, nil},
{`\\.`, LiteralStringEscape, nil},
{`\\\n`, Text, Push("request")},
},
"request": {
{`\n`, Text, Pop(1)},
Include("escapes"),
{`"[^\n"]+"`, LiteralStringDouble, nil},
{`\d+`, LiteralNumber, nil},
{`\S+`, LiteralString, nil},
{`\s+`, Text, nil},
},
}
},
))

View file

@ -37,14 +37,14 @@ func httpRules() Rules {
}
}
func httpContentBlock(groups []string, lexer Lexer) Iterator {
func httpContentBlock(groups []string, state *LexerState) Iterator {
tokens := []Token{
{Generic, groups[0]},
}
return Literator(tokens...)
}
func httpHeaderBlock(groups []string, lexer Lexer) Iterator {
func httpHeaderBlock(groups []string, state *LexerState) Iterator {
tokens := []Token{
{Name, groups[1]},
{Text, groups[2]},
@ -56,7 +56,7 @@ func httpHeaderBlock(groups []string, lexer Lexer) Iterator {
return Literator(tokens...)
}
func httpContinuousHeaderBlock(groups []string, lexer Lexer) Iterator {
func httpContinuousHeaderBlock(groups []string, state *LexerState) Iterator {
tokens := []Token{
{Text, groups[1]},
{Literal, groups[2]},

View file

@ -11,6 +11,19 @@ import (
"github.com/alecthomas/chroma"
)
var (
ignoredSuffixes = [...]string{
// Editor backups
"~", ".bak", ".old", ".orig",
// Debian and derivatives apt/dpkg backups
".dpkg-dist", ".dpkg-old",
// Red Hat and derivatives rpm backups
".rpmnew", ".rpmorig", ".rpmsave",
// Build system input/template files
".in",
}
)
// Registry of Lexers.
var Registry = struct {
Lexers chroma.Lexers
@ -93,6 +106,13 @@ func Match(filename string) chroma.Lexer {
for _, glob := range config.Filenames {
if fnmatch.Match(glob, filename, 0) {
matched = append(matched, lexer)
} else {
for _, suf := range &ignoredSuffixes {
if fnmatch.Match(glob+suf, filename, 0) {
matched = append(matched, lexer)
break
}
}
}
}
}
@ -107,6 +127,13 @@ func Match(filename string) chroma.Lexer {
for _, glob := range config.AliasFilenames {
if fnmatch.Match(glob, filename, 0) {
matched = append(matched, lexer)
} else {
for _, suf := range &ignoredSuffixes {
if fnmatch.Match(glob+suf, filename, 0) {
matched = append(matched, lexer)
break
}
}
}
}
}

View file

@ -61,7 +61,7 @@ var JavascriptRules = Rules{
}
// Javascript lexer.
var Javascript = internal.Register(MustNewLexer(
var Javascript = internal.Register(MustNewLexer( // nolint: forbidigo
&Config{
Name: "JavaScript",
Aliases: []string{"js", "javascript"},

View file

@ -3,7 +3,7 @@
// Sub-packages contain lexer implementations.
package lexers
// nolint: golint
// nolint
import (
"github.com/alecthomas/chroma"
_ "github.com/alecthomas/chroma/lexers/a"

View file

@ -40,7 +40,7 @@ func markdownRules() Rules {
},
"inline": {
{`\\.`, Text, nil},
{`(\s)([*_][^*_]+[*_])(\W|\n)`, ByGroups(Text, GenericEmph, Text), nil},
{`(\s)(\*|_)((?:(?!\2).)*)(\2)((?=\W|\n))`, ByGroups(Text, GenericEmph, GenericEmph, GenericEmph, Text), nil},
{`(\s)((\*\*|__).*?)\3((?=\W|\n))`, ByGroups(Text, GenericStrong, GenericStrong, Text), nil},
{`(\s)(~~[^~]+~~)((?=\W|\n))`, ByGroups(Text, GenericDeleted, Text), nil},
{"`[^`]+`", LiteralStringBacktick, nil},

View file

@ -6,7 +6,7 @@ import (
)
// mcfunction lexer.
var MCFunction = internal.Register(MustNewLexer(
var MCFunction = internal.Register(MustNewLazyLexer(
&Config{
Name: "mcfunction",
Aliases: []string{"mcfunction"},
@ -15,93 +15,95 @@ var MCFunction = internal.Register(MustNewLexer(
NotMultiline: true,
DotAll: true,
},
Rules{
"simplevalue": {
{`(true|false)`, KeywordConstant, nil},
{`[01]b`, LiteralNumber, nil},
{`-?(0|[1-9]\d*)(\.\d+[eE](\+|-)?\d+|[eE](\+|-)?\d+|\.\d+)`, LiteralNumberFloat, nil},
{`(-?\d+)(\.\.)(-?\d+)`, ByGroups(LiteralNumberInteger, Punctuation, LiteralNumberInteger), nil},
{`-?(0|[1-9]\d*)`, LiteralNumberInteger, nil},
{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
{`'[^']+'`, LiteralStringSingle, nil},
{`([!#]?)(\w+)`, ByGroups(Punctuation, Text), nil},
},
"nbtobjectattribute": {
Include("nbtvalue"),
{`:`, Punctuation, nil},
{`,`, Punctuation, Pop(1)},
{`\}`, Punctuation, Pop(2)},
},
"nbtobjectvalue": {
{`("(\\\\|\\"|[^"])*"|[a-zA-Z0-9_]+)`, NameTag, Push("nbtobjectattribute")},
{`\}`, Punctuation, Pop(1)},
},
"nbtarrayvalue": {
Include("nbtvalue"),
{`,`, Punctuation, nil},
{`\]`, Punctuation, Pop(1)},
},
"nbtvalue": {
Include("simplevalue"),
{`\{`, Punctuation, Push("nbtobjectvalue")},
{`\[`, Punctuation, Push("nbtarrayvalue")},
},
"argumentvalue": {
Include("simplevalue"),
{`,`, Punctuation, Pop(1)},
{`[}\]]`, Punctuation, Pop(2)},
},
"argumentlist": {
{`(nbt)(={)`, ByGroups(NameAttribute, Punctuation), Push("nbtobjectvalue")},
{`([A-Za-z0-9/_!]+)(={)`, ByGroups(NameAttribute, Punctuation), Push("argumentlist")},
{`([A-Za-z0-9/_!]+)(=)`, ByGroups(NameAttribute, Punctuation), Push("argumentvalue")},
Include("simplevalue"),
{`,`, Punctuation, nil},
{`[}\]]`, Punctuation, Pop(1)},
},
"root": {
{`#.*?\n`, CommentSingle, nil},
{Words(`/?`, `\b`, `ability`, `attributes`, `advancement`,
`ban`, `ban-ip`, `banlist`, `bossbar`,
`camerashake`, `classroommode`, `clear`,
`clearspawnpoint`, `clone`, `code`, `collect`,
`createagent`, `data`, `datapack`, `debug`,
`defaultgamemode`, `deop`, `destroy`, `detect`,
`detectredstone`, `difficulty`, `dropall`,
`effect`, `enchant`, `event`, `execute`,
`experience`, `fill`, `flog`, `forceload`,
`function`, `gamemode`, `gamerule`,
`geteduclientinfo`, `give`, `help`, `item`,
`immutableworld`, `kick`, `kill`, `list`,
`locate`, `locatebiome`, `loot`, `me`, `mixer`,
`mobevent`, `move`, `msg`, `music`, `op`,
`pardon`, `particle`, `playanimation`,
`playsound`, `position`, `publish`,
`raytracefog`, `recipe`, `reload`, `remove`,
`replaceitem`, `ride`, `save`, `save-all`,
`save-off`, `save-on`, `say`, `schedule`,
`scoreboard`, `seed`, `setblock`,
`setidletimeout`, `setmaxplayers`,
`setworldspawn`, `spawnpoint`, `spectate`,
`spreadplayers`, `stop`, `stopsound`,
`structure`, `summon`, `tag`, `team`, `teammsg`,
`teleport`, `tell`, `tellraw`, `testfor`,
`testforblock`, `testforblocks`, `tickingarea`,
`time`, `title`, `toggledownfall`, `tp`,
`tpagent`, `transfer`, `transferserver`,
`trigger`, `turn`, `w`, `weather`, `whitelist`,
`worldborder`, `worldbuilder`, `wsserver`, `xp`,
), KeywordReserved, nil},
{Words(``, ``, `@p`, `@r`, `@a`, `@e`, `@s`, `@c`, `@v`),
KeywordConstant, nil},
{`\[`, Punctuation, Push("argumentlist")},
{`{`, Punctuation, Push("nbtobjectvalue")},
{`~`, NameBuiltin, nil},
{`([a-zA-Z_]+:)?[a-zA-Z_]+\b`, Text, nil},
{`([a-z]+)(\.)([0-9]+)\b`, ByGroups(Text, Punctuation, LiteralNumber), nil},
{`([<>=]|<=|>=)`, Punctuation, nil},
Include("simplevalue"),
{`\s+`, TextWhitespace, nil},
},
func() Rules {
return Rules{
"simplevalue": {
{`(true|false)`, KeywordConstant, nil},
{`[01]b`, LiteralNumber, nil},
{`-?(0|[1-9]\d*)(\.\d+[eE](\+|-)?\d+|[eE](\+|-)?\d+|\.\d+)`, LiteralNumberFloat, nil},
{`(-?\d+)(\.\.)(-?\d+)`, ByGroups(LiteralNumberInteger, Punctuation, LiteralNumberInteger), nil},
{`-?(0|[1-9]\d*)`, LiteralNumberInteger, nil},
{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
{`'[^']+'`, LiteralStringSingle, nil},
{`([!#]?)(\w+)`, ByGroups(Punctuation, Text), nil},
},
"nbtobjectattribute": {
Include("nbtvalue"),
{`:`, Punctuation, nil},
{`,`, Punctuation, Pop(1)},
{`\}`, Punctuation, Pop(2)},
},
"nbtobjectvalue": {
{`("(\\\\|\\"|[^"])*"|[a-zA-Z0-9_]+)`, NameTag, Push("nbtobjectattribute")},
{`\}`, Punctuation, Pop(1)},
},
"nbtarrayvalue": {
Include("nbtvalue"),
{`,`, Punctuation, nil},
{`\]`, Punctuation, Pop(1)},
},
"nbtvalue": {
Include("simplevalue"),
{`\{`, Punctuation, Push("nbtobjectvalue")},
{`\[`, Punctuation, Push("nbtarrayvalue")},
},
"argumentvalue": {
Include("simplevalue"),
{`,`, Punctuation, Pop(1)},
{`[}\]]`, Punctuation, Pop(2)},
},
"argumentlist": {
{`(nbt)(={)`, ByGroups(NameAttribute, Punctuation), Push("nbtobjectvalue")},
{`([A-Za-z0-9/_!]+)(={)`, ByGroups(NameAttribute, Punctuation), Push("argumentlist")},
{`([A-Za-z0-9/_!]+)(=)`, ByGroups(NameAttribute, Punctuation), Push("argumentvalue")},
Include("simplevalue"),
{`,`, Punctuation, nil},
{`[}\]]`, Punctuation, Pop(1)},
},
"root": {
{`#.*?\n`, CommentSingle, nil},
{Words(`/?`, `\b`, `ability`, `attributes`, `advancement`,
`ban`, `ban-ip`, `banlist`, `bossbar`,
`camerashake`, `classroommode`, `clear`,
`clearspawnpoint`, `clone`, `code`, `collect`,
`createagent`, `data`, `datapack`, `debug`,
`defaultgamemode`, `deop`, `destroy`, `detect`,
`detectredstone`, `difficulty`, `dropall`,
`effect`, `enchant`, `event`, `execute`,
`experience`, `fill`, `flog`, `forceload`,
`function`, `gamemode`, `gamerule`,
`geteduclientinfo`, `give`, `help`, `item`,
`immutableworld`, `kick`, `kill`, `list`,
`locate`, `locatebiome`, `loot`, `me`, `mixer`,
`mobevent`, `move`, `msg`, `music`, `op`,
`pardon`, `particle`, `playanimation`,
`playsound`, `position`, `publish`,
`raytracefog`, `recipe`, `reload`, `remove`,
`replaceitem`, `ride`, `save`, `save-all`,
`save-off`, `save-on`, `say`, `schedule`,
`scoreboard`, `seed`, `setblock`,
`setidletimeout`, `setmaxplayers`,
`setworldspawn`, `spawnpoint`, `spectate`,
`spreadplayers`, `stop`, `stopsound`,
`structure`, `summon`, `tag`, `team`, `teammsg`,
`teleport`, `tell`, `tellraw`, `testfor`,
`testforblock`, `testforblocks`, `tickingarea`,
`time`, `title`, `toggledownfall`, `tp`,
`tpagent`, `transfer`, `transferserver`,
`trigger`, `turn`, `w`, `weather`, `whitelist`,
`worldborder`, `worldbuilder`, `wsserver`, `xp`,
), KeywordReserved, nil},
{Words(``, ``, `@p`, `@r`, `@a`, `@e`, `@s`, `@c`, `@v`),
KeywordConstant, nil},
{`\[`, Punctuation, Push("argumentlist")},
{`{`, Punctuation, Push("nbtobjectvalue")},
{`~`, NameBuiltin, nil},
{`([a-zA-Z_]+:)?[a-zA-Z_]+\b`, Text, nil},
{`([a-z]+)(\.)([0-9]+)\b`, ByGroups(Text, Punctuation, LiteralNumber), nil},
{`([<>=]|<=|>=)`, Punctuation, nil},
Include("simplevalue"),
{`\s+`, TextWhitespace, nil},
},
}
},
))

101
vendor/github.com/alecthomas/chroma/lexers/m/metal.go generated vendored Normal file
View file

@ -0,0 +1,101 @@
package m
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
// Metal lexer.
var Metal = internal.Register(MustNewLazyLexer(
&Config{
Name: "Metal",
Aliases: []string{"metal"},
Filenames: []string{"*.metal"},
MimeTypes: []string{"text/x-metal"},
EnsureNL: true,
},
metalRules,
))
func metalRules() Rules {
return Rules{
"statements": {
{Words(``, `\b`, `namespace`, `operator`, `template`, `this`, `using`, `constexpr`), Keyword, nil},
{`(enum)\b(\s+)(class)\b(\s*)`, ByGroups(Keyword, Text, Keyword, Text), Push("classname")},
{`(class|struct|enum|union)\b(\s*)`, ByGroups(Keyword, Text), Push("classname")},
{`\[\[.+\]\]`, NameAttribute, nil},
{`(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*`, LiteralNumberFloat, nil},
{`(\d+\.\d*|\.\d+|\d+[fF])[fF]?`, LiteralNumberFloat, nil},
{`0[xX]([0-9A-Fa-f]('?[0-9A-Fa-f]+)*)[LlUu]*`, LiteralNumberHex, nil},
{`0('?[0-7]+)+[LlUu]*`, LiteralNumberOct, nil},
{`0[Bb][01]('?[01]+)*[LlUu]*`, LiteralNumberBin, nil},
{`[0-9]('?[0-9]+)*[LlUu]*`, LiteralNumberInteger, nil},
{`\*/`, Error, nil},
{`[~!%^&*+=|?:<>/-]`, Operator, nil},
{`[()\[\],.]`, Punctuation, nil},
{Words(``, `\b`, `break`, `case`, `const`, `continue`, `do`, `else`, `enum`, `extern`, `for`, `if`, `return`, `sizeof`, `static`, `struct`, `switch`, `typedef`, `union`, `while`), Keyword, nil},
{`(bool|float|half|long|ptrdiff_t|size_t|unsigned|u?char|u?int((8|16|32|64)_t)?|u?short)\b`, KeywordType, nil},
{`(bool|float|half|u?(char|int|long|short))(2|3|4)\b`, KeywordType, nil},
{`packed_(float|half|long|u?(char|int|short))(2|3|4)\b`, KeywordType, nil},
{`(float|half)(2|3|4)x(2|3|4)\b`, KeywordType, nil},
{`atomic_u?int\b`, KeywordType, nil},
{`(rg?(8|16)(u|s)norm|rgba(8|16)(u|s)norm|srgba8unorm|rgb10a2|rg11b10f|rgb9e5)\b`, KeywordType, nil},
{`(array|depth(2d|cube)(_array)?|depth2d_ms(_array)?|sampler|texture_buffer|texture(1|2)d(_array)?|texture2d_ms(_array)?|texture3d|texturecube(_array)?|uniform|visible_function_table)\b`, KeywordType, nil},
{`(true|false|NULL)\b`, NameBuiltin, nil},
{Words(``, `\b`, `device`, `constant`, `ray_data`, `thread`, `threadgroup`, `threadgroup_imageblock`), Keyword, nil},
{`([a-zA-Z_]\w*)(\s*)(:)(?!:)`, ByGroups(NameLabel, Text, Punctuation), nil},
{`[a-zA-Z_]\w*`, Name, nil},
},
"root": {
Include("whitespace"),
{`(fragment|kernel|vertex)?((?:[\w*\s])+?(?:\s|[*]))([a-zA-Z_]\w*)(\s*\([^;]*?\))([^;{]*)(\{)`, ByGroups(Keyword, UsingSelf("root"), NameFunction, UsingSelf("root"), UsingSelf("root"), Punctuation), Push("function")},
{`(fragment|kernel|vertex)?((?:[\w*\s])+?(?:\s|[*]))([a-zA-Z_]\w*)(\s*\([^;]*?\))([^;]*)(;)`, ByGroups(Keyword, UsingSelf("root"), NameFunction, UsingSelf("root"), UsingSelf("root"), Punctuation), nil},
Default(Push("statement")),
},
"classname": {
{`(\[\[.+\]\])(\s*)`, ByGroups(NameAttribute, Text), nil},
{`[a-zA-Z_]\w*`, NameClass, Pop(1)},
{`\s*(?=[>{])`, Text, Pop(1)},
},
"whitespace": {
{`^#if\s+0`, CommentPreproc, Push("if0")},
{`^#`, CommentPreproc, Push("macro")},
{`^(\s*(?:/[*].*?[*]/\s*)?)(#if\s+0)`, ByGroups(UsingSelf("root"), CommentPreproc), Push("if0")},
{`^(\s*(?:/[*].*?[*]/\s*)?)(#)`, ByGroups(UsingSelf("root"), CommentPreproc), Push("macro")},
{`\n`, Text, nil},
{`\s+`, Text, nil},
{`\\\n`, Text, nil},
{`//(\n|[\w\W]*?[^\\]\n)`, CommentSingle, nil},
{`/(\\\n)?[*][\w\W]*?[*](\\\n)?/`, CommentMultiline, nil},
{`/(\\\n)?[*][\w\W]*`, CommentMultiline, nil},
},
"statement": {
Include("whitespace"),
Include("statements"),
{`[{]`, Punctuation, Push("root")},
{`[;}]`, Punctuation, Pop(1)},
},
"function": {
Include("whitespace"),
Include("statements"),
{`;`, Punctuation, nil},
{`\{`, Punctuation, Push()},
{`\}`, Punctuation, Pop(1)},
},
"macro": {
{`(include)(\s*(?:/[*].*?[*]/\s*)?)([^\n]+)`, ByGroups(CommentPreproc, Text, CommentPreprocFile), nil},
{`[^/\n]+`, CommentPreproc, nil},
{`/[*](.|\n)*?[*]/`, CommentMultiline, nil},
{`//.*?\n`, CommentSingle, Pop(1)},
{`/`, CommentPreproc, nil},
{`(?<=\\)\n`, CommentPreproc, nil},
{`\n`, CommentPreproc, Pop(1)},
},
"if0": {
{`^\s*#if.*?(?<!\\)\n`, CommentPreproc, Push()},
{`^\s*#el(?:se|if).*\n`, CommentPreproc, Pop(1)},
{`^\s*#endif.*?(?<!\\)\n`, CommentPreproc, Pop(1)},
{`.*?\n`, Comment, nil},
},
}
}

View file

@ -22,13 +22,13 @@ func myghtyRules() Rules {
"root": {
{`\s+`, Text, nil},
{`(<%(?:def|method))(\s*)(.*?)(>)(.*?)(</%\2\s*>)(?s)`, ByGroups(NameTag, Text, NameFunction, NameTag, UsingSelf("root"), NameTag), nil},
{`(<%\w+)(.*?)(>)(.*?)(</%\2\s*>)(?s)`, ByGroups(NameTag, NameFunction, NameTag, Using(Python), NameTag), nil},
{`(<&[^|])(.*?)(,.*?)?(&>)`, ByGroups(NameTag, NameFunction, Using(Python), NameTag), nil},
{`(<&\|)(.*?)(,.*?)?(&>)(?s)`, ByGroups(NameTag, NameFunction, Using(Python), NameTag), nil},
{`(<%\w+)(.*?)(>)(.*?)(</%\2\s*>)(?s)`, ByGroups(NameTag, NameFunction, NameTag, Using(Python2), NameTag), nil},
{`(<&[^|])(.*?)(,.*?)?(&>)`, ByGroups(NameTag, NameFunction, Using(Python2), NameTag), nil},
{`(<&\|)(.*?)(,.*?)?(&>)(?s)`, ByGroups(NameTag, NameFunction, Using(Python2), NameTag), nil},
{`</&>`, NameTag, nil},
{`(<%!?)(.*?)(%>)(?s)`, ByGroups(NameTag, Using(Python), NameTag), nil},
{`(<%!?)(.*?)(%>)(?s)`, ByGroups(NameTag, Using(Python2), NameTag), nil},
{`(?<=^)#[^\n]*(\n|\Z)`, Comment, nil},
{`(?<=^)(%)([^\n]*)(\n|\Z)`, ByGroups(NameTag, Using(Python), Other), nil},
{`(?<=^)(%)([^\n]*)(\n|\Z)`, ByGroups(NameTag, Using(Python2), Other), nil},
{`(?sx)
(.+?) # anything, followed by:
(?:

View file

@ -1,10 +1,17 @@
package m
import (
"regexp"
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
var (
mysqlAnalyserNameBetweenBacktickRe = regexp.MustCompile("`[a-zA-Z_]\\w*`")
mysqlAnalyserNameBetweenBracketRe = regexp.MustCompile(`\[[a-zA-Z_]\w*\]`)
)
// MySQL lexer.
var MySQL = internal.Register(MustNewLazyLexer(
&Config{
@ -16,7 +23,25 @@ var MySQL = internal.Register(MustNewLazyLexer(
CaseInsensitive: true,
},
mySQLRules,
))
).SetAnalyser(func(text string) float32 {
nameBetweenBacktickCount := len(mysqlAnalyserNameBetweenBacktickRe.FindAllString(text, -1))
nameBetweenBracketCount := len(mysqlAnalyserNameBetweenBracketRe.FindAllString(text, -1))
var result float32
// Same logic as above in the TSQL analysis.
dialectNameCount := nameBetweenBacktickCount + nameBetweenBracketCount
if dialectNameCount >= 1 && nameBetweenBacktickCount >= (2*nameBetweenBracketCount) {
// Found at least twice as many `name` as [name].
result += 0.5
} else if nameBetweenBacktickCount > nameBetweenBracketCount {
result += 0.2
} else if nameBetweenBacktickCount > 0 {
result += 0.1
}
return result
}))
func mySQLRules() Rules {
return Rules{

View file

@ -0,0 +1,38 @@
package p
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
// PowerQuery lexer.
var PowerQuery = internal.Register(MustNewLazyLexer(
&Config{
Name: "PowerQuery",
Aliases: []string{"powerquery", "pq"},
Filenames: []string{"*.pq"},
MimeTypes: []string{"text/x-powerquery"},
DotAll: true,
CaseInsensitive: true,
},
powerqueryRules,
))
func powerqueryRules() Rules {
return Rules{
"root": {
{`\s+`, Text, nil},
{`//.*?\n`, CommentSingle, nil},
{`/\*.*?\*/`, CommentMultiline, nil},
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
{`(and|as|each|else|error|false|if|in|is|let|meta|not|null|or|otherwise|section|shared|then|true|try|type)\b`, Keyword, nil},
{`(#binary|#date|#datetime|#datetimezone|#duration|#infinity|#nan|#sections|#shared|#table|#time)\b`, KeywordType, nil},
{`(([a-zA-Z]|_)[\w|._]*|#"[^"]+")`, Name, nil},
{`0[xX][0-9a-fA-F][0-9a-fA-F_]*[lL]?`, LiteralNumberHex, nil},
{`([0-9]+\.[0-9]+|\.[0-9]+)([eE][0-9]+)?`, LiteralNumberFloat, nil},
{`[0-9]+`, LiteralNumberInteger, nil},
{`[\(\)\[\]\{\}]`, Punctuation, nil},
{`\.\.|\.\.\.|=>|<=|>=|<>|[@!?,;=<>\+\-\*\/&]`, Operator, nil},
},
}
}

File diff suppressed because one or more lines are too long

141
vendor/github.com/alecthomas/chroma/lexers/p/python2.go generated vendored Normal file
View file

@ -0,0 +1,141 @@
package p
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
// Python2 lexer.
var Python2 = internal.Register(MustNewLazyLexer(
&Config{
Name: "Python 2",
Aliases: []string{"python2", "py2"},
Filenames: []string{},
MimeTypes: []string{"text/x-python2", "application/x-python2"},
},
python2Rules,
))
func python2Rules() Rules {
return Rules{
"root": {
{`\n`, Text, nil},
{`^(\s*)([rRuUbB]{,2})("""(?:.|\n)*?""")`, ByGroups(Text, LiteralStringAffix, LiteralStringDoc), nil},
{`^(\s*)([rRuUbB]{,2})('''(?:.|\n)*?''')`, ByGroups(Text, LiteralStringAffix, LiteralStringDoc), nil},
{`[^\S\n]+`, Text, nil},
{`\A#!.+$`, CommentHashbang, nil},
{`#.*$`, CommentSingle, nil},
{`[]{}:(),;[]`, Punctuation, nil},
{`\\\n`, Text, nil},
{`\\`, Text, nil},
{`(in|is|and|or|not)\b`, OperatorWord, nil},
{`!=|==|<<|>>|[-~+/*%=<>&^|.]`, Operator, nil},
Include("keywords"),
{`(def)((?:\s|\\\s)+)`, ByGroups(Keyword, Text), Push("funcname")},
{`(class)((?:\s|\\\s)+)`, ByGroups(Keyword, Text), Push("classname")},
{`(from)((?:\s|\\\s)+)`, ByGroups(KeywordNamespace, Text), Push("fromimport")},
{`(import)((?:\s|\\\s)+)`, ByGroups(KeywordNamespace, Text), Push("import")},
Include("builtins"),
Include("magicfuncs"),
Include("magicvars"),
Include("backtick"),
{`([rR]|[uUbB][rR]|[rR][uUbB])(""")`, ByGroups(LiteralStringAffix, LiteralStringDouble), Push("tdqs")},
{`([rR]|[uUbB][rR]|[rR][uUbB])(''')`, ByGroups(LiteralStringAffix, LiteralStringSingle), Push("tsqs")},
{`([rR]|[uUbB][rR]|[rR][uUbB])(")`, ByGroups(LiteralStringAffix, LiteralStringDouble), Push("dqs")},
{`([rR]|[uUbB][rR]|[rR][uUbB])(')`, ByGroups(LiteralStringAffix, LiteralStringSingle), Push("sqs")},
{`([uUbB]?)(""")`, ByGroups(LiteralStringAffix, LiteralStringDouble), Combined("stringescape", "tdqs")},
{`([uUbB]?)(''')`, ByGroups(LiteralStringAffix, LiteralStringSingle), Combined("stringescape", "tsqs")},
{`([uUbB]?)(")`, ByGroups(LiteralStringAffix, LiteralStringDouble), Combined("stringescape", "dqs")},
{`([uUbB]?)(')`, ByGroups(LiteralStringAffix, LiteralStringSingle), Combined("stringescape", "sqs")},
Include("name"),
Include("numbers"),
},
"keywords": {
{Words(``, `\b`, `assert`, `break`, `continue`, `del`, `elif`, `else`, `except`, `exec`, `finally`, `for`, `global`, `if`, `lambda`, `pass`, `print`, `raise`, `return`, `try`, `while`, `yield`, `yield from`, `as`, `with`), Keyword, nil},
},
"builtins": {
{Words(`(?<!\.)`, `\b`, `__import__`, `abs`, `all`, `any`, `apply`, `basestring`, `bin`, `bool`, `buffer`, `bytearray`, `bytes`, `callable`, `chr`, `classmethod`, `cmp`, `coerce`, `compile`, `complex`, `delattr`, `dict`, `dir`, `divmod`, `enumerate`, `eval`, `execfile`, `exit`, `file`, `filter`, `float`, `frozenset`, `getattr`, `globals`, `hasattr`, `hash`, `hex`, `id`, `input`, `int`, `intern`, `isinstance`, `issubclass`, `iter`, `len`, `list`, `locals`, `long`, `map`, `max`, `min`, `next`, `object`, `oct`, `open`, `ord`, `pow`, `property`, `range`, `raw_input`, `reduce`, `reload`, `repr`, `reversed`, `round`, `set`, `setattr`, `slice`, `sorted`, `staticmethod`, `str`, `sum`, `super`, `tuple`, `type`, `unichr`, `unicode`, `vars`, `xrange`, `zip`), NameBuiltin, nil},
{`(?<!\.)(self|None|Ellipsis|NotImplemented|False|True|cls)\b`, NameBuiltinPseudo, nil},
{Words(`(?<!\.)`, `\b`, `ArithmeticError`, `AssertionError`, `AttributeError`, `BaseException`, `DeprecationWarning`, `EOFError`, `EnvironmentError`, `Exception`, `FloatingPointError`, `FutureWarning`, `GeneratorExit`, `IOError`, `ImportError`, `ImportWarning`, `IndentationError`, `IndexError`, `KeyError`, `KeyboardInterrupt`, `LookupError`, `MemoryError`, `NameError`, `NotImplementedError`, `OSError`, `OverflowError`, `OverflowWarning`, `PendingDeprecationWarning`, `ReferenceError`, `RuntimeError`, `RuntimeWarning`, `StandardError`, `StopIteration`, `SyntaxError`, `SyntaxWarning`, `SystemError`, `SystemExit`, `TabError`, `TypeError`, `UnboundLocalError`, `UnicodeDecodeError`, `UnicodeEncodeError`, `UnicodeError`, `UnicodeTranslateError`, `UnicodeWarning`, `UserWarning`, `ValueError`, `VMSError`, `Warning`, `WindowsError`, `ZeroDivisionError`), NameException, nil},
},
"magicfuncs": {
{Words(``, `\b`, `__abs__`, `__add__`, `__and__`, `__call__`, `__cmp__`, `__coerce__`, `__complex__`, `__contains__`, `__del__`, `__delattr__`, `__delete__`, `__delitem__`, `__delslice__`, `__div__`, `__divmod__`, `__enter__`, `__eq__`, `__exit__`, `__float__`, `__floordiv__`, `__ge__`, `__get__`, `__getattr__`, `__getattribute__`, `__getitem__`, `__getslice__`, `__gt__`, `__hash__`, `__hex__`, `__iadd__`, `__iand__`, `__idiv__`, `__ifloordiv__`, `__ilshift__`, `__imod__`, `__imul__`, `__index__`, `__init__`, `__instancecheck__`, `__int__`, `__invert__`, `__iop__`, `__ior__`, `__ipow__`, `__irshift__`, `__isub__`, `__iter__`, `__itruediv__`, `__ixor__`, `__le__`, `__len__`, `__long__`, `__lshift__`, `__lt__`, `__missing__`, `__mod__`, `__mul__`, `__ne__`, `__neg__`, `__new__`, `__nonzero__`, `__oct__`, `__op__`, `__or__`, `__pos__`, `__pow__`, `__radd__`, `__rand__`, `__rcmp__`, `__rdiv__`, `__rdivmod__`, `__repr__`, `__reversed__`, `__rfloordiv__`, `__rlshift__`, `__rmod__`, `__rmul__`, `__rop__`, `__ror__`, `__rpow__`, `__rrshift__`, `__rshift__`, `__rsub__`, `__rtruediv__`, `__rxor__`, `__set__`, `__setattr__`, `__setitem__`, `__setslice__`, `__str__`, `__sub__`, `__subclasscheck__`, `__truediv__`, `__unicode__`, `__xor__`), NameFunctionMagic, nil},
},
"magicvars": {
{Words(``, `\b`, `__bases__`, `__class__`, `__closure__`, `__code__`, `__defaults__`, `__dict__`, `__doc__`, `__file__`, `__func__`, `__globals__`, `__metaclass__`, `__module__`, `__mro__`, `__name__`, `__self__`, `__slots__`, `__weakref__`), NameVariableMagic, nil},
},
"numbers": {
{`(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?`, LiteralNumberFloat, nil},
{`\d+[eE][+-]?[0-9]+j?`, LiteralNumberFloat, nil},
{`0[0-7]+j?`, LiteralNumberOct, nil},
{`0[bB][01]+`, LiteralNumberBin, nil},
{`0[xX][a-fA-F0-9]+`, LiteralNumberHex, nil},
{`\d+L`, LiteralNumberIntegerLong, nil},
{`\d+j?`, LiteralNumberInteger, nil},
},
"backtick": {
{"`.*?`", LiteralStringBacktick, nil},
},
"name": {
{`@[\w.]+`, NameDecorator, nil},
{`[a-zA-Z_]\w*`, Name, nil},
},
"funcname": {
Include("magicfuncs"),
{`[a-zA-Z_]\w*`, NameFunction, Pop(1)},
Default(Pop(1)),
},
"classname": {
{`[a-zA-Z_]\w*`, NameClass, Pop(1)},
},
"import": {
{`(?:[ \t]|\\\n)+`, Text, nil},
{`as\b`, KeywordNamespace, nil},
{`,`, Operator, nil},
{`[a-zA-Z_][\w.]*`, NameNamespace, nil},
Default(Pop(1)),
},
"fromimport": {
{`(?:[ \t]|\\\n)+`, Text, nil},
{`import\b`, KeywordNamespace, Pop(1)},
{`None\b`, NameBuiltinPseudo, Pop(1)},
{`[a-zA-Z_.][\w.]*`, NameNamespace, nil},
Default(Pop(1)),
},
"stringescape": {
{`\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})`, LiteralStringEscape, nil},
},
"strings-single": {
{`%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsux%]`, LiteralStringInterpol, nil},
{`[^\\\'"%\n]+`, LiteralStringSingle, nil},
{`[\'"\\]`, LiteralStringSingle, nil},
{`%`, LiteralStringSingle, nil},
},
"strings-double": {
{`%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsux%]`, LiteralStringInterpol, nil},
{`[^\\\'"%\n]+`, LiteralStringDouble, nil},
{`[\'"\\]`, LiteralStringDouble, nil},
{`%`, LiteralStringDouble, nil},
},
"dqs": {
{`"`, LiteralStringDouble, Pop(1)},
{`\\\\|\\"|\\\n`, LiteralStringEscape, nil},
Include("strings-double"),
},
"sqs": {
{`'`, LiteralStringSingle, Pop(1)},
{`\\\\|\\'|\\\n`, LiteralStringEscape, nil},
Include("strings-single"),
},
"tdqs": {
{`"""`, LiteralStringDouble, Pop(1)},
Include("strings-double"),
{`\n`, LiteralStringDouble, nil},
},
"tsqs": {
{`'''`, LiteralStringSingle, Pop(1)},
Include("strings-single"),
{`\n`, LiteralStringSingle, nil},
},
}
}

File diff suppressed because one or more lines are too long

1496
vendor/github.com/alecthomas/chroma/lexers/r/raku.go generated vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -63,7 +63,7 @@ func restructuredtextRules() Rules {
}
}
func rstCodeBlock(groups []string, lexer Lexer) Iterator {
func rstCodeBlock(groups []string, state *LexerState) Iterator {
iterators := []Iterator{}
tokens := []Token{
{Punctuation, groups[1]},
@ -75,7 +75,7 @@ func rstCodeBlock(groups []string, lexer Lexer) Iterator {
{Text, groups[7]},
}
code := strings.Join(groups[8:], "")
lexer = internal.Get(groups[6])
lexer := internal.Get(groups[6])
if lexer == nil {
tokens = append(tokens, Token{String, code})
iterators = append(iterators, Literator(tokens...))

File diff suppressed because one or more lines are too long

View file

@ -39,17 +39,16 @@ func solidityRules() Rules {
{`/[*][\w\W]*`, CommentMultiline, nil},
},
"keywords-other": {
{Words(``, `\b`, `for`, `in`, `while`, `do`, `break`, `return`, `returns`, `continue`, `if`, `else`, `throw`, `new`, `delete`), Keyword, nil},
{Words(``, `\b`, `for`, `in`, `while`, `do`, `break`, `return`, `returns`, `continue`, `if`, `else`, `try`, `catch`, `throw`, `_`, `new`, `delete`, `is`, `as`, `from`, `memory`, `storage`), Keyword, nil},
{`assembly\b`, Keyword, Push("assembly")},
{Words(``, `\b`, `contract`, `interface`, `enum`, `event`, `function`, `library`, `mapping`, `modifier`, `struct`, `var`), KeywordDeclaration, nil},
{`(contract|interface|enum|event|struct)(\s+)([a-zA-Z_]\w*)`, ByGroups(KeywordDeclaration, Text, NameClass), nil},
{`(function|modifier)(\s+)([a-zA-Z_]\w*)`, ByGroups(KeywordDeclaration, Text, NameFunction), nil},
{Words(``, `\b`, `contract`, `interface`, `enum`, `event`, `constructor`, `function`, `library`, `mapping`, `modifier`, `struct`, `var`), KeywordDeclaration, nil},
{Words(``, `\b`, `abstract`, `external`, `internal`, `private`, `public`), Keyword, nil},
{Words(``, `\b`, `anonymous`, `constant`, `immutable`, `indexed`, `override`, `payable`, `pure`, `view`, `virtual`), Keyword, nil},
{`(import|using)\b`, KeywordNamespace, nil},
{`pragma (solidity|experimental)\b`, KeywordReserved, nil},
{`(_|as|constant|default|from|is)\b`, KeywordReserved, nil},
{`payable\b`, KeywordReserved, nil},
{`(memory|storage)\b`, KeywordReserved, nil},
{`(external|internal|private|public)\b`, KeywordReserved, nil},
{`(anonymous|indexed)\b`, KeywordReserved, nil},
{`(abstract|pure|static|view)\b`, KeywordReserved, nil},
{`pragma (solidity|experimental)\b`, Keyword, nil},
{Words(``, `\b`, `after`, `alias`, `apply`, `auto`, `case`, `copyof`, `default`, `define`, `final`, `implements`, `inline`, `let`, `macro`, `match`, `mutable`, `null`, `of`, `partial`, `promise`, `reference`, `relocatable`, `sealed`, `sizeof`, `static`, `supports`, `switch`, `typedef`, `typeof`, `unchecked`), KeywordReserved, nil},
{`(true|false)\b`, KeywordConstant, nil},
{`(wei|finney|szabo|ether)\b`, KeywordConstant, nil},
{`(seconds|minutes|hours|days|weeks|years)\b`, KeywordConstant, nil},
@ -99,15 +98,20 @@ func solidityRules() Rules {
{`\+\+|--|\*\*|\?|:|~|&&|\|\||=>|==?|!=?|(<<|>>>?|[-<>+*%&|^/])=?`, Operator, nil},
{`[{(\[;,]`, Punctuation, nil},
{`[})\].]`, Punctuation, nil},
{`(block|msg|now|this|super|tx)\b`, NameBuiltin, nil},
{`(sender|origin)\b`, NameBuiltin, nil},
{`(gas|value)\b`, NameBuiltin, nil},
{`(abi|block|msg|tx)\b`, NameBuiltin, nil},
{`(?!abi\.)(decode|encode|encodePacked|encodeWithSelector|encodeWithSignature|encodeWithSelector)\b`, NameBuiltin, nil},
{`(?!block\.)(chainid|coinbase|difficulty|gaslimit|number|timestamp)\b`, NameBuiltin, nil},
{`(?!msg\.)(data|gas|sender|value)\b`, NameBuiltin, nil},
{`(?!tx\.)(gasprice|origin)\b`, NameBuiltin, nil},
{`(type)(\()([a-zA-Z_]\w*)(\))`, ByGroups(NameBuiltin, Punctuation, NameClass, Punctuation), nil},
{`(?!type\([a-zA-Z_]\w*\)\.)(creationCode|interfaceId|max|min|name|runtimeCode)\b`, NameBuiltin, nil},
{`(now|this|super|gasleft)\b`, NameBuiltin, nil},
{`(selfdestruct|suicide)\b`, NameBuiltin, nil},
{`(balance|send|transfer)\b`, NameBuiltin, nil},
{`(?!0x[0-9a-fA-F]+\.)(balance|code|codehash|send|transfer)\b`, NameBuiltin, nil},
{`(assert|revert|require)\b`, NameBuiltin, nil},
{`(call|callcode|delegatecall)\b`, NameBuiltin, nil},
{`selector\b`, NameBuiltin, nil},
{`(addmod|ecrecover|keccak256|mulmod|ripemd160|sha256|sha3)\b`, NameFunction, nil},
{`(addmod|blockhash|ecrecover|keccak256|mulmod|ripemd160|sha256|sha3)\b`, NameBuiltin, nil},
{`[a-zA-Z_]\w*`, Name, nil},
},
}

73
vendor/github.com/alecthomas/chroma/lexers/s/svelte.go generated vendored Normal file
View file

@ -0,0 +1,73 @@
package s
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/h"
"github.com/alecthomas/chroma/lexers/internal"
"github.com/alecthomas/chroma/lexers/t"
)
// Svelte lexer.
var Svelte = internal.Register(DelegatingLexer(h.HTML, MustNewLazyLexer(
&Config{
Name: "Svelte",
Aliases: []string{"svelte"},
Filenames: []string{"*.svelte"},
MimeTypes: []string{"application/x-svelte"},
DotAll: true,
},
svelteRules,
)))
func svelteRules() Rules {
return Rules{
"root": {
// Let HTML handle the comments, including comments containing script and style tags
{`<!--`, Other, Push("comment")},
{
// Highlight script and style tags based on lang attribute
// and allow attributes besides lang
`(<\s*(?:script|style).*?lang\s*=\s*['"])` +
`(.+?)(['"].*?>)` +
`(.+?)` +
`(<\s*/\s*(?:script|style)\s*>)`,
UsingByGroup(internal.Get, 2, 4, Other, Other, Other, Other, Other),
nil,
},
{
// Make sure `{` is not inside script or style tags
`(?<!<\s*(?:script|style)(?:(?!(?:script|style)\s*>).)*?)` +
`{` +
`(?!(?:(?!<\s*(?:script|style)).)*?(?:script|style)\s*>)`,
Punctuation,
Push("templates"),
},
// on:submit|preventDefault
{`(?<=\s+on:\w+(?:\|\w+)*)\|(?=\w+)`, Operator, nil},
{`.+?`, Other, nil},
},
"comment": {
{`-->`, Other, Pop(1)},
{`.+?`, Other, nil},
},
"templates": {
{`}`, Punctuation, Pop(1)},
// Let TypeScript handle strings and the curly braces inside them
{`(?<!(?<!\\)\\)(['"` + "`])" + `.*?(?<!(?<!\\)\\)\1`, Using(t.TypeScript), nil},
// If there is another opening curly brace push to templates again
{"{", Punctuation, Push("templates")},
{`@(debug|html)\b`, Keyword, nil},
{
`(#await)(\s+)(\w+)(\s+)(then|catch)(\s+)(\w+)`,
ByGroups(Keyword, Text, Using(t.TypeScript), Text,
Keyword, Text, Using(t.TypeScript),
),
nil,
},
{`(#|/)(await|each|if|key)\b`, Keyword, nil},
{`(:else)(\s+)(if)?\b`, ByGroups(Keyword, Text, Keyword), nil},
{`:(catch|then)\b`, Keyword, nil},
{`[^{}]+`, Using(t.TypeScript), nil},
},
}
}

View file

@ -7,9 +7,10 @@ import (
var SYSTEMD = internal.Register(MustNewLazyLexer(
&Config{
Name: "SYSTEMD",
Aliases: []string{"systemd"},
Filenames: []string{"*.service"},
Name: "SYSTEMD",
Aliases: []string{"systemd"},
// Suspects: man systemd.index | grep -E 'systemd\..*configuration'
Filenames: []string{"*.automount", "*.device", "*.dnssd", "*.link", "*.mount", "*.netdev", "*.network", "*.path", "*.scope", "*.service", "*.slice", "*.socket", "*.swap", "*.target", "*.timer"},
MimeTypes: []string{"text/plain"},
},
systemdRules,

View file

@ -27,7 +27,7 @@ func tomlRules() Rules {
{`"(\\\\|\\"|[^"])*"`, StringDouble, nil},
{`'(\\\\|\\'|[^'])*'`, StringSingle, nil},
{`[.,=\[\]{}]`, Punctuation, nil},
{`[^\W\d]\w*`, NameOther, nil},
{`[A-Za-z0-9_-]+`, NameOther, nil},
},
}
}