mirror of
https://github.com/cheat/cheat.git
synced 2024-11-01 13:41:01 +01:00
55b18b4897
commit 95479c8ad744db48386a5c78e54ef8da80e9120b Author: Chris Lane <chris@chris-allen-lane.com> Date: Wed Apr 28 12:26:32 2021 -0400 chore(version): bump version to 4.2.1 commit6956f51cae
Author: Chris Lane <chris@chris-allen-lane.com> Date: Wed Apr 28 12:24:21 2021 -0400 fix(Makefile): `vendor-update` Update the `vendor-update` build target to run `go mod vendor` after updating dependencies. commit0aca411279
Author: Chris Lane <chris@chris-allen-lane.com> Date: Wed Apr 28 12:23:24 2021 -0400 chore(deps): update dependencies commite847956b02
Author: Chris Lane <chris@chris-allen-lane.com> Date: Wed Apr 28 08:26:51 2021 -0400 chore(deps): build updates - Upgrade `go` to `1.16.3` - Attempt to fix build errors regarding dependencies
74 lines
4.2 KiB
Go
74 lines
4.2 KiB
Go
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)),
|
||
},
|
||
}
|
||
}
|