forked from NYANDEV/forgejo
86e2789960
* update github.com/PuerkitoBio/goquery * update github.com/alecthomas/chroma * update github.com/blevesearch/bleve/v2 * update github.com/caddyserver/certmagic * update github.com/go-enry/go-enry/v2 * update github.com/go-git/go-billy/v5 * update github.com/go-git/go-git/v5 * update github.com/go-redis/redis/v8 * update github.com/go-testfixtures/testfixtures/v3 * update github.com/jaytaylor/html2text * update github.com/json-iterator/go * update github.com/klauspost/compress * update github.com/markbates/goth * update github.com/mattn/go-isatty * update github.com/mholt/archiver/v3 * update github.com/microcosm-cc/bluemonday * update github.com/minio/minio-go/v7 * update github.com/prometheus/client_golang * update github.com/unrolled/render * update github.com/xanzy/go-gitlab * update github.com/yuin/goldmark * update github.com/yuin/goldmark-highlighting Co-authored-by: techknowlogick <techknowlogick@gitea.io>
58 lines
3.6 KiB
Go
Vendored
58 lines
3.6 KiB
Go
Vendored
package m
|
|
|
|
import (
|
|
. "github.com/alecthomas/chroma" // nolint
|
|
"github.com/alecthomas/chroma/lexers/internal"
|
|
)
|
|
|
|
// MySQL lexer.
|
|
var MySQL = internal.Register(MustNewLazyLexer(
|
|
&Config{
|
|
Name: "MySQL",
|
|
Aliases: []string{"mysql"},
|
|
Filenames: []string{"*.sql"},
|
|
MimeTypes: []string{"text/x-mysql"},
|
|
NotMultiline: true,
|
|
CaseInsensitive: true,
|
|
},
|
|
mySQLRules,
|
|
))
|
|
|
|
func mySQLRules() Rules {
|
|
return Rules{
|
|
"root": {
|
|
{`\s+`, TextWhitespace, nil},
|
|
{`(#|--\s+).*\n?`, CommentSingle, nil},
|
|
{`/\*`, CommentMultiline, Push("multiline-comments")},
|
|
{`[0-9]+`, LiteralNumberInteger, nil},
|
|
{`[0-9]*\.[0-9]+(e[+-][0-9]+)`, LiteralNumberFloat, nil},
|
|
{`((?:_[a-z0-9]+)?)(')`, ByGroups(LiteralStringAffix, LiteralStringSingle), Push("string")},
|
|
{`((?:_[a-z0-9]+)?)(")`, ByGroups(LiteralStringAffix, LiteralStringDouble), Push("double-string")},
|
|
{"[+*/<>=~!@#%^&|`?-]", Operator, nil},
|
|
{`\b(tinyint|smallint|mediumint|int|integer|bigint|date|datetime|time|bit|bool|tinytext|mediumtext|longtext|text|tinyblob|mediumblob|longblob|blob|float|double|double\s+precision|real|numeric|dec|decimal|timestamp|year|char|varchar|varbinary|varcharacter|enum|set)(\b\s*)(\()?`, ByGroups(KeywordType, TextWhitespace, Punctuation), nil},
|
|
{`\b(add|all|alter|analyze|and|as|asc|asensitive|before|between|bigint|binary|blob|both|by|call|cascade|case|change|char|character|check|collate|column|condition|constraint|continue|convert|create|cross|current_date|current_time|current_timestamp|current_user|cursor|database|databases|day_hour|day_microsecond|day_minute|day_second|dec|decimal|declare|default|delayed|delete|desc|describe|deterministic|distinct|distinctrow|div|double|drop|dual|each|else|elseif|enclosed|escaped|exists|exit|explain|fetch|flush|float|float4|float8|for|force|foreign|from|fulltext|grant|group|having|high_priority|hour_microsecond|hour_minute|hour_second|identified|if|ignore|in|index|infile|inner|inout|insensitive|insert|int|int1|int2|int3|int4|int8|integer|interval|into|is|iterate|join|key|keys|kill|leading|leave|left|like|limit|lines|load|localtime|localtimestamp|lock|long|loop|low_priority|match|minute_microsecond|minute_second|mod|modifies|natural|no_write_to_binlog|not|numeric|on|optimize|option|optionally|or|order|out|outer|outfile|precision|primary|privileges|procedure|purge|raid0|read|reads|real|references|regexp|release|rename|repeat|replace|require|restrict|return|revoke|right|rlike|schema|schemas|second_microsecond|select|sensitive|separator|set|show|smallint|soname|spatial|specific|sql|sql_big_result|sql_calc_found_rows|sql_small_result|sqlexception|sqlstate|sqlwarning|ssl|starting|straight_join|table|terminated|then|to|trailing|trigger|undo|union|unique|unlock|unsigned|update|usage|use|user|using|utc_date|utc_time|utc_timestamp|values|varying|when|where|while|with|write|x509|xor|year_month|zerofill)\b`, Keyword, nil},
|
|
{`\b(auto_increment|engine|charset|tables)\b`, KeywordPseudo, nil},
|
|
{`(true|false|null)`, NameConstant, nil},
|
|
{`([a-z_]\w*)(\s*)(\()`, ByGroups(NameFunction, TextWhitespace, Punctuation), nil},
|
|
{`[a-z_]\w*`, Name, nil},
|
|
{`@[a-z0-9]*[._]*[a-z0-9]*`, 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)},
|
|
},
|
|
"double-string": {
|
|
{`[^"]+`, LiteralStringDouble, nil},
|
|
{`""`, LiteralStringDouble, nil},
|
|
{`"`, LiteralStringDouble, Pop(1)},
|
|
},
|
|
}
|
|
}
|