gitea/vendor/github.com/alecthomas/chroma/lexers/s/sparql.go
6543 86e2789960
Vendor Update (#16121)
* 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>
2021-06-10 16:44:25 +02:00

74 lines
4.2 KiB
Go
Vendored
Raw Blame History

package s
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
// Sparql lexer.
var Sparql = internal.Register(MustNewLazyLexer(
&Config{
Name: "SPARQL",
Aliases: []string{"sparql"},
Filenames: []string{"*.rq", "*.sparql"},
MimeTypes: []string{"application/sparql-query"},
},
sparqlRules,
))
func sparqlRules() Rules {
return Rules{
"root": {
{`\s+`, Text, nil},
{`((?i)select|construct|describe|ask|where|filter|group\s+by|minus|distinct|reduced|from\s+named|from|order\s+by|desc|asc|limit|offset|bindings|load|clear|drop|create|add|move|copy|insert\s+data|delete\s+data|delete\s+where|delete|insert|using\s+named|using|graph|default|named|all|optional|service|silent|bind|union|not\s+in|in|as|having|to|prefix|base)\b`, Keyword, nil},
{`(a)\b`, Keyword, nil},
{"(<(?:[^<>\"{}|^`\\\\\\x00-\\x20])*>)", NameLabel, nil},
{`(_:[0-9a-zA-ZÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-<2D>_](?:[a-zA-ZÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-<2D>_\-0-9·̀-ͯ‿-⁀.]*[a-zA-ZÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-<2D>_\-0-9·̀-ͯ‿-⁀])?)`, NameLabel, nil},
{`[?$][0-9a-zA-ZÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-<2D>_][a-zA-ZÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-<2D>_0-9·̀-ͯ‿-⁀]*`, NameVariable, nil},
{`([a-zA-ZÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-<2D>](?:[a-zA-ZÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-<2D>_\-0-9·̀-ͯ‿-⁀.]*[a-zA-ZÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-<2D>_\-0-9·̀-ͯ‿-⁀])?)?(\:)((?:[a-zA-ZÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-<2D>_:0-9]|(?:%[0-9A-Fa-f][0-9A-Fa-f])|(?:\\[ _~.\-!$&"()*+,;=/?#@%]))(?:(?:[a-zA-ZÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-<2D>_\-0-9·̀-ͯ‿-⁀.:]|(?:%[0-9A-Fa-f][0-9A-Fa-f])|(?:\\[ _~.\-!$&"()*+,;=/?#@%]))*(?:[a-zA-ZÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-<2D>_\-0-9·̀-ͯ‿-⁀:]|(?:%[0-9A-Fa-f][0-9A-Fa-f])|(?:\\[ _~.\-!$&"()*+,;=/?#@%])))?)?`, ByGroups(NameNamespace, Punctuation, NameTag), nil},
{`((?i)str|lang|langmatches|datatype|bound|iri|uri|bnode|rand|abs|ceil|floor|round|concat|strlen|ucase|lcase|encode_for_uri|contains|strstarts|strends|strbefore|strafter|year|month|day|hours|minutes|seconds|timezone|tz|now|md5|sha1|sha256|sha384|sha512|coalesce|if|strlang|strdt|sameterm|isiri|isuri|isblank|isliteral|isnumeric|regex|substr|replace|exists|not\s+exists|count|sum|min|max|avg|sample|group_concat|separator)\b`, NameFunction, nil},
{`(true|false)`, KeywordConstant, nil},
{`[+\-]?(\d+\.\d*[eE][+-]?\d+|\.?\d+[eE][+-]?\d+)`, LiteralNumberFloat, nil},
{`[+\-]?(\d+\.\d*|\.\d+)`, LiteralNumberFloat, nil},
{`[+\-]?\d+`, LiteralNumberInteger, nil},
{`(\|\||&&|=|\*|\-|\+|/|!=|<=|>=|!|<|>)`, Operator, nil},
{`[(){}.;,:^\[\]]`, Punctuation, nil},
{`#[^\n]*`, Comment, nil},
{`"""`, LiteralString, Push("triple-double-quoted-string")},
{`"`, LiteralString, Push("single-double-quoted-string")},
{`'''`, LiteralString, Push("triple-single-quoted-string")},
{`'`, LiteralString, Push("single-single-quoted-string")},
},
"triple-double-quoted-string": {
{`"""`, LiteralString, Push("end-of-string")},
{`[^\\]+`, LiteralString, nil},
{`\\`, LiteralString, Push("string-escape")},
},
"single-double-quoted-string": {
{`"`, LiteralString, Push("end-of-string")},
{`[^"\\\n]+`, LiteralString, nil},
{`\\`, LiteralString, Push("string-escape")},
},
"triple-single-quoted-string": {
{`'''`, LiteralString, Push("end-of-string")},
{`[^\\]+`, LiteralString, nil},
{`\\`, LiteralStringEscape, Push("string-escape")},
},
"single-single-quoted-string": {
{`'`, LiteralString, Push("end-of-string")},
{`[^'\\\n]+`, LiteralString, nil},
{`\\`, LiteralString, Push("string-escape")},
},
"string-escape": {
{`u[0-9A-Fa-f]{4}`, LiteralStringEscape, Pop(1)},
{`U[0-9A-Fa-f]{8}`, LiteralStringEscape, Pop(1)},
{`.`, LiteralStringEscape, Pop(1)},
},
"end-of-string": {
{`(@)([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)`, ByGroups(Operator, NameFunction), Pop(2)},
{`\^\^`, Operator, Pop(2)},
Default(Pop(2)),
},
}
}