forked from forgejo/forgejo
Server-side syntax highlighting for all code (#12047)
* Server-side syntax hilighting for all code This PR does a few things: * Remove all traces of highlight.js * Use chroma library to provide fast syntax hilighting directly on the server * Provide syntax hilighting for diffs * Re-style both unified and split diffs views * Add custom syntax hilighting styling for both regular and arc-green Fixes #7729 Fixes #10157 Fixes #11825 Fixes #7728 Fixes #3872 Fixes #3682 And perhaps gets closer to #9553 * fix line marker * fix repo search * Fix single line select * properly load settings * npm uninstall highlight.js * review suggestion * code review * forgot to call function * fix test * Apply suggestions from code review suggestions from @silverwind thanks Co-authored-by: silverwind <me@silverwind.io> * code review * copy/paste error * Use const for highlight size limit * Update web_src/less/_repository.less Co-authored-by: Lauris BH <lauris@nix.lv> * update size limit to 1MB and other styling tweaks * fix highlighting for certain diff sections * fix test * add worker back as suggested Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
parent
ce5f2b9845
commit
af7ffaa279
336 changed files with 37293 additions and 769 deletions
26
vendor/github.com/alecthomas/chroma/lexers/p/pacman.go
generated
vendored
Normal file
26
vendor/github.com/alecthomas/chroma/lexers/p/pacman.go
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
package p
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Pacmanconf lexer.
|
||||
var Pacmanconf = internal.Register(MustNewLexer(
|
||||
&Config{
|
||||
Name: "PacmanConf",
|
||||
Aliases: []string{"pacmanconf"},
|
||||
Filenames: []string{"pacman.conf"},
|
||||
MimeTypes: []string{},
|
||||
},
|
||||
Rules{
|
||||
"root": {
|
||||
{`#.*$`, CommentSingle, nil},
|
||||
{`^\s*\[.*?\]\s*$`, Keyword, nil},
|
||||
{`(\w+)(\s*)(=)`, ByGroups(NameAttribute, Text, Operator), nil},
|
||||
{`^(\s*)(\w+)(\s*)$`, ByGroups(Text, NameAttribute, Text), nil},
|
||||
{Words(``, `\b`, `$repo`, `$arch`, `%o`, `%u`), NameVariable, nil},
|
||||
{`.`, Text, nil},
|
||||
},
|
||||
},
|
||||
))
|
138
vendor/github.com/alecthomas/chroma/lexers/p/perl.go
generated
vendored
Normal file
138
vendor/github.com/alecthomas/chroma/lexers/p/perl.go
generated
vendored
Normal file
|
@ -0,0 +1,138 @@
|
|||
package p
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Perl lexer.
|
||||
var Perl = internal.Register(MustNewLexer(
|
||||
&Config{
|
||||
Name: "Perl",
|
||||
Aliases: []string{"perl", "pl"},
|
||||
Filenames: []string{"*.pl", "*.pm", "*.t"},
|
||||
MimeTypes: []string{"text/x-perl", "application/x-perl"},
|
||||
DotAll: true,
|
||||
},
|
||||
Rules{
|
||||
"balanced-regex": {
|
||||
{`/(\\\\|\\[^\\]|[^\\/])*/[egimosx]*`, LiteralStringRegex, Pop(1)},
|
||||
{`!(\\\\|\\[^\\]|[^\\!])*![egimosx]*`, LiteralStringRegex, Pop(1)},
|
||||
{`\\(\\\\|[^\\])*\\[egimosx]*`, LiteralStringRegex, Pop(1)},
|
||||
{`\{(\\\\|\\[^\\]|[^\\}])*\}[egimosx]*`, LiteralStringRegex, Pop(1)},
|
||||
{`<(\\\\|\\[^\\]|[^\\>])*>[egimosx]*`, LiteralStringRegex, Pop(1)},
|
||||
{`\[(\\\\|\\[^\\]|[^\\\]])*\][egimosx]*`, LiteralStringRegex, Pop(1)},
|
||||
{`\((\\\\|\\[^\\]|[^\\)])*\)[egimosx]*`, LiteralStringRegex, Pop(1)},
|
||||
{`@(\\\\|\\[^\\]|[^\\@])*@[egimosx]*`, LiteralStringRegex, Pop(1)},
|
||||
{`%(\\\\|\\[^\\]|[^\\%])*%[egimosx]*`, LiteralStringRegex, Pop(1)},
|
||||
{`\$(\\\\|\\[^\\]|[^\\$])*\$[egimosx]*`, LiteralStringRegex, Pop(1)},
|
||||
},
|
||||
"root": {
|
||||
{`\A\#!.+?$`, CommentHashbang, nil},
|
||||
{`\#.*?$`, CommentSingle, nil},
|
||||
{`^=[a-zA-Z0-9]+\s+.*?\n=cut`, CommentMultiline, nil},
|
||||
{Words(``, `\b`, `case`, `continue`, `do`, `else`, `elsif`, `for`, `foreach`, `if`, `last`, `my`, `next`, `our`, `redo`, `reset`, `then`, `unless`, `until`, `while`, `print`, `new`, `BEGIN`, `CHECK`, `INIT`, `END`, `return`), Keyword, nil},
|
||||
{`(format)(\s+)(\w+)(\s*)(=)(\s*\n)`, ByGroups(Keyword, Text, Name, Text, Punctuation, Text), Push("format")},
|
||||
{`(eq|lt|gt|le|ge|ne|not|and|or|cmp)\b`, OperatorWord, nil},
|
||||
{`s/(\\\\|\\[^\\]|[^\\/])*/(\\\\|\\[^\\]|[^\\/])*/[egimosx]*`, LiteralStringRegex, nil},
|
||||
{`s!(\\\\|\\!|[^!])*!(\\\\|\\!|[^!])*![egimosx]*`, LiteralStringRegex, nil},
|
||||
{`s\\(\\\\|[^\\])*\\(\\\\|[^\\])*\\[egimosx]*`, LiteralStringRegex, nil},
|
||||
{`s@(\\\\|\\[^\\]|[^\\@])*@(\\\\|\\[^\\]|[^\\@])*@[egimosx]*`, LiteralStringRegex, nil},
|
||||
{`s%(\\\\|\\[^\\]|[^\\%])*%(\\\\|\\[^\\]|[^\\%])*%[egimosx]*`, LiteralStringRegex, nil},
|
||||
{`s\{(\\\\|\\[^\\]|[^\\}])*\}\s*`, LiteralStringRegex, Push("balanced-regex")},
|
||||
{`s<(\\\\|\\[^\\]|[^\\>])*>\s*`, LiteralStringRegex, Push("balanced-regex")},
|
||||
{`s\[(\\\\|\\[^\\]|[^\\\]])*\]\s*`, LiteralStringRegex, Push("balanced-regex")},
|
||||
{`s\((\\\\|\\[^\\]|[^\\)])*\)\s*`, LiteralStringRegex, Push("balanced-regex")},
|
||||
{`m?/(\\\\|\\[^\\]|[^\\/\n])*/[gcimosx]*`, LiteralStringRegex, nil},
|
||||
{`m(?=[/!\\{<\[(@%$])`, LiteralStringRegex, Push("balanced-regex")},
|
||||
{`((?<==~)|(?<=\())\s*/(\\\\|\\[^\\]|[^\\/])*/[gcimosx]*`, LiteralStringRegex, nil},
|
||||
{`\s+`, Text, nil},
|
||||
{Words(``, `\b`, `abs`, `accept`, `alarm`, `atan2`, `bind`, `binmode`, `bless`, `caller`, `chdir`, `chmod`, `chomp`, `chop`, `chown`, `chr`, `chroot`, `close`, `closedir`, `connect`, `continue`, `cos`, `crypt`, `dbmclose`, `dbmopen`, `defined`, `delete`, `die`, `dump`, `each`, `endgrent`, `endhostent`, `endnetent`, `endprotoent`, `endpwent`, `endservent`, `eof`, `eval`, `exec`, `exists`, `exit`, `exp`, `fcntl`, `fileno`, `flock`, `fork`, `format`, `formline`, `getc`, `getgrent`, `getgrgid`, `getgrnam`, `gethostbyaddr`, `gethostbyname`, `gethostent`, `getlogin`, `getnetbyaddr`, `getnetbyname`, `getnetent`, `getpeername`, `getpgrp`, `getppid`, `getpriority`, `getprotobyname`, `getprotobynumber`, `getprotoent`, `getpwent`, `getpwnam`, `getpwuid`, `getservbyname`, `getservbyport`, `getservent`, `getsockname`, `getsockopt`, `glob`, `gmtime`, `goto`, `grep`, `hex`, `import`, `index`, `int`, `ioctl`, `join`, `keys`, `kill`, `last`, `lc`, `lcfirst`, `length`, `link`, `listen`, `local`, `localtime`, `log`, `lstat`, `map`, `mkdir`, `msgctl`, `msgget`, `msgrcv`, `msgsnd`, `my`, `next`, `oct`, `open`, `opendir`, `ord`, `our`, `pack`, `pipe`, `pop`, `pos`, `printf`, `prototype`, `push`, `quotemeta`, `rand`, `read`, `readdir`, `readline`, `readlink`, `readpipe`, `recv`, `redo`, `ref`, `rename`, `reverse`, `rewinddir`, `rindex`, `rmdir`, `scalar`, `seek`, `seekdir`, `select`, `semctl`, `semget`, `semop`, `send`, `setgrent`, `sethostent`, `setnetent`, `setpgrp`, `setpriority`, `setprotoent`, `setpwent`, `setservent`, `setsockopt`, `shift`, `shmctl`, `shmget`, `shmread`, `shmwrite`, `shutdown`, `sin`, `sleep`, `socket`, `socketpair`, `sort`, `splice`, `split`, `sprintf`, `sqrt`, `srand`, `stat`, `study`, `substr`, `symlink`, `syscall`, `sysopen`, `sysread`, `sysseek`, `system`, `syswrite`, `tell`, `telldir`, `tie`, `tied`, `time`, `times`, `tr`, `truncate`, `uc`, `ucfirst`, `umask`, `undef`, `unlink`, `unpack`, `unshift`, `untie`, `utime`, `values`, `vec`, `wait`, `waitpid`, `wantarray`, `warn`, `write`), NameBuiltin, nil},
|
||||
{`((__(DATA|DIE|WARN)__)|(STD(IN|OUT|ERR)))\b`, NameBuiltinPseudo, nil},
|
||||
{`(<<)([\'"]?)([a-zA-Z_]\w*)(\2;?\n.*?\n)(\3)(\n)`, ByGroups(LiteralString, LiteralString, LiteralStringDelimiter, LiteralString, LiteralStringDelimiter, Text), nil},
|
||||
{`__END__`, CommentPreproc, Push("end-part")},
|
||||
{`\$\^[ADEFHILMOPSTWX]`, NameVariableGlobal, nil},
|
||||
{"\\$[\\\\\\\"\\[\\]'&`+*.,;=%~?@$!<>(^|/-](?!\\w)", NameVariableGlobal, nil},
|
||||
{`[$@%#]+`, NameVariable, Push("varname")},
|
||||
{`0_?[0-7]+(_[0-7]+)*`, LiteralNumberOct, nil},
|
||||
{`0x[0-9A-Fa-f]+(_[0-9A-Fa-f]+)*`, LiteralNumberHex, nil},
|
||||
{`0b[01]+(_[01]+)*`, LiteralNumberBin, nil},
|
||||
{`(?i)(\d*(_\d*)*\.\d+(_\d*)*|\d+(_\d*)*\.\d+(_\d*)*)(e[+-]?\d+)?`, LiteralNumberFloat, nil},
|
||||
{`(?i)\d+(_\d*)*e[+-]?\d+(_\d*)*`, LiteralNumberFloat, nil},
|
||||
{`\d+(_\d+)*`, LiteralNumberInteger, nil},
|
||||
{`'(\\\\|\\[^\\]|[^'\\])*'`, LiteralString, nil},
|
||||
{`"(\\\\|\\[^\\]|[^"\\])*"`, LiteralString, nil},
|
||||
{"`(\\\\\\\\|\\\\[^\\\\]|[^`\\\\])*`", LiteralStringBacktick, nil},
|
||||
{`<([^\s>]+)>`, LiteralStringRegex, nil},
|
||||
{`(q|qq|qw|qr|qx)\{`, LiteralStringOther, Push("cb-string")},
|
||||
{`(q|qq|qw|qr|qx)\(`, LiteralStringOther, Push("rb-string")},
|
||||
{`(q|qq|qw|qr|qx)\[`, LiteralStringOther, Push("sb-string")},
|
||||
{`(q|qq|qw|qr|qx)\<`, LiteralStringOther, Push("lt-string")},
|
||||
{`(q|qq|qw|qr|qx)([\W_])(.|\n)*?\2`, LiteralStringOther, nil},
|
||||
{`(package)(\s+)([a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*)`, ByGroups(Keyword, Text, NameNamespace), nil},
|
||||
{`(use|require|no)(\s+)([a-zA-Z_]\w*(?:::[a-zA-Z_]\w*)*)`, ByGroups(Keyword, Text, NameNamespace), nil},
|
||||
{`(sub)(\s+)`, ByGroups(Keyword, Text), Push("funcname")},
|
||||
{Words(``, `\b`, `no`, `package`, `require`, `use`), Keyword, nil},
|
||||
{`(\[\]|\*\*|::|<<|>>|>=|<=>|<=|={3}|!=|=~|!~|&&?|\|\||\.{1,3})`, Operator, nil},
|
||||
{`[-+/*%=<>&^|!\\~]=?`, Operator, nil},
|
||||
{`[()\[\]:;,<>/?{}]`, Punctuation, nil},
|
||||
{`(?=\w)`, Name, Push("name")},
|
||||
},
|
||||
"format": {
|
||||
{`\.\n`, LiteralStringInterpol, Pop(1)},
|
||||
{`[^\n]*\n`, LiteralStringInterpol, nil},
|
||||
},
|
||||
"varname": {
|
||||
{`\s+`, Text, nil},
|
||||
{`\{`, Punctuation, Pop(1)},
|
||||
{`\)|,`, Punctuation, Pop(1)},
|
||||
{`\w+::`, NameNamespace, nil},
|
||||
{`[\w:]+`, NameVariable, Pop(1)},
|
||||
},
|
||||
"name": {
|
||||
{`[a-zA-Z_]\w*(::[a-zA-Z_]\w*)*(::)?(?=\s*->)`, NameNamespace, Pop(1)},
|
||||
{`[a-zA-Z_]\w*(::[a-zA-Z_]\w*)*::`, NameNamespace, Pop(1)},
|
||||
{`[\w:]+`, Name, Pop(1)},
|
||||
{`[A-Z_]+(?=\W)`, NameConstant, Pop(1)},
|
||||
{`(?=\W)`, Text, Pop(1)},
|
||||
},
|
||||
"funcname": {
|
||||
{`[a-zA-Z_]\w*[!?]?`, NameFunction, nil},
|
||||
{`\s+`, Text, nil},
|
||||
{`(\([$@%]*\))(\s*)`, ByGroups(Punctuation, Text), nil},
|
||||
{`;`, Punctuation, Pop(1)},
|
||||
{`.*?\{`, Punctuation, Pop(1)},
|
||||
},
|
||||
"cb-string": {
|
||||
{`\\[{}\\]`, LiteralStringOther, nil},
|
||||
{`\\`, LiteralStringOther, nil},
|
||||
{`\{`, LiteralStringOther, Push("cb-string")},
|
||||
{`\}`, LiteralStringOther, Pop(1)},
|
||||
{`[^{}\\]+`, LiteralStringOther, nil},
|
||||
},
|
||||
"rb-string": {
|
||||
{`\\[()\\]`, LiteralStringOther, nil},
|
||||
{`\\`, LiteralStringOther, nil},
|
||||
{`\(`, LiteralStringOther, Push("rb-string")},
|
||||
{`\)`, LiteralStringOther, Pop(1)},
|
||||
{`[^()]+`, LiteralStringOther, nil},
|
||||
},
|
||||
"sb-string": {
|
||||
{`\\[\[\]\\]`, LiteralStringOther, nil},
|
||||
{`\\`, LiteralStringOther, nil},
|
||||
{`\[`, LiteralStringOther, Push("sb-string")},
|
||||
{`\]`, LiteralStringOther, Pop(1)},
|
||||
{`[^\[\]]+`, LiteralStringOther, nil},
|
||||
},
|
||||
"lt-string": {
|
||||
{`\\[<>\\]`, LiteralStringOther, nil},
|
||||
{`\\`, LiteralStringOther, nil},
|
||||
{`\<`, LiteralStringOther, Push("lt-string")},
|
||||
{`\>`, LiteralStringOther, Pop(1)},
|
||||
{`[^<>]+`, LiteralStringOther, nil},
|
||||
},
|
||||
"end-part": {
|
||||
{`.+`, CommentPreproc, Pop(1)},
|
||||
},
|
||||
},
|
||||
))
|
57
vendor/github.com/alecthomas/chroma/lexers/p/pig.go
generated
vendored
Normal file
57
vendor/github.com/alecthomas/chroma/lexers/p/pig.go
generated
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
package p
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Pig lexer.
|
||||
var Pig = internal.Register(MustNewLexer(
|
||||
&Config{
|
||||
Name: "Pig",
|
||||
Aliases: []string{"pig"},
|
||||
Filenames: []string{"*.pig"},
|
||||
MimeTypes: []string{"text/x-pig"},
|
||||
CaseInsensitive: true,
|
||||
},
|
||||
Rules{
|
||||
"root": {
|
||||
{`\s+`, Text, nil},
|
||||
{`--.*`, Comment, nil},
|
||||
{`/\*[\w\W]*?\*/`, CommentMultiline, nil},
|
||||
{`\\\n`, Text, nil},
|
||||
{`\\`, Text, nil},
|
||||
{`\'(?:\\[ntbrf\\\']|\\u[0-9a-f]{4}|[^\'\\\n\r])*\'`, LiteralString, nil},
|
||||
Include("keywords"),
|
||||
Include("types"),
|
||||
Include("builtins"),
|
||||
Include("punct"),
|
||||
Include("operators"),
|
||||
{`[0-9]*\.[0-9]+(e[0-9]+)?[fd]?`, LiteralNumberFloat, nil},
|
||||
{`0x[0-9a-f]+`, LiteralNumberHex, nil},
|
||||
{`[0-9]+L?`, LiteralNumberInteger, nil},
|
||||
{`\n`, Text, nil},
|
||||
{`([a-z_]\w*)(\s*)(\()`, ByGroups(NameFunction, Text, Punctuation), nil},
|
||||
{`[()#:]`, Text, nil},
|
||||
{`[^(:#\'")\s]+`, Text, nil},
|
||||
{`\S+\s+`, Text, nil},
|
||||
},
|
||||
"keywords": {
|
||||
{`(assert|and|any|all|arrange|as|asc|bag|by|cache|CASE|cat|cd|cp|%declare|%default|define|dense|desc|describe|distinct|du|dump|eval|exex|explain|filter|flatten|foreach|full|generate|group|help|if|illustrate|import|inner|input|into|is|join|kill|left|limit|load|ls|map|matches|mkdir|mv|not|null|onschema|or|order|outer|output|parallel|pig|pwd|quit|register|returns|right|rm|rmf|rollup|run|sample|set|ship|split|stderr|stdin|stdout|store|stream|through|union|using|void)\b`, Keyword, nil},
|
||||
},
|
||||
"builtins": {
|
||||
{`(AVG|BinStorage|cogroup|CONCAT|copyFromLocal|copyToLocal|COUNT|cross|DIFF|MAX|MIN|PigDump|PigStorage|SIZE|SUM|TextLoader|TOKENIZE)\b`, NameBuiltin, nil},
|
||||
},
|
||||
"types": {
|
||||
{`(bytearray|BIGINTEGER|BIGDECIMAL|chararray|datetime|double|float|int|long|tuple)\b`, KeywordType, nil},
|
||||
},
|
||||
"punct": {
|
||||
{`[;(){}\[\]]`, Punctuation, nil},
|
||||
},
|
||||
"operators": {
|
||||
{`[#=,./%+\-?]`, Operator, nil},
|
||||
{`(eq|gt|lt|gte|lte|neq|matches)\b`, Operator, nil},
|
||||
{`(==|<=|<|>=|>|!=)`, Operator, nil},
|
||||
},
|
||||
},
|
||||
))
|
41
vendor/github.com/alecthomas/chroma/lexers/p/pkgconfig.go
generated
vendored
Normal file
41
vendor/github.com/alecthomas/chroma/lexers/p/pkgconfig.go
generated
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
package p
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Pkgconfig lexer.
|
||||
var Pkgconfig = internal.Register(MustNewLexer(
|
||||
&Config{
|
||||
Name: "PkgConfig",
|
||||
Aliases: []string{"pkgconfig"},
|
||||
Filenames: []string{"*.pc"},
|
||||
MimeTypes: []string{},
|
||||
},
|
||||
Rules{
|
||||
"root": {
|
||||
{`#.*$`, CommentSingle, nil},
|
||||
{`^(\w+)(=)`, ByGroups(NameAttribute, Operator), nil},
|
||||
{`^([\w.]+)(:)`, ByGroups(NameTag, Punctuation), Push("spvalue")},
|
||||
Include("interp"),
|
||||
{`[^${}#=:\n.]+`, Text, nil},
|
||||
{`.`, Text, nil},
|
||||
},
|
||||
"interp": {
|
||||
{`\$\$`, Text, nil},
|
||||
{`\$\{`, LiteralStringInterpol, Push("curly")},
|
||||
},
|
||||
"curly": {
|
||||
{`\}`, LiteralStringInterpol, Pop(1)},
|
||||
{`\w+`, NameAttribute, nil},
|
||||
},
|
||||
"spvalue": {
|
||||
Include("interp"),
|
||||
{`#.*$`, CommentSingle, Pop(1)},
|
||||
{`\n`, Text, Pop(1)},
|
||||
{`[^${}#\n]+`, Text, nil},
|
||||
{`.`, Text, nil},
|
||||
},
|
||||
},
|
||||
))
|
17
vendor/github.com/alecthomas/chroma/lexers/p/plaintext.go
generated
vendored
Normal file
17
vendor/github.com/alecthomas/chroma/lexers/p/plaintext.go
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
package p
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
var Plaintext = internal.Register(MustNewLexer(
|
||||
&Config{
|
||||
Name: "plaintext",
|
||||
Aliases: []string{"text", "plain", "no-highlight"},
|
||||
Filenames: []string{"*.txt"},
|
||||
MimeTypes: []string{"text/plain"},
|
||||
Priority: 0.1,
|
||||
},
|
||||
internal.PlaintextRules,
|
||||
))
|
58
vendor/github.com/alecthomas/chroma/lexers/p/plsql.go
generated
vendored
Normal file
58
vendor/github.com/alecthomas/chroma/lexers/p/plsql.go
generated
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
package p
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Pl/Pgsql lexer.
|
||||
var PLpgSQL = internal.Register(MustNewLexer(
|
||||
&Config{
|
||||
Name: "PL/pgSQL",
|
||||
Aliases: []string{"plpgsql"},
|
||||
Filenames: []string{},
|
||||
MimeTypes: []string{"text/x-plpgsql"},
|
||||
NotMultiline: true,
|
||||
CaseInsensitive: true,
|
||||
},
|
||||
Rules{
|
||||
"root": {
|
||||
{`\%[a-z]\w*\b`, NameBuiltin, nil},
|
||||
{`:=`, Operator, nil},
|
||||
{`\<\<[a-z]\w*\>\>`, NameLabel, nil},
|
||||
{`\#[a-z]\w*\b`, KeywordPseudo, nil},
|
||||
{`\s+`, Text, nil},
|
||||
{`--.*\n?`, CommentSingle, nil},
|
||||
{`/\*`, CommentMultiline, Push("multiline-comments")},
|
||||
{`(bigint|bigserial|bit|bit\s+varying|bool|boolean|box|bytea|char|character|character\s+varying|cidr|circle|date|decimal|double\s+precision|float4|float8|inet|int|int2|int4|int8|integer|interval|json|jsonb|line|lseg|macaddr|money|numeric|path|pg_lsn|point|polygon|real|serial|serial2|serial4|serial8|smallint|smallserial|text|time|timestamp|timestamptz|timetz|tsquery|tsvector|txid_snapshot|uuid|varbit|varchar|with\s+time\s+zone|without\s+time\s+zone|xml|anyarray|anyelement|anyenum|anynonarray|anyrange|cstring|fdw_handler|internal|language_handler|opaque|record|void)\b`, NameBuiltin, nil},
|
||||
{Words(``, `\b`, `ABORT`, `ABSOLUTE`, `ACCESS`, `ACTION`, `ADD`, `ADMIN`, `AFTER`, `AGGREGATE`, `ALL`, `ALSO`, `ALTER`, `ALWAYS`, `ANALYSE`, `ANALYZE`, `AND`, `ANY`, `ARRAY`, `AS`, `ASC`, `ASSERTION`, `ASSIGNMENT`, `ASYMMETRIC`, `AT`, `ATTRIBUTE`, `AUTHORIZATION`, `BACKWARD`, `BEFORE`, `BEGIN`, `BETWEEN`, `BIGINT`, `BINARY`, `BIT`, `BOOLEAN`, `BOTH`, `BY`, `CACHE`, `CALLED`, `CASCADE`, `CASCADED`, `CASE`, `CAST`, `CATALOG`, `CHAIN`, `CHAR`, `CHARACTER`, `CHARACTERISTICS`, `CHECK`, `CHECKPOINT`, `CLASS`, `CLOSE`, `CLUSTER`, `COALESCE`, `COLLATE`, `COLLATION`, `COLUMN`, `COMMENT`, `COMMENTS`, `COMMIT`, `COMMITTED`, `CONCURRENTLY`, `CONFIGURATION`, `CONNECTION`, `CONSTRAINT`, `CONSTRAINTS`, `CONTENT`, `CONTINUE`, `CONVERSION`, `COPY`, `COST`, `CREATE`, `CROSS`, `CSV`, `CURRENT`, `CURRENT_CATALOG`, `CURRENT_DATE`, `CURRENT_ROLE`, `CURRENT_SCHEMA`, `CURRENT_TIME`, `CURRENT_TIMESTAMP`, `CURRENT_USER`, `CURSOR`, `CYCLE`, `DATA`, `DATABASE`, `DAY`, `DEALLOCATE`, `DEC`, `DECIMAL`, `DECLARE`, `DEFAULT`, `DEFAULTS`, `DEFERRABLE`, `DEFERRED`, `DEFINER`, `DELETE`, `DELIMITER`, `DELIMITERS`, `DESC`, `DICTIONARY`, `DISABLE`, `DISCARD`, `DISTINCT`, `DO`, `DOCUMENT`, `DOMAIN`, `DOUBLE`, `DROP`, `EACH`, `ELSE`, `ENABLE`, `ENCODING`, `ENCRYPTED`, `END`, `ENUM`, `ESCAPE`, `EVENT`, `EXCEPT`, `EXCLUDE`, `EXCLUDING`, `EXCLUSIVE`, `EXECUTE`, `EXISTS`, `EXPLAIN`, `EXTENSION`, `EXTERNAL`, `EXTRACT`, `FALSE`, `FAMILY`, `FETCH`, `FILTER`, `FIRST`, `FLOAT`, `FOLLOWING`, `FOR`, `FORCE`, `FOREIGN`, `FORWARD`, `FREEZE`, `FROM`, `FULL`, `FUNCTION`, `FUNCTIONS`, `GLOBAL`, `GRANT`, `GRANTED`, `GREATEST`, `GROUP`, `HANDLER`, `HAVING`, `HEADER`, `HOLD`, `HOUR`, `IDENTITY`, `IF`, `ILIKE`, `IMMEDIATE`, `IMMUTABLE`, `IMPLICIT`, `IN`, `INCLUDING`, `INCREMENT`, `INDEX`, `INDEXES`, `INHERIT`, `INHERITS`, `INITIALLY`, `INLINE`, `INNER`, `INOUT`, `INPUT`, `INSENSITIVE`, `INSERT`, `INSTEAD`, `INT`, `INTEGER`, `INTERSECT`, `INTERVAL`, `INTO`, `INVOKER`, `IS`, `ISNULL`, `ISOLATION`, `JOIN`, `KEY`, `LABEL`, `LANGUAGE`, `LARGE`, `LAST`, `LATERAL`, `LC_COLLATE`, `LC_CTYPE`, `LEADING`, `LEAKPROOF`, `LEAST`, `LEFT`, `LEVEL`, `LIKE`, `LIMIT`, `LISTEN`, `LOAD`, `LOCAL`, `LOCALTIME`, `LOCALTIMESTAMP`, `LOCATION`, `LOCK`, `MAPPING`, `MATCH`, `MATERIALIZED`, `MAXVALUE`, `MINUTE`, `MINVALUE`, `MODE`, `MONTH`, `MOVE`, `NAME`, `NAMES`, `NATIONAL`, `NATURAL`, `NCHAR`, `NEXT`, `NO`, `NONE`, `NOT`, `NOTHING`, `NOTIFY`, `NOTNULL`, `NOWAIT`, `NULL`, `NULLIF`, `NULLS`, `NUMERIC`, `OBJECT`, `OF`, `OFF`, `OFFSET`, `OIDS`, `ON`, `ONLY`, `OPERATOR`, `OPTION`, `OPTIONS`, `OR`, `ORDER`, `ORDINALITY`, `OUT`, `OUTER`, `OVER`, `OVERLAPS`, `OVERLAY`, `OWNED`, `OWNER`, `PARSER`, `PARTIAL`, `PARTITION`, `PASSING`, `PASSWORD`, `PLACING`, `PLANS`, `POLICY`, `POSITION`, `PRECEDING`, `PRECISION`, `PREPARE`, `PREPARED`, `PRESERVE`, `PRIMARY`, `PRIOR`, `PRIVILEGES`, `PROCEDURAL`, `PROCEDURE`, `PROGRAM`, `QUOTE`, `RANGE`, `READ`, `REAL`, `REASSIGN`, `RECHECK`, `RECURSIVE`, `REF`, `REFERENCES`, `REFRESH`, `REINDEX`, `RELATIVE`, `RELEASE`, `RENAME`, `REPEATABLE`, `REPLACE`, `REPLICA`, `RESET`, `RESTART`, `RESTRICT`, `RETURNING`, `RETURNS`, `REVOKE`, `RIGHT`, `ROLE`, `ROLLBACK`, `ROW`, `ROWS`, `RULE`, `SAVEPOINT`, `SCHEMA`, `SCROLL`, `SEARCH`, `SECOND`, `SECURITY`, `SELECT`, `SEQUENCE`, `SEQUENCES`, `SERIALIZABLE`, `SERVER`, `SESSION`, `SESSION_USER`, `SET`, `SETOF`, `SHARE`, `SHOW`, `SIMILAR`, `SIMPLE`, `SMALLINT`, `SNAPSHOT`, `SOME`, `STABLE`, `STANDALONE`, `START`, `STATEMENT`, `STATISTICS`, `STDIN`, `STDOUT`, `STORAGE`, `STRICT`, `STRIP`, `SUBSTRING`, `SYMMETRIC`, `SYSID`, `SYSTEM`, `TABLE`, `TABLES`, `TABLESPACE`, `TEMP`, `TEMPLATE`, `TEMPORARY`, `TEXT`, `THEN`, `TIME`, `TIMESTAMP`, `TO`, `TRAILING`, `TRANSACTION`, `TREAT`, `TRIGGER`, `TRIM`, `TRUE`, `TRUNCATE`, `TRUSTED`, `TYPE`, `TYPES`, `UNBOUNDED`, `UNCOMMITTED`, `UNENCRYPTED`, `UNION`, `UNIQUE`, `UNKNOWN`, `UNLISTEN`, `UNLOGGED`, `UNTIL`, `UPDATE`, `USER`, `USING`, `VACUUM`, `VALID`, `VALIDATE`, `VALIDATOR`, `VALUE`, `VALUES`, `VARCHAR`, `VARIADIC`, `VARYING`, `VERBOSE`, `VERSION`, `VIEW`, `VIEWS`, `VOLATILE`, `WHEN`, `WHERE`, `WHITESPACE`, `WINDOW`, `WITH`, `WITHIN`, `WITHOUT`, `WORK`, `WRAPPER`, `WRITE`, `XML`, `XMLATTRIBUTES`, `XMLCONCAT`, `XMLELEMENT`, `XMLEXISTS`, `XMLFOREST`, `XMLPARSE`, `XMLPI`, `XMLROOT`, `XMLSERIALIZE`, `YEAR`, `YES`, `ZONE`, `ALIAS`, `CONSTANT`, `DIAGNOSTICS`, `ELSIF`, `EXCEPTION`, `EXIT`, `FOREACH`, `GET`, `LOOP`, `NOTICE`, `OPEN`, `PERFORM`, `QUERY`, `RAISE`, `RETURN`, `REVERSE`, `SQLSTATE`, `WHILE`), Keyword, nil},
|
||||
{"[+*/<>=~!@#%^&|`?-]+", Operator, nil},
|
||||
{`::`, Operator, nil},
|
||||
{`\$\d+`, NameVariable, nil},
|
||||
{`([0-9]*\.[0-9]*|[0-9]+)(e[+-]?[0-9]+)?`, LiteralNumberFloat, nil},
|
||||
{`[0-9]+`, LiteralNumberInteger, nil},
|
||||
{`((?:E|U&)?)(')`, ByGroups(LiteralStringAffix, LiteralStringSingle), Push("string")},
|
||||
{`((?:U&)?)(")`, ByGroups(LiteralStringAffix, LiteralStringName), Push("quoted-ident")},
|
||||
// { `(?s)(\$)([^$]*)(\$)(.*?)(\$)(\2)(\$)`, ?? <function language_callback at 0x108964400> ??, nil },
|
||||
{`[a-z_]\w*`, Name, nil},
|
||||
{`:(['"]?)[a-z]\w*\b\1`, NameVariable, nil},
|
||||
{`[;:()\[\]{},.]`, Punctuation, nil},
|
||||
},
|
||||
"multiline-comments": {
|
||||
{`/\*`, CommentMultiline, Push("multiline-comments")},
|
||||
{`\*/`, CommentMultiline, Pop(1)},
|
||||
{`[^/*]+`, CommentMultiline, nil},
|
||||
{`[/*]`, CommentMultiline, nil},
|
||||
},
|
||||
"string": {
|
||||
{`[^']+`, LiteralStringSingle, nil},
|
||||
{`''`, LiteralStringSingle, nil},
|
||||
{`'`, LiteralStringSingle, Pop(1)},
|
||||
},
|
||||
"quoted-ident": {
|
||||
{`[^"]+`, LiteralStringName, nil},
|
||||
{`""`, LiteralStringName, nil},
|
||||
{`"`, LiteralStringName, Pop(1)},
|
||||
},
|
||||
},
|
||||
))
|
77
vendor/github.com/alecthomas/chroma/lexers/p/postgres.go
generated
vendored
Normal file
77
vendor/github.com/alecthomas/chroma/lexers/p/postgres.go
generated
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
package p
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Postgresql Sql Dialect lexer.
|
||||
var PostgreSQL = internal.Register(MustNewLexer(
|
||||
&Config{
|
||||
Name: "PostgreSQL SQL dialect",
|
||||
Aliases: []string{"postgresql", "postgres"},
|
||||
Filenames: []string{},
|
||||
MimeTypes: []string{"text/x-postgresql"},
|
||||
NotMultiline: true,
|
||||
CaseInsensitive: true,
|
||||
},
|
||||
Rules{
|
||||
"root": {
|
||||
{`\s+`, Text, nil},
|
||||
{`--.*\n?`, CommentSingle, nil},
|
||||
{`/\*`, CommentMultiline, Push("multiline-comments")},
|
||||
{`(bigint|bigserial|bit|bit\s+varying|bool|boolean|box|bytea|char|character|character\s+varying|cidr|circle|date|decimal|double\s+precision|float4|float8|inet|int|int2|int4|int8|integer|interval|json|jsonb|line|lseg|macaddr|money|numeric|path|pg_lsn|point|polygon|real|serial|serial2|serial4|serial8|smallint|smallserial|text|time|timestamp|timestamptz|timetz|tsquery|tsvector|txid_snapshot|uuid|varbit|varchar|with\s+time\s+zone|without\s+time\s+zone|xml|anyarray|anyelement|anyenum|anynonarray|anyrange|cstring|fdw_handler|internal|language_handler|opaque|record|void)\b`, NameBuiltin, nil},
|
||||
{`(?s)(DO)(\s+)(?:(LANGUAGE)?(\s+)('?)(\w+)?('?)(\s+))?(\$)([^$]*)(\$)(.*?)(\$)(\10)(\$)`,
|
||||
UsingByGroup(
|
||||
internal.Get,
|
||||
6, 12,
|
||||
Keyword, Text, Keyword, Text, // DO LANGUAGE
|
||||
StringSingle, StringSingle, StringSingle, Text, // 'plpgsql'
|
||||
StringHeredoc, StringHeredoc, StringHeredoc, // $tag$
|
||||
StringHeredoc, // (code block)
|
||||
StringHeredoc, StringHeredoc, StringHeredoc, // $tag$
|
||||
),
|
||||
nil,
|
||||
},
|
||||
{Words(``, `\b`, `ABORT`, `ABSOLUTE`, `ACCESS`, `ACTION`, `ADD`, `ADMIN`, `AFTER`, `AGGREGATE`, `ALL`, `ALSO`, `ALTER`, `ALWAYS`, `ANALYSE`, `ANALYZE`, `AND`, `ANY`, `ARRAY`, `AS`, `ASC`, `ASSERTION`, `ASSIGNMENT`, `ASYMMETRIC`, `AT`, `ATTRIBUTE`, `AUTHORIZATION`, `BACKWARD`, `BEFORE`, `BEGIN`, `BETWEEN`, `BIGINT`, `BINARY`, `BIT`, `BOOLEAN`, `BOTH`, `BY`, `CACHE`, `CALLED`, `CASCADE`, `CASCADED`, `CASE`, `CAST`, `CATALOG`, `CHAIN`, `CHAR`, `CHARACTER`, `CHARACTERISTICS`, `CHECK`, `CHECKPOINT`, `CLASS`, `CLOSE`, `CLUSTER`, `COALESCE`, `COLLATE`, `COLLATION`, `COLUMN`, `COMMENT`, `COMMENTS`, `COMMIT`, `COMMITTED`, `CONCURRENTLY`, `CONFIGURATION`, `CONNECTION`, `CONSTRAINT`, `CONSTRAINTS`, `CONTENT`, `CONTINUE`, `CONVERSION`, `COPY`, `COST`, `CREATE`, `CROSS`, `CSV`, `CURRENT`, `CURRENT_CATALOG`, `CURRENT_DATE`, `CURRENT_ROLE`, `CURRENT_SCHEMA`, `CURRENT_TIME`, `CURRENT_TIMESTAMP`, `CURRENT_USER`, `CURSOR`, `CYCLE`, `DATA`, `DATABASE`, `DAY`, `DEALLOCATE`, `DEC`, `DECIMAL`, `DECLARE`, `DEFAULT`, `DEFAULTS`, `DEFERRABLE`, `DEFERRED`, `DEFINER`, `DELETE`, `DELIMITER`, `DELIMITERS`, `DESC`, `DICTIONARY`, `DISABLE`, `DISCARD`, `DISTINCT`, `DO`, `DOCUMENT`, `DOMAIN`, `DOUBLE`, `DROP`, `EACH`, `ELSE`, `ENABLE`, `ENCODING`, `ENCRYPTED`, `END`, `ENUM`, `ESCAPE`, `EVENT`, `EXCEPT`, `EXCLUDE`, `EXCLUDING`, `EXCLUSIVE`, `EXECUTE`, `EXISTS`, `EXPLAIN`, `EXTENSION`, `EXTERNAL`, `EXTRACT`, `FALSE`, `FAMILY`, `FETCH`, `FILTER`, `FIRST`, `FLOAT`, `FOLLOWING`, `FOR`, `FORCE`, `FOREIGN`, `FORWARD`, `FREEZE`, `FROM`, `FULL`, `FUNCTION`, `FUNCTIONS`, `GLOBAL`, `GRANT`, `GRANTED`, `GREATEST`, `GROUP`, `HANDLER`, `HAVING`, `HEADER`, `HOLD`, `HOUR`, `IDENTITY`, `IF`, `ILIKE`, `IMMEDIATE`, `IMMUTABLE`, `IMPLICIT`, `IN`, `INCLUDING`, `INCREMENT`, `INDEX`, `INDEXES`, `INHERIT`, `INHERITS`, `INITIALLY`, `INLINE`, `INNER`, `INOUT`, `INPUT`, `INSENSITIVE`, `INSERT`, `INSTEAD`, `INT`, `INTEGER`, `INTERSECT`, `INTERVAL`, `INTO`, `INVOKER`, `IS`, `ISNULL`, `ISOLATION`, `JOIN`, `KEY`, `LABEL`, `LANGUAGE`, `LARGE`, `LAST`, `LATERAL`, `LC_COLLATE`, `LC_CTYPE`, `LEADING`, `LEAKPROOF`, `LEAST`, `LEFT`, `LEVEL`, `LIKE`, `LIMIT`, `LISTEN`, `LOAD`, `LOCAL`, `LOCALTIME`, `LOCALTIMESTAMP`, `LOCATION`, `LOCK`, `MAPPING`, `MATCH`, `MATERIALIZED`, `MAXVALUE`, `MINUTE`, `MINVALUE`, `MODE`, `MONTH`, `MOVE`, `NAME`, `NAMES`, `NATIONAL`, `NATURAL`, `NCHAR`, `NEXT`, `NO`, `NONE`, `NOT`, `NOTHING`, `NOTIFY`, `NOTNULL`, `NOWAIT`, `NULL`, `NULLIF`, `NULLS`, `NUMERIC`, `OBJECT`, `OF`, `OFF`, `OFFSET`, `OIDS`, `ON`, `ONLY`, `OPERATOR`, `OPTION`, `OPTIONS`, `OR`, `ORDER`, `ORDINALITY`, `OUT`, `OUTER`, `OVER`, `OVERLAPS`, `OVERLAY`, `OWNED`, `OWNER`, `PARSER`, `PARTIAL`, `PARTITION`, `PASSING`, `PASSWORD`, `PLACING`, `PLANS`, `POLICY`, `POSITION`, `PRECEDING`, `PRECISION`, `PREPARE`, `PREPARED`, `PRESERVE`, `PRIMARY`, `PRIOR`, `PRIVILEGES`, `PROCEDURAL`, `PROCEDURE`, `PROGRAM`, `QUOTE`, `RANGE`, `READ`, `REAL`, `REASSIGN`, `RECHECK`, `RECURSIVE`, `REF`, `REFERENCES`, `REFRESH`, `REINDEX`, `RELATIVE`, `RELEASE`, `RENAME`, `REPEATABLE`, `REPLACE`, `REPLICA`, `RESET`, `RESTART`, `RESTRICT`, `RETURNING`, `RETURNS`, `REVOKE`, `RIGHT`, `ROLE`, `ROLLBACK`, `ROW`, `ROWS`, `RULE`, `SAVEPOINT`, `SCHEMA`, `SCROLL`, `SEARCH`, `SECOND`, `SECURITY`, `SELECT`, `SEQUENCE`, `SEQUENCES`, `SERIALIZABLE`, `SERVER`, `SESSION`, `SESSION_USER`, `SET`, `SETOF`, `SHARE`, `SHOW`, `SIMILAR`, `SIMPLE`, `SMALLINT`, `SNAPSHOT`, `SOME`, `STABLE`, `STANDALONE`, `START`, `STATEMENT`, `STATISTICS`, `STDIN`, `STDOUT`, `STORAGE`, `STRICT`, `STRIP`, `SUBSTRING`, `SYMMETRIC`, `SYSID`, `SYSTEM`, `TABLE`, `TABLES`, `TABLESPACE`, `TEMP`, `TEMPLATE`, `TEMPORARY`, `TEXT`, `THEN`, `TIME`, `TIMESTAMP`, `TO`, `TRAILING`, `TRANSACTION`, `TREAT`, `TRIGGER`, `TRIM`, `TRUE`, `TRUNCATE`, `TRUSTED`, `TYPE`, `TYPES`, `UNBOUNDED`, `UNCOMMITTED`, `UNENCRYPTED`, `UNION`, `UNIQUE`, `UNKNOWN`, `UNLISTEN`, `UNLOGGED`, `UNTIL`, `UPDATE`, `USER`, `USING`, `VACUUM`, `VALID`, `VALIDATE`, `VALIDATOR`, `VALUE`, `VALUES`, `VARCHAR`, `VARIADIC`, `VARYING`, `VERBOSE`, `VERSION`, `VIEW`, `VIEWS`, `VOLATILE`, `WHEN`, `WHERE`, `WHITESPACE`, `WINDOW`, `WITH`, `WITHIN`, `WITHOUT`, `WORK`, `WRAPPER`, `WRITE`, `XML`, `XMLATTRIBUTES`, `XMLCONCAT`, `XMLELEMENT`, `XMLEXISTS`, `XMLFOREST`, `XMLPARSE`, `XMLPI`, `XMLROOT`, `XMLSERIALIZE`, `YEAR`, `YES`, `ZONE`), Keyword, nil},
|
||||
{"[+*/<>=~!@#%^&|`?-]+", Operator, nil},
|
||||
{`::`, Operator, nil},
|
||||
{`\$\d+`, NameVariable, nil},
|
||||
{`([0-9]*\.[0-9]*|[0-9]+)(e[+-]?[0-9]+)?`, LiteralNumberFloat, nil},
|
||||
{`[0-9]+`, LiteralNumberInteger, nil},
|
||||
{`((?:E|U&)?)(')`, ByGroups(LiteralStringAffix, LiteralStringSingle), Push("string")},
|
||||
{`((?:U&)?)(")`, ByGroups(LiteralStringAffix, LiteralStringName), Push("quoted-ident")},
|
||||
{`(?s)(\$)([^$]*)(\$)(.*?)(\$)(\2)(\$)(\s+)(LANGUAGE)?(\s+)('?)(\w+)?('?)`,
|
||||
UsingByGroup(internal.Get,
|
||||
12, 4,
|
||||
StringHeredoc, StringHeredoc, StringHeredoc, // $tag$
|
||||
StringHeredoc, // (code block)
|
||||
StringHeredoc, StringHeredoc, StringHeredoc, // $tag$
|
||||
Text, Keyword, Text, // <space> LANGUAGE <space>
|
||||
StringSingle, StringSingle, StringSingle, // 'type'
|
||||
),
|
||||
nil,
|
||||
},
|
||||
{`(?s)(\$)([^$]*)(\$)(.*?)(\$)(\2)(\$)`, LiteralStringHeredoc, nil},
|
||||
{`[a-z_]\w*`, Name, nil},
|
||||
{`:(['"]?)[a-z]\w*\b\1`, NameVariable, nil},
|
||||
{`[;:()\[\]{},.]`, Punctuation, nil},
|
||||
},
|
||||
"multiline-comments": {
|
||||
{`/\*`, CommentMultiline, Push("multiline-comments")},
|
||||
{`\*/`, CommentMultiline, Pop(1)},
|
||||
{`[^/*]+`, CommentMultiline, nil},
|
||||
{`[/*]`, CommentMultiline, nil},
|
||||
},
|
||||
"string": {
|
||||
{`[^']+`, LiteralStringSingle, nil},
|
||||
{`''`, LiteralStringSingle, nil},
|
||||
{`'`, LiteralStringSingle, Pop(1)},
|
||||
},
|
||||
"quoted-ident": {
|
||||
{`[^"]+`, LiteralStringName, nil},
|
||||
{`""`, LiteralStringName, nil},
|
||||
{`"`, LiteralStringName, Pop(1)},
|
||||
},
|
||||
},
|
||||
))
|
46
vendor/github.com/alecthomas/chroma/lexers/p/postscript.go
generated
vendored
Normal file
46
vendor/github.com/alecthomas/chroma/lexers/p/postscript.go
generated
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
package p
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Postscript lexer.
|
||||
var Postscript = internal.Register(MustNewLexer(
|
||||
&Config{
|
||||
Name: "PostScript",
|
||||
Aliases: []string{"postscript", "postscr"},
|
||||
Filenames: []string{"*.ps", "*.eps"},
|
||||
MimeTypes: []string{"application/postscript"},
|
||||
},
|
||||
Rules{
|
||||
"root": {
|
||||
{`^%!.+\n`, CommentPreproc, nil},
|
||||
{`%%.*\n`, CommentSpecial, nil},
|
||||
{`(^%.*\n){2,}`, CommentMultiline, nil},
|
||||
{`%.*\n`, CommentSingle, nil},
|
||||
{`\(`, LiteralString, Push("stringliteral")},
|
||||
{`[{}<>\[\]]`, Punctuation, nil},
|
||||
{`<[0-9A-Fa-f]+>(?=[()<>\[\]{}/%\s])`, LiteralNumberHex, nil},
|
||||
{`[0-9]+\#(\-|\+)?([0-9]+\.?|[0-9]*\.[0-9]+|[0-9]+\.[0-9]*)((e|E)[0-9]+)?(?=[()<>\[\]{}/%\s])`, LiteralNumberOct, nil},
|
||||
{`(\-|\+)?([0-9]+\.?|[0-9]*\.[0-9]+|[0-9]+\.[0-9]*)((e|E)[0-9]+)?(?=[()<>\[\]{}/%\s])`, LiteralNumberFloat, nil},
|
||||
{`(\-|\+)?[0-9]+(?=[()<>\[\]{}/%\s])`, LiteralNumberInteger, nil},
|
||||
{`\/[^()<>\[\]{}/%\s]+(?=[()<>\[\]{}/%\s])`, NameVariable, nil},
|
||||
{`[^()<>\[\]{}/%\s]+(?=[()<>\[\]{}/%\s])`, NameFunction, nil},
|
||||
{`(false|true)(?=[()<>\[\]{}/%\s])`, KeywordConstant, nil},
|
||||
{`(eq|ne|g[et]|l[et]|and|or|not|if(?:else)?|for(?:all)?)(?=[()<>\[\]{}/%\s])`, KeywordReserved, nil},
|
||||
{Words(``, `(?=[()<>\[\]{}/%\s])`, `abs`, `add`, `aload`, `arc`, `arcn`, `array`, `atan`, `begin`, `bind`, `ceiling`, `charpath`, `clip`, `closepath`, `concat`, `concatmatrix`, `copy`, `cos`, `currentlinewidth`, `currentmatrix`, `currentpoint`, `curveto`, `cvi`, `cvs`, `def`, `defaultmatrix`, `dict`, `dictstackoverflow`, `div`, `dtransform`, `dup`, `end`, `exch`, `exec`, `exit`, `exp`, `fill`, `findfont`, `floor`, `get`, `getinterval`, `grestore`, `gsave`, `gt`, `identmatrix`, `idiv`, `idtransform`, `index`, `invertmatrix`, `itransform`, `length`, `lineto`, `ln`, `load`, `log`, `loop`, `matrix`, `mod`, `moveto`, `mul`, `neg`, `newpath`, `pathforall`, `pathbbox`, `pop`, `print`, `pstack`, `put`, `quit`, `rand`, `rangecheck`, `rcurveto`, `repeat`, `restore`, `rlineto`, `rmoveto`, `roll`, `rotate`, `round`, `run`, `save`, `scale`, `scalefont`, `setdash`, `setfont`, `setgray`, `setlinecap`, `setlinejoin`, `setlinewidth`, `setmatrix`, `setrgbcolor`, `shfill`, `show`, `showpage`, `sin`, `sqrt`, `stack`, `stringwidth`, `stroke`, `strokepath`, `sub`, `syntaxerror`, `transform`, `translate`, `truncate`, `typecheck`, `undefined`, `undefinedfilename`, `undefinedresult`), NameBuiltin, nil},
|
||||
{`\s+`, Text, nil},
|
||||
},
|
||||
"stringliteral": {
|
||||
{`[^()\\]+`, LiteralString, nil},
|
||||
{`\\`, LiteralStringEscape, Push("escape")},
|
||||
{`\(`, LiteralString, Push()},
|
||||
{`\)`, LiteralString, Pop(1)},
|
||||
},
|
||||
"escape": {
|
||||
{`[0-8]{3}|n|r|t|b|f|\\|\(|\)`, LiteralStringEscape, Pop(1)},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
},
|
||||
))
|
35
vendor/github.com/alecthomas/chroma/lexers/p/povray.go
generated
vendored
Normal file
35
vendor/github.com/alecthomas/chroma/lexers/p/povray.go
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
package p
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Povray lexer.
|
||||
var Povray = internal.Register(MustNewLexer(
|
||||
&Config{
|
||||
Name: "POVRay",
|
||||
Aliases: []string{"pov"},
|
||||
Filenames: []string{"*.pov", "*.inc"},
|
||||
MimeTypes: []string{"text/x-povray"},
|
||||
},
|
||||
Rules{
|
||||
"root": {
|
||||
{`/\*[\w\W]*?\*/`, CommentMultiline, nil},
|
||||
{`//.*\n`, CommentSingle, nil},
|
||||
{`(?s)"(?:\\.|[^"\\])+"`, LiteralStringDouble, nil},
|
||||
{Words(`#`, `\b`, `break`, `case`, `debug`, `declare`, `default`, `define`, `else`, `elseif`, `end`, `error`, `fclose`, `fopen`, `for`, `if`, `ifdef`, `ifndef`, `include`, `local`, `macro`, `range`, `read`, `render`, `statistics`, `switch`, `undef`, `version`, `warning`, `while`, `write`), CommentPreproc, nil},
|
||||
{Words(`\b`, `\b`, `aa_level`, `aa_threshold`, `abs`, `acos`, `acosh`, `adaptive`, `adc_bailout`, `agate`, `agate_turb`, `all`, `alpha`, `ambient`, `ambient_light`, `angle`, `aperture`, `arc_angle`, `area_light`, `asc`, `asin`, `asinh`, `assumed_gamma`, `atan`, `atan2`, `atanh`, `atmosphere`, `atmospheric_attenuation`, `attenuating`, `average`, `background`, `black_hole`, `blue`, `blur_samples`, `bounded_by`, `box_mapping`, `bozo`, `break`, `brick`, `brick_size`, `brightness`, `brilliance`, `bumps`, `bumpy1`, `bumpy2`, `bumpy3`, `bump_map`, `bump_size`, `case`, `caustics`, `ceil`, `checker`, `chr`, `clipped_by`, `clock`, `color`, `color_map`, `colour`, `colour_map`, `component`, `composite`, `concat`, `confidence`, `conic_sweep`, `constant`, `control0`, `control1`, `cos`, `cosh`, `count`, `crackle`, `crand`, `cube`, `cubic_spline`, `cylindrical_mapping`, `debug`, `declare`, `default`, `degrees`, `dents`, `diffuse`, `direction`, `distance`, `distance_maximum`, `div`, `dust`, `dust_type`, `eccentricity`, `else`, `emitting`, `end`, `error`, `error_bound`, `exp`, `exponent`, `fade_distance`, `fade_power`, `falloff`, `falloff_angle`, `false`, `file_exists`, `filter`, `finish`, `fisheye`, `flatness`, `flip`, `floor`, `focal_point`, `fog`, `fog_alt`, `fog_offset`, `fog_type`, `frequency`, `gif`, `global_settings`, `glowing`, `gradient`, `granite`, `gray_threshold`, `green`, `halo`, `hexagon`, `hf_gray_16`, `hierarchy`, `hollow`, `hypercomplex`, `if`, `ifdef`, `iff`, `image_map`, `incidence`, `include`, `int`, `interpolate`, `inverse`, `ior`, `irid`, `irid_wavelength`, `jitter`, `lambda`, `leopard`, `linear`, `linear_spline`, `linear_sweep`, `location`, `log`, `looks_like`, `look_at`, `low_error_factor`, `mandel`, `map_type`, `marble`, `material_map`, `matrix`, `max`, `max_intersections`, `max_iteration`, `max_trace_level`, `max_value`, `metallic`, `min`, `minimum_reuse`, `mod`, `mortar`, `nearest_count`, `no`, `normal`, `normal_map`, `no_shadow`, `number_of_waves`, `octaves`, `off`, `offset`, `omega`, `omnimax`, `on`, `once`, `onion`, `open`, `orthographic`, `panoramic`, `pattern1`, `pattern2`, `pattern3`, `perspective`, `pgm`, `phase`, `phong`, `phong_size`, `pi`, `pigment`, `pigment_map`, `planar_mapping`, `png`, `point_at`, `pot`, `pow`, `ppm`, `precision`, `pwr`, `quadratic_spline`, `quaternion`, `quick_color`, `quick_colour`, `quilted`, `radial`, `radians`, `radiosity`, `radius`, `rainbow`, `ramp_wave`, `rand`, `range`, `reciprocal`, `recursion_limit`, `red`, `reflection`, `refraction`, `render`, `repeat`, `rgb`, `rgbf`, `rgbft`, `rgbt`, `right`, `ripples`, `rotate`, `roughness`, `samples`, `scale`, `scallop_wave`, `scattering`, `seed`, `shadowless`, `sin`, `sine_wave`, `sinh`, `sky`, `sky_sphere`, `slice`, `slope_map`, `smooth`, `specular`, `spherical_mapping`, `spiral`, `spiral1`, `spiral2`, `spotlight`, `spotted`, `sqr`, `sqrt`, `statistics`, `str`, `strcmp`, `strength`, `strlen`, `strlwr`, `strupr`, `sturm`, `substr`, `switch`, `sys`, `t`, `tan`, `tanh`, `test_camera_1`, `test_camera_2`, `test_camera_3`, `test_camera_4`, `texture`, `texture_map`, `tga`, `thickness`, `threshold`, `tightness`, `tile2`, `tiles`, `track`, `transform`, `translate`, `transmit`, `triangle_wave`, `true`, `ttf`, `turbulence`, `turb_depth`, `type`, `ultra_wide_angle`, `up`, `use_color`, `use_colour`, `use_index`, `u_steps`, `val`, `variance`, `vaxis_rotate`, `vcross`, `vdot`, `version`, `vlength`, `vnormalize`, `volume_object`, `volume_rendered`, `vol_with_light`, `vrotate`, `v_steps`, `warning`, `warp`, `water_level`, `waves`, `while`, `width`, `wood`, `wrinkles`, `yes`), Keyword, nil},
|
||||
{Words(``, `\b`, `bicubic_patch`, `blob`, `box`, `camera`, `cone`, `cubic`, `cylinder`, `difference`, `disc`, `height_field`, `intersection`, `julia_fractal`, `lathe`, `light_source`, `merge`, `mesh`, `object`, `plane`, `poly`, `polygon`, `prism`, `quadric`, `quartic`, `smooth_triangle`, `sor`, `sphere`, `superellipsoid`, `text`, `torus`, `triangle`, `union`), NameBuiltin, nil},
|
||||
{`[\[\](){}<>;,]`, Punctuation, nil},
|
||||
{`[-+*/=]`, Operator, nil},
|
||||
{`\b(x|y|z|u|v)\b`, NameBuiltinPseudo, nil},
|
||||
{`[a-zA-Z_]\w*`, Name, nil},
|
||||
{`[0-9]+\.[0-9]*`, LiteralNumberFloat, nil},
|
||||
{`\.[0-9]+`, LiteralNumberFloat, nil},
|
||||
{`[0-9]+`, LiteralNumberInteger, nil},
|
||||
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
|
||||
{`\s+`, Text, nil},
|
||||
},
|
||||
},
|
||||
))
|
66
vendor/github.com/alecthomas/chroma/lexers/p/powershell.go
generated
vendored
Normal file
66
vendor/github.com/alecthomas/chroma/lexers/p/powershell.go
generated
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
package p
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Powershell lexer.
|
||||
var Powershell = internal.Register(MustNewLexer(
|
||||
&Config{
|
||||
Name: "PowerShell",
|
||||
Aliases: []string{"powershell", "posh", "ps1", "psm1"},
|
||||
Filenames: []string{"*.ps1", "*.psm1"},
|
||||
MimeTypes: []string{"text/x-powershell"},
|
||||
DotAll: true,
|
||||
CaseInsensitive: true,
|
||||
},
|
||||
Rules{
|
||||
"root": {
|
||||
{`\(`, Punctuation, Push("child")},
|
||||
{`\s+`, Text, nil},
|
||||
{`^(\s*#[#\s]*)(\.(?:component|description|example|externalhelp|forwardhelpcategory|forwardhelptargetname|functionality|inputs|link|notes|outputs|parameter|remotehelprunspace|role|synopsis))([^\n]*$)`, ByGroups(Comment, LiteralStringDoc, Comment), nil},
|
||||
{`#[^\n]*?$`, Comment, nil},
|
||||
{`(<|<)#`, CommentMultiline, Push("multline")},
|
||||
{`(?i)([A-Z]:)`, Name, nil},
|
||||
{`@"\n`, LiteralStringHeredoc, Push("heredoc-double")},
|
||||
{`@'\n.*?\n'@`, LiteralStringHeredoc, nil},
|
||||
{"`[\\'\"$@-]", Punctuation, nil},
|
||||
{`"`, LiteralStringDouble, Push("string")},
|
||||
{`'([^']|'')*'`, LiteralStringSingle, nil},
|
||||
{`(\$|@@|@)((global|script|private|env):)?\w+`, NameVariable, nil},
|
||||
{`(while|validateset|validaterange|validatepattern|validatelength|validatecount|until|trap|switch|return|ref|process|param|parameter|in|if|global:|function|foreach|for|finally|filter|end|elseif|else|dynamicparam|do|default|continue|cmdletbinding|break|begin|alias|\?|%|#script|#private|#local|#global|mandatory|parametersetname|position|valuefrompipeline|valuefrompipelinebypropertyname|valuefromremainingarguments|helpmessage|try|catch|throw)\b`, Keyword, nil},
|
||||
{`-(and|as|band|bnot|bor|bxor|casesensitive|ccontains|ceq|cge|cgt|cle|clike|clt|cmatch|cne|cnotcontains|cnotlike|cnotmatch|contains|creplace|eq|exact|f|file|ge|gt|icontains|ieq|ige|igt|ile|ilike|ilt|imatch|ine|inotcontains|inotlike|inotmatch|ireplace|is|isnot|le|like|lt|match|ne|not|notcontains|notlike|notmatch|or|regex|replace|wildcard)\b`, Operator, nil},
|
||||
{`(write|where|watch|wait|use|update|unregister|unpublish|unprotect|unlock|uninstall|undo|unblock|trace|test|tee|take|sync|switch|suspend|submit|stop|step|start|split|sort|skip|show|set|send|select|search|scroll|save|revoke|resume|restore|restart|resolve|resize|reset|request|repair|rename|remove|register|redo|receive|read|push|publish|protect|pop|ping|out|optimize|open|new|move|mount|merge|measure|lock|limit|join|invoke|install|initialize|import|hide|group|grant|get|format|foreach|find|export|expand|exit|enter|enable|edit|dismount|disconnect|disable|deny|debug|cxnew|copy|convertto|convertfrom|convert|connect|confirm|compress|complete|compare|close|clear|checkpoint|block|backup|assert|approve|aggregate|add)-[a-z_]\w*\b`, NameBuiltin, nil},
|
||||
{`(ac|asnp|cat|cd|cfs|chdir|clc|clear|clhy|cli|clp|cls|clv|cnsn|compare|copy|cp|cpi|cpp|curl|cvpa|dbp|del|diff|dir|dnsn|ebp|echo|epal|epcsv|epsn|erase|etsn|exsn|fc|fhx|fl|foreach|ft|fw|gal|gbp|gc|gci|gcm|gcs|gdr|ghy|gi|gjb|gl|gm|gmo|gp|gps|gpv|group|gsn|gsnp|gsv|gu|gv|gwmi|h|history|icm|iex|ihy|ii|ipal|ipcsv|ipmo|ipsn|irm|ise|iwmi|iwr|kill|lp|ls|man|md|measure|mi|mount|move|mp|mv|nal|ndr|ni|nmo|npssc|nsn|nv|ogv|oh|popd|ps|pushd|pwd|r|rbp|rcjb|rcsn|rd|rdr|ren|ri|rjb|rm|rmdir|rmo|rni|rnp|rp|rsn|rsnp|rujb|rv|rvpa|rwmi|sajb|sal|saps|sasv|sbp|sc|select|set|shcm|si|sl|sleep|sls|sort|sp|spjb|spps|spsv|start|sujb|sv|swmi|tee|trcm|type|wget|where|wjb|write)\s`, NameBuiltin, nil},
|
||||
{"\\[[a-z_\\[][\\w. `,\\[\\]]*\\]", NameConstant, nil},
|
||||
{`-[a-z_]\w*`, Name, nil},
|
||||
{`\w+`, Name, nil},
|
||||
{"[.,;@{}\\[\\]$()=+*/\\\\&%!~?^`|<>-]|::", Punctuation, nil},
|
||||
},
|
||||
"child": {
|
||||
{`\)`, Punctuation, Pop(1)},
|
||||
Include("root"),
|
||||
},
|
||||
"multline": {
|
||||
{`[^#&.]+`, CommentMultiline, nil},
|
||||
{`#(>|>)`, CommentMultiline, Pop(1)},
|
||||
{`\.(component|description|example|externalhelp|forwardhelpcategory|forwardhelptargetname|functionality|inputs|link|notes|outputs|parameter|remotehelprunspace|role|synopsis)`, LiteralStringDoc, nil},
|
||||
{`[#&.]`, CommentMultiline, nil},
|
||||
},
|
||||
"string": {
|
||||
{"`[0abfnrtv'\\\"$`]", LiteralStringEscape, nil},
|
||||
{"[^$`\"]+", LiteralStringDouble, nil},
|
||||
{`\$\(`, Punctuation, Push("child")},
|
||||
{`""`, LiteralStringDouble, nil},
|
||||
{"[`$]", LiteralStringDouble, nil},
|
||||
{`"`, LiteralStringDouble, Pop(1)},
|
||||
},
|
||||
"heredoc-double": {
|
||||
{`\n"@`, LiteralStringHeredoc, Pop(1)},
|
||||
{`\$\(`, Punctuation, Push("child")},
|
||||
{`[^@\n]+"]`, LiteralStringHeredoc, nil},
|
||||
{`.`, LiteralStringHeredoc, nil},
|
||||
},
|
||||
},
|
||||
))
|
50
vendor/github.com/alecthomas/chroma/lexers/p/prolog.go
generated
vendored
Normal file
50
vendor/github.com/alecthomas/chroma/lexers/p/prolog.go
generated
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
package p
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Prolog lexer.
|
||||
var Prolog = internal.Register(MustNewLexer(
|
||||
&Config{
|
||||
Name: "Prolog",
|
||||
Aliases: []string{"prolog"},
|
||||
Filenames: []string{"*.ecl", "*.prolog", "*.pro", "*.pl"},
|
||||
MimeTypes: []string{"text/x-prolog"},
|
||||
},
|
||||
Rules{
|
||||
"root": {
|
||||
{`/\*`, CommentMultiline, Push("nested-comment")},
|
||||
{`%.*`, CommentSingle, nil},
|
||||
{`0\'.`, LiteralStringChar, nil},
|
||||
{`0b[01]+`, LiteralNumberBin, nil},
|
||||
{`0o[0-7]+`, LiteralNumberOct, nil},
|
||||
{`0x[0-9a-fA-F]+`, LiteralNumberHex, nil},
|
||||
{`\d\d?\'[a-zA-Z0-9]+`, LiteralNumberInteger, nil},
|
||||
{`(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?`, LiteralNumberFloat, nil},
|
||||
{`\d+`, LiteralNumberInteger, nil},
|
||||
{`[\[\](){}|.,;!]`, Punctuation, nil},
|
||||
{`:-|-->`, Punctuation, nil},
|
||||
{`"(?:\\x[0-9a-fA-F]+\\|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|\\[0-7]+\\|\\["\nabcefnrstv]|[^\\"])*"`, LiteralStringDouble, nil},
|
||||
{`'(?:''|[^'])*'`, LiteralStringAtom, nil},
|
||||
{`is\b`, Operator, nil},
|
||||
{`(<|>|=<|>=|==|=:=|=|/|//|\*|\+|-)(?=\s|[a-zA-Z0-9\[])`, Operator, nil},
|
||||
{`(mod|div|not)\b`, Operator, nil},
|
||||
{`_`, Keyword, nil},
|
||||
{`([a-z]+)(:)`, ByGroups(NameNamespace, Punctuation), nil},
|
||||
{`([a-zÀ---][\w$À---]*)(\s*)(:-|-->)`, ByGroups(NameFunction, Text, Operator), nil},
|
||||
{`([a-zÀ---][\w$À---]*)(\s*)(\()`, ByGroups(NameFunction, Text, Punctuation), nil},
|
||||
{`[a-zÀ---][\w$À---]*`, LiteralStringAtom, nil},
|
||||
{`[#&*+\-./:<=>?@\\^~¡-¿‐-〿]+`, LiteralStringAtom, nil},
|
||||
{`[A-Z_]\w*`, NameVariable, nil},
|
||||
{`\s+|[ --]`, Text, nil},
|
||||
},
|
||||
"nested-comment": {
|
||||
{`\*/`, CommentMultiline, Pop(1)},
|
||||
{`/\*`, CommentMultiline, Push()},
|
||||
{`[^*/]+`, CommentMultiline, nil},
|
||||
{`[*/]`, CommentMultiline, nil},
|
||||
},
|
||||
},
|
||||
))
|
53
vendor/github.com/alecthomas/chroma/lexers/p/protobuf.go
generated
vendored
Normal file
53
vendor/github.com/alecthomas/chroma/lexers/p/protobuf.go
generated
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
package p
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// ProtocolBuffer lexer.
|
||||
var ProtocolBuffer = internal.Register(MustNewLexer(
|
||||
&Config{
|
||||
Name: "Protocol Buffer",
|
||||
Aliases: []string{"protobuf", "proto"},
|
||||
Filenames: []string{"*.proto"},
|
||||
MimeTypes: []string{},
|
||||
},
|
||||
Rules{
|
||||
"root": {
|
||||
{`[ \t]+`, Text, nil},
|
||||
{`[,;{}\[\]()<>]`, Punctuation, nil},
|
||||
{`/(\\\n)?/(\n|(.|\n)*?[^\\]\n)`, CommentSingle, nil},
|
||||
{`/(\\\n)?\*(.|\n)*?\*(\\\n)?/`, CommentMultiline, nil},
|
||||
{Words(`\b`, `\b`, `import`, `option`, `optional`, `required`, `repeated`, `default`, `packed`, `ctype`, `extensions`, `to`, `max`, `rpc`, `returns`, `oneof`), Keyword, nil},
|
||||
{Words(``, `\b`, `int32`, `int64`, `uint32`, `uint64`, `sint32`, `sint64`, `fixed32`, `fixed64`, `sfixed32`, `sfixed64`, `float`, `double`, `bool`, `string`, `bytes`), KeywordType, nil},
|
||||
{`(true|false)\b`, KeywordConstant, nil},
|
||||
{`(package)(\s+)`, ByGroups(KeywordNamespace, Text), Push("package")},
|
||||
{`(message|extend)(\s+)`, ByGroups(KeywordDeclaration, Text), Push("message")},
|
||||
{`(enum|group|service)(\s+)`, ByGroups(KeywordDeclaration, Text), Push("type")},
|
||||
{`\".*?\"`, LiteralString, nil},
|
||||
{`\'.*?\'`, LiteralString, nil},
|
||||
{`(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*`, LiteralNumberFloat, nil},
|
||||
{`(\d+\.\d*|\.\d+|\d+[fF])[fF]?`, LiteralNumberFloat, nil},
|
||||
{`(\-?(inf|nan))\b`, LiteralNumberFloat, nil},
|
||||
{`0x[0-9a-fA-F]+[LlUu]*`, LiteralNumberHex, nil},
|
||||
{`0[0-7]+[LlUu]*`, LiteralNumberOct, nil},
|
||||
{`\d+[LlUu]*`, LiteralNumberInteger, nil},
|
||||
{`[+-=]`, Operator, nil},
|
||||
{`([a-zA-Z_][\w.]*)([ \t]*)(=)`, ByGroups(Name, Text, Operator), nil},
|
||||
{`[a-zA-Z_][\w.]*`, Name, nil},
|
||||
},
|
||||
"package": {
|
||||
{`[a-zA-Z_]\w*`, NameNamespace, Pop(1)},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"message": {
|
||||
{`[a-zA-Z_]\w*`, NameClass, Pop(1)},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
"type": {
|
||||
{`[a-zA-Z_]\w*`, Name, Pop(1)},
|
||||
Default(Pop(1)),
|
||||
},
|
||||
},
|
||||
))
|
56
vendor/github.com/alecthomas/chroma/lexers/p/puppet.go
generated
vendored
Normal file
56
vendor/github.com/alecthomas/chroma/lexers/p/puppet.go
generated
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
package p
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Puppet lexer.
|
||||
var Puppet = internal.Register(MustNewLexer(
|
||||
&Config{
|
||||
Name: "Puppet",
|
||||
Aliases: []string{"puppet"},
|
||||
Filenames: []string{"*.pp"},
|
||||
MimeTypes: []string{},
|
||||
},
|
||||
Rules{
|
||||
"root": {
|
||||
Include("comments"),
|
||||
Include("keywords"),
|
||||
Include("names"),
|
||||
Include("numbers"),
|
||||
Include("operators"),
|
||||
Include("strings"),
|
||||
{`[]{}:(),;[]`, Punctuation, nil},
|
||||
{`[^\S\n]+`, Text, nil},
|
||||
},
|
||||
"comments": {
|
||||
{`\s*#.*$`, Comment, nil},
|
||||
{`/(\\\n)?[*](.|\n)*?[*](\\\n)?/`, CommentMultiline, nil},
|
||||
},
|
||||
"operators": {
|
||||
{`(=>|\?|<|>|=|\+|-|/|\*|~|!|\|)`, Operator, nil},
|
||||
{`(in|and|or|not)\b`, OperatorWord, nil},
|
||||
},
|
||||
"names": {
|
||||
{`[a-zA-Z_]\w*`, NameAttribute, nil},
|
||||
{`(\$\S+)(\[)(\S+)(\])`, ByGroups(NameVariable, Punctuation, LiteralString, Punctuation), nil},
|
||||
{`\$\S+`, NameVariable, 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[xX][a-fA-F0-9]+`, LiteralNumberHex, nil},
|
||||
{`\d+L`, LiteralNumberIntegerLong, nil},
|
||||
{`\d+j?`, LiteralNumberInteger, nil},
|
||||
},
|
||||
"keywords": {
|
||||
{Words(`(?i)`, `\b`, `absent`, `alert`, `alias`, `audit`, `augeas`, `before`, `case`, `check`, `class`, `computer`, `configured`, `contained`, `create_resources`, `crit`, `cron`, `debug`, `default`, `define`, `defined`, `directory`, `else`, `elsif`, `emerg`, `err`, `exec`, `extlookup`, `fail`, `false`, `file`, `filebucket`, `fqdn_rand`, `generate`, `host`, `if`, `import`, `include`, `info`, `inherits`, `inline_template`, `installed`, `interface`, `k5login`, `latest`, `link`, `loglevel`, `macauthorization`, `mailalias`, `maillist`, `mcx`, `md5`, `mount`, `mounted`, `nagios_command`, `nagios_contact`, `nagios_contactgroup`, `nagios_host`, `nagios_hostdependency`, `nagios_hostescalation`, `nagios_hostextinfo`, `nagios_hostgroup`, `nagios_service`, `nagios_servicedependency`, `nagios_serviceescalation`, `nagios_serviceextinfo`, `nagios_servicegroup`, `nagios_timeperiod`, `node`, `noop`, `notice`, `notify`, `package`, `present`, `purged`, `realize`, `regsubst`, `resources`, `role`, `router`, `running`, `schedule`, `scheduled_task`, `search`, `selboolean`, `selmodule`, `service`, `sha1`, `shellquote`, `split`, `sprintf`, `ssh_authorized_key`, `sshkey`, `stage`, `stopped`, `subscribe`, `tag`, `tagged`, `template`, `tidy`, `true`, `undef`, `unmounted`, `user`, `versioncmp`, `vlan`, `warning`, `yumrepo`, `zfs`, `zone`, `zpool`), Keyword, nil},
|
||||
},
|
||||
"strings": {
|
||||
{`"([^"])*"`, LiteralString, nil},
|
||||
{`'(\\'|[^'])*'`, LiteralString, nil},
|
||||
},
|
||||
},
|
||||
))
|
137
vendor/github.com/alecthomas/chroma/lexers/p/python.go
generated
vendored
Normal file
137
vendor/github.com/alecthomas/chroma/lexers/p/python.go
generated
vendored
Normal file
|
@ -0,0 +1,137 @@
|
|||
package p
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Python lexer.
|
||||
var Python = internal.Register(MustNewLexer(
|
||||
&Config{
|
||||
Name: "Python",
|
||||
Aliases: []string{"python", "py", "sage"},
|
||||
Filenames: []string{"*.py", "*.pyw", "*.sc", "SConstruct", "SConscript", "*.tac", "*.sage"},
|
||||
MimeTypes: []string{"text/x-python", "application/x-python"},
|
||||
},
|
||||
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`, `NotImplemented`, `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},
|
||||
},
|
||||
},
|
||||
))
|
137
vendor/github.com/alecthomas/chroma/lexers/p/python3.go
generated
vendored
Normal file
137
vendor/github.com/alecthomas/chroma/lexers/p/python3.go
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue