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:
parent
65ae46bc20
commit
fae07cbc8f
319 changed files with 33568 additions and 21050 deletions
16
vendor/github.com/alecthomas/chroma/.golangci.yml
generated
vendored
16
vendor/github.com/alecthomas/chroma/.golangci.yml
generated
vendored
|
@ -25,6 +25,17 @@ linters:
|
|||
- testpackage
|
||||
- godot
|
||||
- nestif
|
||||
- paralleltest
|
||||
- nlreturn
|
||||
- cyclop
|
||||
- exhaustivestruct
|
||||
- gci
|
||||
- gofumpt
|
||||
- errorlint
|
||||
- exhaustive
|
||||
- ifshort
|
||||
- wrapcheck
|
||||
- stylecheck
|
||||
|
||||
linters-settings:
|
||||
govet:
|
||||
|
@ -36,6 +47,11 @@ linters-settings:
|
|||
goconst:
|
||||
min-len: 8
|
||||
min-occurrences: 3
|
||||
forbidigo:
|
||||
forbid:
|
||||
- (Must)?NewLexer
|
||||
exclude_godoc_examples: false
|
||||
|
||||
|
||||
issues:
|
||||
max-per-linter: 0
|
||||
|
|
34
vendor/github.com/alecthomas/chroma/README.md
generated
vendored
34
vendor/github.com/alecthomas/chroma/README.md
generated
vendored
|
@ -41,7 +41,7 @@ C | C, C#, C++, Caddyfile, Caddyfile Directives, Cap'n Proto, Cassandra CQL, Cey
|
|||
D | D, Dart, Diff, Django/Jinja, Docker, DTD, Dylan
|
||||
E | EBNF, Elixir, Elm, EmacsLisp, Erlang
|
||||
F | Factor, Fish, Forth, Fortran, FSharp
|
||||
G | GAS, GDScript, Genshi, Genshi HTML, Genshi Text, Gherkin, GLSL, Gnuplot, Go, Go HTML Template, Go Text Template, GraphQL, Groovy
|
||||
G | GAS, GDScript, Genshi, Genshi HTML, Genshi Text, Gherkin, GLSL, Gnuplot, Go, Go HTML Template, Go Text Template, GraphQL, Groff, Groovy
|
||||
H | Handlebars, Haskell, Haxe, HCL, Hexdump, HLB, HTML, HTTP, Hy
|
||||
I | Idris, Igor, INI, Io
|
||||
J | J, Java, JavaScript, JSON, Julia, Jungle
|
||||
|
@ -50,10 +50,10 @@ L | Lighttpd configuration file, LLVM, Lua
|
|||
M | Mako, markdown, Mason, Mathematica, Matlab, MiniZinc, MLIR, Modula-2, MonkeyC, MorrowindScript, Myghty, MySQL
|
||||
N | NASM, Newspeak, Nginx configuration file, Nim, Nix
|
||||
O | Objective-C, OCaml, Octave, OpenSCAD, Org Mode
|
||||
P | PacmanConf, Perl, PHP, PHTML, Pig, PkgConfig, PL/pgSQL, plaintext, Pony, PostgreSQL SQL dialect, PostScript, POVRay, PowerShell, Prolog, PromQL, Protocol Buffer, Puppet, Python, Python 3
|
||||
P | PacmanConf, Perl, PHP, PHTML, Pig, PkgConfig, PL/pgSQL, plaintext, Pony, PostgreSQL SQL dialect, PostScript, POVRay, PowerShell, Prolog, PromQL, Protocol Buffer, Puppet, Python 2, Python
|
||||
Q | QBasic
|
||||
R | R, Racket, Ragel, react, ReasonML, reg, reStructuredText, Rexx, Ruby, Rust
|
||||
S | SAS, Sass, Scala, Scheme, Scilab, SCSS, Smalltalk, Smarty, Snobol, Solidity, SPARQL, SQL, SquidConf, Standard ML, Stylus, Swift, SYSTEMD, systemverilog
|
||||
R | R, Racket, Ragel, Raku, react, ReasonML, reg, reStructuredText, Rexx, Ruby, Rust
|
||||
S | SAS, Sass, Scala, Scheme, Scilab, SCSS, Smalltalk, Smarty, Snobol, Solidity, SPARQL, SQL, SquidConf, Standard ML, Stylus, Svelte, Swift, SYSTEMD, systemverilog
|
||||
T | TableGen, TASM, Tcl, Tcsh, Termcap, Terminfo, Terraform, TeX, Thrift, TOML, TradingView, Transact-SQL, Turing, Turtle, Twig, TypeScript, TypoScript, TypoScriptCssData, TypoScriptHtmlData
|
||||
V | VB.net, verilog, VHDL, VimL, vue
|
||||
W | WDTE
|
||||
|
@ -210,10 +210,10 @@ using the included Python 3 script `pygments2chroma.py`. I use something like
|
|||
the following:
|
||||
|
||||
```sh
|
||||
python3 ~/Projects/chroma/_tools/pygments2chroma.py \
|
||||
python3 _tools/pygments2chroma.py \
|
||||
pygments.lexers.jvm.KotlinLexer \
|
||||
> ~/Projects/chroma/lexers/kotlin.go \
|
||||
&& gofmt -s -w ~/Projects/chroma/lexers/*.go
|
||||
> lexers/k/kotlin.go \
|
||||
&& gofmt -s -w lexers/k/kotlin.go
|
||||
```
|
||||
|
||||
See notes in [pygments-lexers.txt](https://github.com/alecthomas/chroma/blob/master/pygments-lexers.txt)
|
||||
|
@ -255,12 +255,30 @@ A command-line interface to Chroma is included. It can be installed with:
|
|||
go get -u github.com/alecthomas/chroma/cmd/chroma
|
||||
```
|
||||
|
||||
The CLI can be used as a preprocessor to colorise output of `less(1)`,
|
||||
see documentation for the `LESSOPEN` environment variable.
|
||||
|
||||
The `--fail` flag can be used to suppress output and return with exit status
|
||||
1 to facilitate falling back to some other preprocessor in case chroma
|
||||
does not resolve a specific lexer to use for the given file. For example:
|
||||
|
||||
```shell
|
||||
export LESSOPEN='| p() { chroma --fail "$1" || cat "$1"; }; p "%s"'
|
||||
```
|
||||
|
||||
Replace `cat` with your favourite fallback preprocessor.
|
||||
|
||||
When invoked as `.lessfilter`, the `--fail` flag is automatically turned
|
||||
on under the hood for easy integration with [lesspipe shipping with
|
||||
Debian and derivatives](https://manpages.debian.org/lesspipe#USER_DEFINED_FILTERS);
|
||||
for that setup the `chroma` executable can be just symlinked to `~/.lessfilter`.
|
||||
|
||||
<a id="markdown-whats-missing-compared-to-pygments" name="whats-missing-compared-to-pygments"></a>
|
||||
## What's missing compared to Pygments?
|
||||
|
||||
- Quite a few lexers, for various reasons (pull-requests welcome):
|
||||
- Pygments lexers for complex languages often include custom code to
|
||||
handle certain aspects, such as Perl6's ability to nest code inside
|
||||
handle certain aspects, such as Raku's ability to nest code inside
|
||||
regular expressions. These require time and effort to convert.
|
||||
- I mostly only converted languages I had heard of, to reduce the porting cost.
|
||||
- Some more esoteric features of Pygments are omitted for simplicity.
|
||||
|
|
2
vendor/github.com/alecthomas/chroma/formatters/html/html.go
generated
vendored
2
vendor/github.com/alecthomas/chroma/formatters/html/html.go
generated
vendored
|
@ -131,7 +131,7 @@ var (
|
|||
}
|
||||
defaultPreWrapper = preWrapper{
|
||||
start: func(code bool, styleAttr string) string {
|
||||
return fmt.Sprintf("<pre%s>", styleAttr)
|
||||
return fmt.Sprintf(`<pre tabindex="0"%s>`, styleAttr)
|
||||
},
|
||||
end: func(code bool) string {
|
||||
return "</pre>"
|
||||
|
|
4
vendor/github.com/alecthomas/chroma/go.sum
generated
vendored
4
vendor/github.com/alecthomas/chroma/go.sum
generated
vendored
|
@ -11,15 +11,12 @@ github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9
|
|||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dlclark/regexp2 v1.2.0 h1:8sAhBGEM0dRWogWqWyQeIJnxjWO6oIjl8FKqREDsGfk=
|
||||
github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
|
||||
github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E=
|
||||
github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
|
||||
github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE=
|
||||
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
|
@ -28,7 +25,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
|
|||
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
|
||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
|
|
9
vendor/github.com/alecthomas/chroma/lexer.go
generated
vendored
9
vendor/github.com/alecthomas/chroma/lexer.go
generated
vendored
|
@ -2,6 +2,7 @@ package chroma
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -98,9 +99,11 @@ type Lexer interface {
|
|||
// Lexers is a slice of lexers sortable by name.
|
||||
type Lexers []Lexer
|
||||
|
||||
func (l Lexers) Len() int { return len(l) }
|
||||
func (l Lexers) Swap(i, j int) { l[i], l[j] = l[j], l[i] }
|
||||
func (l Lexers) Less(i, j int) bool { return l[i].Config().Name < l[j].Config().Name }
|
||||
func (l Lexers) Len() int { return len(l) }
|
||||
func (l Lexers) Swap(i, j int) { l[i], l[j] = l[j], l[i] }
|
||||
func (l Lexers) Less(i, j int) bool {
|
||||
return strings.ToLower(l[i].Config().Name) < strings.ToLower(l[j].Config().Name)
|
||||
}
|
||||
|
||||
// PrioritisedLexers is a slice of lexers sortable by priority.
|
||||
type PrioritisedLexers []Lexer
|
||||
|
|
3
vendor/github.com/alecthomas/chroma/lexers/README.md
generated
vendored
3
vendor/github.com/alecthomas/chroma/lexers/README.md
generated
vendored
|
@ -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:
|
||||
|
|
6
vendor/github.com/alecthomas/chroma/lexers/c/c.go
generated
vendored
6
vendor/github.com/alecthomas/chroma/lexers/c/c.go
generated
vendored
|
@ -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},
|
||||
|
|
5
vendor/github.com/alecthomas/chroma/lexers/circular/phtml.go
generated
vendored
5
vendor/github.com/alecthomas/chroma/lexers/circular/phtml.go
generated
vendored
|
@ -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 {
|
||||
|
|
112
vendor/github.com/alecthomas/chroma/lexers/d/dylan.go
generated
vendored
112
vendor/github.com/alecthomas/chroma/lexers/d/dylan.go
generated
vendored
|
@ -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},
|
||||
},
|
||||
}
|
||||
},
|
||||
))
|
||||
|
|
43
vendor/github.com/alecthomas/chroma/lexers/f/fish.go
generated
vendored
43
vendor/github.com/alecthomas/chroma/lexers/f/fish.go
generated
vendored
|
@ -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)},
|
||||
|
|
39
vendor/github.com/alecthomas/chroma/lexers/f/fortran_fixed.go
generated
vendored
Normal file
39
vendor/github.com/alecthomas/chroma/lexers/f/fortran_fixed.go
generated
vendored
Normal 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
47
vendor/github.com/alecthomas/chroma/lexers/g/groff.go
generated
vendored
Normal 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},
|
||||
},
|
||||
}
|
||||
},
|
||||
))
|
6
vendor/github.com/alecthomas/chroma/lexers/h/http.go
generated
vendored
6
vendor/github.com/alecthomas/chroma/lexers/h/http.go
generated
vendored
|
@ -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]},
|
||||
|
|
27
vendor/github.com/alecthomas/chroma/lexers/internal/api.go
generated
vendored
27
vendor/github.com/alecthomas/chroma/lexers/internal/api.go
generated
vendored
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
vendor/github.com/alecthomas/chroma/lexers/j/javascript.go
generated
vendored
2
vendor/github.com/alecthomas/chroma/lexers/j/javascript.go
generated
vendored
|
@ -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"},
|
||||
|
|
2
vendor/github.com/alecthomas/chroma/lexers/lexers.go
generated
vendored
2
vendor/github.com/alecthomas/chroma/lexers/lexers.go
generated
vendored
|
@ -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"
|
||||
|
|
2
vendor/github.com/alecthomas/chroma/lexers/m/markdown.go
generated
vendored
2
vendor/github.com/alecthomas/chroma/lexers/m/markdown.go
generated
vendored
|
@ -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},
|
||||
|
|
180
vendor/github.com/alecthomas/chroma/lexers/m/mcfunction.go
generated
vendored
180
vendor/github.com/alecthomas/chroma/lexers/m/mcfunction.go
generated
vendored
|
@ -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
101
vendor/github.com/alecthomas/chroma/lexers/m/metal.go
generated
vendored
Normal 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},
|
||||
},
|
||||
}
|
||||
}
|
10
vendor/github.com/alecthomas/chroma/lexers/m/myghty.go
generated
vendored
10
vendor/github.com/alecthomas/chroma/lexers/m/myghty.go
generated
vendored
|
@ -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:
|
||||
(?:
|
||||
|
|
27
vendor/github.com/alecthomas/chroma/lexers/m/mysql.go
generated
vendored
27
vendor/github.com/alecthomas/chroma/lexers/m/mysql.go
generated
vendored
|
@ -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{
|
||||
|
|
38
vendor/github.com/alecthomas/chroma/lexers/p/powerquery.go
generated
vendored
Normal file
38
vendor/github.com/alecthomas/chroma/lexers/p/powerquery.go
generated
vendored
Normal 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},
|
||||
},
|
||||
}
|
||||
}
|
170
vendor/github.com/alecthomas/chroma/lexers/p/python.go
generated
vendored
170
vendor/github.com/alecthomas/chroma/lexers/p/python.go
generated
vendored
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
141
vendor/github.com/alecthomas/chroma/lexers/p/python2.go
generated
vendored
Normal 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},
|
||||
},
|
||||
}
|
||||
}
|
141
vendor/github.com/alecthomas/chroma/lexers/p/python3.go
generated
vendored
141
vendor/github.com/alecthomas/chroma/lexers/p/python3.go
generated
vendored
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
1496
vendor/github.com/alecthomas/chroma/lexers/r/raku.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
4
vendor/github.com/alecthomas/chroma/lexers/r/rst.go
generated
vendored
4
vendor/github.com/alecthomas/chroma/lexers/r/rst.go
generated
vendored
|
@ -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...))
|
||||
|
|
47
vendor/github.com/alecthomas/chroma/lexers/s/scss.go
generated
vendored
47
vendor/github.com/alecthomas/chroma/lexers/s/scss.go
generated
vendored
File diff suppressed because one or more lines are too long
32
vendor/github.com/alecthomas/chroma/lexers/s/solidity.go
generated
vendored
32
vendor/github.com/alecthomas/chroma/lexers/s/solidity.go
generated
vendored
|
@ -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
73
vendor/github.com/alecthomas/chroma/lexers/s/svelte.go
generated
vendored
Normal 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},
|
||||
},
|
||||
}
|
||||
}
|
7
vendor/github.com/alecthomas/chroma/lexers/s/systemd.go
generated
vendored
7
vendor/github.com/alecthomas/chroma/lexers/s/systemd.go
generated
vendored
|
@ -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,
|
||||
|
|
2
vendor/github.com/alecthomas/chroma/lexers/t/toml.go
generated
vendored
2
vendor/github.com/alecthomas/chroma/lexers/t/toml.go
generated
vendored
|
@ -27,7 +27,7 @@ func tomlRules() Rules {
|
|||
{`"(\\\\|\\"|[^"])*"`, StringDouble, nil},
|
||||
{`'(\\\\|\\'|[^'])*'`, StringSingle, nil},
|
||||
{`[.,=\[\]{}]`, Punctuation, nil},
|
||||
{`[^\W\d]\w*`, NameOther, nil},
|
||||
{`[A-Za-z0-9_-]+`, NameOther, nil},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
3
vendor/github.com/alecthomas/chroma/pygments-lexers.txt
generated
vendored
3
vendor/github.com/alecthomas/chroma/pygments-lexers.txt
generated
vendored
|
@ -2,9 +2,6 @@ Generated with:
|
|||
|
||||
g 'class.*RegexLexer' | pawk --strict -F: '"pygments.lexers.%s.%s" % (f[0].split(".")[0], f[2].split()[1].split("(")[0])' > lexers.txt
|
||||
|
||||
perl6:
|
||||
Requires a bunch of helpers that I do not have the time to convert.
|
||||
|
||||
kotlin:
|
||||
invalid unicode escape sequences
|
||||
FIXED: Have to disable wide Unicode characters in unistring.py
|
||||
|
|
95
vendor/github.com/alecthomas/chroma/regexp.go
generated
vendored
95
vendor/github.com/alecthomas/chroma/regexp.go
generated
vendored
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
@ -22,25 +23,57 @@ type Rule struct {
|
|||
// An Emitter takes group matches and returns tokens.
|
||||
type Emitter interface {
|
||||
// Emit tokens for the given regex groups.
|
||||
Emit(groups []string, lexer Lexer) Iterator
|
||||
Emit(groups []string, state *LexerState) Iterator
|
||||
}
|
||||
|
||||
// EmitterFunc is a function that is an Emitter.
|
||||
type EmitterFunc func(groups []string, lexer Lexer) Iterator
|
||||
type EmitterFunc func(groups []string, state *LexerState) Iterator
|
||||
|
||||
// Emit tokens for groups.
|
||||
func (e EmitterFunc) Emit(groups []string, lexer Lexer) Iterator { return e(groups, lexer) }
|
||||
func (e EmitterFunc) Emit(groups []string, state *LexerState) Iterator {
|
||||
return e(groups, state)
|
||||
}
|
||||
|
||||
// ByGroups emits a token for each matching group in the rule's regex.
|
||||
func ByGroups(emitters ...Emitter) Emitter {
|
||||
return EmitterFunc(func(groups []string, lexer Lexer) Iterator {
|
||||
return EmitterFunc(func(groups []string, state *LexerState) Iterator {
|
||||
iterators := make([]Iterator, 0, len(groups)-1)
|
||||
if len(emitters) != len(groups)-1 {
|
||||
iterators = append(iterators, Error.Emit(groups, lexer))
|
||||
iterators = append(iterators, Error.Emit(groups, state))
|
||||
// panic(errors.Errorf("number of groups %q does not match number of emitters %v", groups, emitters))
|
||||
} else {
|
||||
for i, group := range groups[1:] {
|
||||
iterators = append(iterators, emitters[i].Emit([]string{group}, lexer))
|
||||
if emitters[i] != nil {
|
||||
iterators = append(iterators, emitters[i].Emit([]string{group}, state))
|
||||
}
|
||||
}
|
||||
}
|
||||
return Concaterator(iterators...)
|
||||
})
|
||||
}
|
||||
|
||||
// ByGroupNames emits a token for each named matching group in the rule's regex.
|
||||
func ByGroupNames(emitters map[string]Emitter) Emitter {
|
||||
return EmitterFunc(func(groups []string, state *LexerState) Iterator {
|
||||
iterators := make([]Iterator, 0, len(state.NamedGroups)-1)
|
||||
if len(state.NamedGroups)-1 == 0 {
|
||||
if emitter, ok := emitters[`0`]; ok {
|
||||
iterators = append(iterators, emitter.Emit(groups, state))
|
||||
} else {
|
||||
iterators = append(iterators, Error.Emit(groups, state))
|
||||
}
|
||||
} else {
|
||||
ruleRegex := state.Rules[state.State][state.Rule].Regexp
|
||||
for i := 1; i < len(state.NamedGroups); i++ {
|
||||
groupName := ruleRegex.GroupNameFromNumber(i)
|
||||
group := state.NamedGroups[groupName]
|
||||
if emitter, ok := emitters[groupName]; ok {
|
||||
if emitter != nil {
|
||||
iterators = append(iterators, emitter.Emit([]string{group}, state))
|
||||
}
|
||||
} else {
|
||||
iterators = append(iterators, Error.Emit([]string{group}, state))
|
||||
}
|
||||
}
|
||||
}
|
||||
return Concaterator(iterators...)
|
||||
|
@ -88,7 +121,7 @@ func ByGroups(emitters ...Emitter) Emitter {
|
|||
// Note: panic's if the number emitters does not equal the number of matched
|
||||
// groups in the regex.
|
||||
func UsingByGroup(sublexerGetFunc func(string) Lexer, sublexerNameGroup, codeGroup int, emitters ...Emitter) Emitter {
|
||||
return EmitterFunc(func(groups []string, lexer Lexer) Iterator {
|
||||
return EmitterFunc(func(groups []string, state *LexerState) Iterator {
|
||||
// bounds check
|
||||
if len(emitters) != len(groups)-1 {
|
||||
panic("UsingByGroup expects number of emitters to be the same as len(groups)-1")
|
||||
|
@ -106,8 +139,8 @@ func UsingByGroup(sublexerGetFunc func(string) Lexer, sublexerNameGroup, codeGro
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
iterators[i] = emitters[i].Emit([]string{group}, lexer)
|
||||
} else if emitters[i] != nil {
|
||||
iterators[i] = emitters[i].Emit([]string{group}, state)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +150,7 @@ func UsingByGroup(sublexerGetFunc func(string) Lexer, sublexerNameGroup, codeGro
|
|||
|
||||
// Using returns an Emitter that uses a given Lexer for parsing and emitting.
|
||||
func Using(lexer Lexer) Emitter {
|
||||
return EmitterFunc(func(groups []string, _ Lexer) Iterator {
|
||||
return EmitterFunc(func(groups []string, _ *LexerState) Iterator {
|
||||
it, err := lexer.Tokenise(&TokeniseOptions{State: "root", Nested: true}, groups[0])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -127,9 +160,9 @@ func Using(lexer Lexer) Emitter {
|
|||
}
|
||||
|
||||
// UsingSelf is like Using, but uses the current Lexer.
|
||||
func UsingSelf(state string) Emitter {
|
||||
return EmitterFunc(func(groups []string, lexer Lexer) Iterator {
|
||||
it, err := lexer.Tokenise(&TokeniseOptions{State: state, Nested: true}, groups[0])
|
||||
func UsingSelf(stateName string) Emitter {
|
||||
return EmitterFunc(func(groups []string, state *LexerState) Iterator {
|
||||
it, err := state.Lexer.Tokenise(&TokeniseOptions{State: stateName, Nested: true}, groups[0])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -139,6 +172,9 @@ func UsingSelf(state string) Emitter {
|
|||
|
||||
// Words creates a regex that matches any of the given literal words.
|
||||
func Words(prefix, suffix string, words ...string) string {
|
||||
sort.Slice(words, func(i, j int) bool {
|
||||
return len(words[j]) < len(words[i])
|
||||
})
|
||||
for i, word := range words {
|
||||
words[i] = regexp.QuoteMeta(word)
|
||||
}
|
||||
|
@ -162,10 +198,10 @@ func Tokenise(lexer Lexer, options *TokeniseOptions, text string) ([]Token, erro
|
|||
type Rules map[string][]Rule
|
||||
|
||||
// Rename clones rules then a rule.
|
||||
func (r Rules) Rename(old, new string) Rules {
|
||||
func (r Rules) Rename(oldRule, newRule string) Rules {
|
||||
r = r.Clone()
|
||||
r[new] = r[old]
|
||||
delete(r, old)
|
||||
r[newRule] = r[oldRule]
|
||||
delete(r, oldRule)
|
||||
return r
|
||||
}
|
||||
|
||||
|
@ -209,8 +245,10 @@ func NewLazyLexer(config *Config, rulesFunc func() Rules) (*RegexLexer, error) {
|
|||
}
|
||||
|
||||
// MustNewLexer creates a new Lexer or panics.
|
||||
func MustNewLexer(config *Config, rules Rules) *RegexLexer {
|
||||
lexer, err := NewLexer(config, rules)
|
||||
//
|
||||
// Deprecated: Use MustNewLazyLexer instead.
|
||||
func MustNewLexer(config *Config, rules Rules) *RegexLexer { // nolint: forbidigo
|
||||
lexer, err := NewLexer(config, rules) // nolint: forbidigo
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -221,7 +259,9 @@ func MustNewLexer(config *Config, rules Rules) *RegexLexer {
|
|||
//
|
||||
// "rules" is a state machine transitition map. Each key is a state. Values are sets of rules
|
||||
// that match input, optionally modify lexer state, and output tokens.
|
||||
func NewLexer(config *Config, rules Rules) (*RegexLexer, error) {
|
||||
//
|
||||
// Deprecated: Use NewLazyLexer instead.
|
||||
func NewLexer(config *Config, rules Rules) (*RegexLexer, error) { // nolint: forbidigo
|
||||
return NewLazyLexer(config, func() Rules { return rules })
|
||||
}
|
||||
|
||||
|
@ -254,6 +294,8 @@ type LexerState struct {
|
|||
Rule int
|
||||
// Group matches.
|
||||
Groups []string
|
||||
// Named Group matches.
|
||||
NamedGroups map[string]string
|
||||
// Custum context for mutators.
|
||||
MutatorContext map[interface{}]interface{}
|
||||
iteratorStack []Iterator
|
||||
|
@ -297,7 +339,7 @@ func (l *LexerState) Iterator() Token { // nolint: gocognit
|
|||
if !ok {
|
||||
panic("unknown state " + l.State)
|
||||
}
|
||||
ruleIndex, rule, groups := matchRules(l.Text, l.Pos, selectedRule)
|
||||
ruleIndex, rule, groups, namedGroups := matchRules(l.Text, l.Pos, selectedRule)
|
||||
// No match.
|
||||
if groups == nil {
|
||||
// From Pygments :\
|
||||
|
@ -315,6 +357,7 @@ func (l *LexerState) Iterator() Token { // nolint: gocognit
|
|||
}
|
||||
l.Rule = ruleIndex
|
||||
l.Groups = groups
|
||||
l.NamedGroups = namedGroups
|
||||
l.Pos += utf8.RuneCountInString(groups[0])
|
||||
if rule.Mutator != nil {
|
||||
if err := rule.Mutator.Mutate(l); err != nil {
|
||||
|
@ -322,7 +365,7 @@ func (l *LexerState) Iterator() Token { // nolint: gocognit
|
|||
}
|
||||
}
|
||||
if rule.Type != nil {
|
||||
l.iteratorStack = append(l.iteratorStack, rule.Type.Emit(l.Groups, l.Lexer))
|
||||
l.iteratorStack = append(l.iteratorStack, rule.Type.Emit(l.Groups, l))
|
||||
}
|
||||
}
|
||||
// Exhaust the IteratorStack, if any.
|
||||
|
@ -391,7 +434,7 @@ func (r *RegexLexer) maybeCompile() (err error) {
|
|||
pattern = "(?" + rule.flags + ")" + pattern
|
||||
}
|
||||
pattern = `\G` + pattern
|
||||
rule.Regexp, err = regexp2.Compile(pattern, 0)
|
||||
rule.Regexp, err = regexp2.Compile(pattern, regexp2.RE2)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to compile rule %s.%d: %s", state, i, err)
|
||||
}
|
||||
|
@ -486,18 +529,20 @@ func (r *RegexLexer) Tokenise(options *TokeniseOptions, text string) (Iterator,
|
|||
return state.Iterator, nil
|
||||
}
|
||||
|
||||
func matchRules(text []rune, pos int, rules []*CompiledRule) (int, *CompiledRule, []string) {
|
||||
func matchRules(text []rune, pos int, rules []*CompiledRule) (int, *CompiledRule, []string, map[string]string) {
|
||||
for i, rule := range rules {
|
||||
match, err := rule.Regexp.FindRunesMatchStartingAt(text, pos)
|
||||
if match != nil && err == nil && match.Index == pos {
|
||||
groups := []string{}
|
||||
namedGroups := make(map[string]string)
|
||||
for _, g := range match.Groups() {
|
||||
namedGroups[g.Name] = g.String()
|
||||
groups = append(groups, g.String())
|
||||
}
|
||||
return i, rule, groups
|
||||
return i, rule, groups, namedGroups
|
||||
}
|
||||
}
|
||||
return 0, &CompiledRule{}, nil
|
||||
return 0, &CompiledRule{}, nil, nil
|
||||
}
|
||||
|
||||
// replace \r and \r\n with \n
|
||||
|
|
4
vendor/github.com/alecthomas/chroma/style.go
generated
vendored
4
vendor/github.com/alecthomas/chroma/style.go
generated
vendored
|
@ -287,8 +287,10 @@ func (s *Style) synthesise(ttype TokenType) StyleEntry {
|
|||
// If we don't have line numbers, use the text colour but 20% brighter/darker
|
||||
case LineNumbers, LineNumbersTable:
|
||||
return text
|
||||
|
||||
default:
|
||||
return StyleEntry{}
|
||||
}
|
||||
return StyleEntry{}
|
||||
}
|
||||
|
||||
func (s *Style) synthesisable(ttype TokenType) bool {
|
||||
|
|
58
vendor/github.com/alecthomas/chroma/styles/doom-one.go
generated
vendored
Normal file
58
vendor/github.com/alecthomas/chroma/styles/doom-one.go
generated
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
package styles
|
||||
|
||||
import (
|
||||
"github.com/alecthomas/chroma"
|
||||
)
|
||||
|
||||
// Doom One style. Inspired by Atom One and Doom Emacs's Atom One theme
|
||||
var DoomOne = Register(chroma.MustNewStyle("doom-one", chroma.StyleEntries{
|
||||
chroma.Text: "#b0c4de",
|
||||
chroma.Error: "#b0c4de",
|
||||
chroma.Comment: "italic #8a93a5",
|
||||
chroma.CommentHashbang: "bold",
|
||||
chroma.Keyword: "#c678dd",
|
||||
chroma.KeywordType: "#ef8383",
|
||||
chroma.KeywordConstant: "bold #b756ff",
|
||||
chroma.Operator: "#c7bf54",
|
||||
chroma.OperatorWord: "bold #b756ff",
|
||||
chroma.Punctuation: "#b0c4de",
|
||||
chroma.Name: "#c1abea",
|
||||
chroma.NameAttribute: "#b3d23c",
|
||||
chroma.NameBuiltin: "#ef8383",
|
||||
chroma.NameClass: "#76a9f9",
|
||||
chroma.NameConstant: "bold #b756ff",
|
||||
chroma.NameDecorator: "#e5c07b",
|
||||
chroma.NameEntity: "#bda26f",
|
||||
chroma.NameException: "bold #fd7474",
|
||||
chroma.NameFunction: "#00b1f7",
|
||||
chroma.NameProperty: "#cebc3a",
|
||||
chroma.NameLabel: "#f5a40d",
|
||||
chroma.NameNamespace: "#76a9f9",
|
||||
chroma.NameTag: "#e06c75",
|
||||
chroma.NameVariable: "#DCAEEA",
|
||||
chroma.NameVariableGlobal: "bold #DCAEEA",
|
||||
chroma.NameVariableInstance: "#e06c75",
|
||||
chroma.Literal: "#98c379",
|
||||
chroma.Number: "#d19a66",
|
||||
chroma.String: "#98c379",
|
||||
chroma.StringDoc: "#7e97c3",
|
||||
chroma.StringDouble: "#63c381",
|
||||
chroma.StringEscape: "bold #d26464",
|
||||
chroma.StringHeredoc: "#98c379",
|
||||
chroma.StringInterpol: "#98c379",
|
||||
chroma.StringOther: "#70b33f",
|
||||
chroma.StringRegex: "#56b6c2",
|
||||
chroma.StringSingle: "#98c379",
|
||||
chroma.StringSymbol: "#56b6c2",
|
||||
chroma.Generic: "#b0c4de",
|
||||
chroma.GenericEmph: "italic",
|
||||
chroma.GenericHeading: "bold #a2cbff",
|
||||
chroma.GenericInserted: "#a6e22e",
|
||||
chroma.GenericOutput: "#a6e22e",
|
||||
chroma.GenericUnderline: "underline",
|
||||
chroma.GenericPrompt: "#a6e22e",
|
||||
chroma.GenericStrong: "bold",
|
||||
chroma.GenericSubheading: "#a2cbff",
|
||||
chroma.GenericTraceback: "#a2cbff",
|
||||
chroma.Background: "#b0c4de bg:#282c34",
|
||||
}))
|
71
vendor/github.com/alecthomas/chroma/styles/doom-one2.go
generated
vendored
Normal file
71
vendor/github.com/alecthomas/chroma/styles/doom-one2.go
generated
vendored
Normal file
|
@ -0,0 +1,71 @@
|
|||
package styles
|
||||
|
||||
import (
|
||||
"github.com/alecthomas/chroma"
|
||||
)
|
||||
|
||||
// Doom One 2 style. Inspired by Atom One and Doom Emacs's Atom One theme
|
||||
var DoomOne2 = Register(chroma.MustNewStyle("doom-one2", chroma.StyleEntries{
|
||||
chroma.Text: "#b0c4de",
|
||||
chroma.Error: "#b0c4de",
|
||||
chroma.Comment: "italic #8a93a5",
|
||||
chroma.CommentHashbang: "bold",
|
||||
chroma.Keyword: "#76a9f9",
|
||||
chroma.KeywordConstant: "#e5c07b",
|
||||
chroma.KeywordType: "#e5c07b",
|
||||
chroma.Operator: "#54b1c7",
|
||||
chroma.OperatorWord: "bold #b756ff",
|
||||
chroma.Punctuation: "#abb2bf",
|
||||
chroma.Name: "#aa89ea",
|
||||
chroma.NameAttribute: "#cebc3a",
|
||||
chroma.NameBuiltin: "#e5c07b",
|
||||
chroma.NameClass: "#ca72ff",
|
||||
chroma.NameConstant: "bold",
|
||||
chroma.NameDecorator: "#e5c07b",
|
||||
chroma.NameEntity: "#bda26f",
|
||||
chroma.NameException: "bold #fd7474",
|
||||
chroma.NameFunction: "#00b1f7",
|
||||
chroma.NameProperty: "#cebc3a",
|
||||
chroma.NameLabel: "#f5a40d",
|
||||
chroma.NameNamespace: "#ca72ff",
|
||||
chroma.NameTag: "#76a9f9",
|
||||
chroma.NameVariable: "#DCAEEA",
|
||||
chroma.NameVariableClass: "#DCAEEA",
|
||||
chroma.NameVariableGlobal: "bold #DCAEEA",
|
||||
chroma.NameVariableInstance: "#e06c75",
|
||||
chroma.NameVariableMagic: "#DCAEEA",
|
||||
chroma.Literal: "#98c379",
|
||||
chroma.LiteralDate: "#98c379",
|
||||
chroma.Number: "#d19a66",
|
||||
chroma.NumberBin: "#d19a66",
|
||||
chroma.NumberFloat: "#d19a66",
|
||||
chroma.NumberHex: "#d19a66",
|
||||
chroma.NumberInteger: "#d19a66",
|
||||
chroma.NumberIntegerLong: "#d19a66",
|
||||
chroma.NumberOct: "#d19a66",
|
||||
chroma.String: "#98c379",
|
||||
chroma.StringAffix: "#98c379",
|
||||
chroma.StringBacktick: "#98c379",
|
||||
chroma.StringDelimiter: "#98c379",
|
||||
chroma.StringDoc: "#7e97c3",
|
||||
chroma.StringDouble: "#63c381",
|
||||
chroma.StringEscape: "bold #d26464",
|
||||
chroma.StringHeredoc: "#98c379",
|
||||
chroma.StringInterpol: "#98c379",
|
||||
chroma.StringOther: "#70b33f",
|
||||
chroma.StringRegex: "#56b6c2",
|
||||
chroma.StringSingle: "#98c379",
|
||||
chroma.StringSymbol: "#56b6c2",
|
||||
chroma.Generic: "#b0c4de",
|
||||
chroma.GenericDeleted: "#b0c4de",
|
||||
chroma.GenericEmph: "italic",
|
||||
chroma.GenericHeading: "bold #a2cbff",
|
||||
chroma.GenericInserted: "#a6e22e",
|
||||
chroma.GenericOutput: "#a6e22e",
|
||||
chroma.GenericUnderline: "underline",
|
||||
chroma.GenericPrompt: "#a6e22e",
|
||||
chroma.GenericStrong: "bold",
|
||||
chroma.GenericSubheading: "#a2cbff",
|
||||
chroma.GenericTraceback: "#a2cbff",
|
||||
chroma.Background: "#b0c4de bg:#282c34",
|
||||
}))
|
4
vendor/github.com/alecthomas/chroma/styles/dracula.go
generated
vendored
4
vendor/github.com/alecthomas/chroma/styles/dracula.go
generated
vendored
|
@ -13,11 +13,11 @@ var Dracula = Register(chroma.MustNewStyle("dracula", chroma.StyleEntries{
|
|||
chroma.CommentSingle: "#6272a4",
|
||||
chroma.CommentSpecial: "#6272a4",
|
||||
chroma.Generic: "#f8f8f2",
|
||||
chroma.GenericDeleted: "#8b080b",
|
||||
chroma.GenericDeleted: "#ff5555",
|
||||
chroma.GenericEmph: "#f8f8f2 underline",
|
||||
chroma.GenericError: "#f8f8f2",
|
||||
chroma.GenericHeading: "#f8f8f2 bold",
|
||||
chroma.GenericInserted: "#f8f8f2 bold",
|
||||
chroma.GenericInserted: "#50fa7b bold",
|
||||
chroma.GenericOutput: "#44475a",
|
||||
chroma.GenericPrompt: "#f8f8f2",
|
||||
chroma.GenericStrong: "#f8f8f2",
|
||||
|
|
17
vendor/github.com/alecthomas/chroma/styles/hr_dark.go
generated
vendored
Normal file
17
vendor/github.com/alecthomas/chroma/styles/hr_dark.go
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
package styles
|
||||
|
||||
import (
|
||||
"github.com/alecthomas/chroma"
|
||||
)
|
||||
|
||||
// Theme based on HackerRank Dark Editor theme
|
||||
var HrDark = Register(chroma.MustNewStyle("hrdark", chroma.StyleEntries{
|
||||
chroma.Comment: "italic #828b96",
|
||||
chroma.Keyword: "#ff636f",
|
||||
chroma.OperatorWord: "#ff636f",
|
||||
chroma.Name: "#58a1dd",
|
||||
chroma.Literal: "#a6be9d",
|
||||
chroma.Operator: "#ff636f",
|
||||
chroma.Background: "#1d2432",
|
||||
chroma.Other: "#fff",
|
||||
}))
|
19
vendor/github.com/alecthomas/chroma/styles/hr_high_contrast.go
generated
vendored
Normal file
19
vendor/github.com/alecthomas/chroma/styles/hr_high_contrast.go
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
package styles
|
||||
|
||||
import (
|
||||
"github.com/alecthomas/chroma"
|
||||
)
|
||||
|
||||
// Theme based on HackerRank High Contrast Editor Theme
|
||||
var HrHighContrast = Register(chroma.MustNewStyle("hr_high_contrast", chroma.StyleEntries{
|
||||
chroma.Comment: "#5a8349",
|
||||
chroma.Keyword: "#467faf",
|
||||
chroma.OperatorWord: "#467faf",
|
||||
chroma.Name: "#ffffff",
|
||||
chroma.LiteralString: "#a87662",
|
||||
chroma.LiteralNumber: "#fff",
|
||||
chroma.LiteralStringBoolean: "#467faf",
|
||||
chroma.Operator: "#e4e400",
|
||||
chroma.Background: "#000",
|
||||
chroma.Other: "#d5d500",
|
||||
}))
|
2
vendor/github.com/alecthomas/chroma/types.go
generated
vendored
2
vendor/github.com/alecthomas/chroma/types.go
generated
vendored
|
@ -342,6 +342,6 @@ func (t TokenType) InSubCategory(other TokenType) bool {
|
|||
return t/100 == other/100
|
||||
}
|
||||
|
||||
func (t TokenType) Emit(groups []string, lexer Lexer) Iterator {
|
||||
func (t TokenType) Emit(groups []string, _ *LexerState) Iterator {
|
||||
return Literator(Token{Type: t, Value: groups[0]})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue