Skip to content

Commit d5f8600

Browse files
Add missing tokens to SPARQL lexer (#1559)
@belett noticed that VALUES was missing [1]; I found the other ones by running the following snippet on the SPARQL 1.1 Query Language spec: new Set(Array.from(document.querySelectorAll('.grammarTable')) .reduce((text, elem) => text + elem.textContent) .match(/'[a-z0-9-_ ]*'/ig)) I don’t know why a few keywords were missing; the docstring linked to the SPARQL 1.0 Query Language spec (also fixed here), but the lexer already contained other tokens which were only added in SPARQL 1.1, such as the aggregate functions (MIN, MAX etc.), which have already been in Pygments since the initial commit of the current history (6ded9db). [1]: https://phabricator.wikimedia.org/T264175
1 parent a886f74 commit d5f8600

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

pygments/lexers/rdf.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
class SparqlLexer(RegexLexer):
2222
"""
23-
Lexer for `SPARQL <http://www.w3.org/TR/rdf-sparql-query/>`_ query language.
23+
Lexer for `SPARQL <https://www.w3.org/TR/sparql11-query/>`_ query language.
2424
2525
.. versionadded:: 2.0
2626
"""
@@ -99,10 +99,10 @@ class SparqlLexer(RegexLexer):
9999
# keywords ::
100100
(r'(?i)(select|construct|describe|ask|where|filter|group\s+by|minus|'
101101
r'distinct|reduced|from\s+named|from|order\s+by|desc|asc|limit|'
102-
r'offset|bindings|load|clear|drop|create|add|move|copy|'
103-
r'insert\s+data|delete\s+data|delete\s+where|delete|insert|'
102+
r'offset|values|bindings|load|into|clear|drop|create|add|move|copy|'
103+
r'insert\s+data|delete\s+data|delete\s+where|with|delete|insert|'
104104
r'using\s+named|using|graph|default|named|all|optional|service|'
105-
r'silent|bind|union|not\s+in|in|as|having|to|prefix|base)\b', Keyword),
105+
r'silent|bind|undef|union|not\s+in|in|as|having|to|prefix|base)\b', Keyword),
106106
(r'(a)\b', Keyword),
107107
# IRIs ::
108108
('(' + IRIREF + ')', Name.Label),
@@ -117,7 +117,7 @@ class SparqlLexer(RegexLexer):
117117
(r'(?i)(str|lang|langmatches|datatype|bound|iri|uri|bnode|rand|abs|'
118118
r'ceil|floor|round|concat|strlen|ucase|lcase|encode_for_uri|'
119119
r'contains|strstarts|strends|strbefore|strafter|year|month|day|'
120-
r'hours|minutes|seconds|timezone|tz|now|md5|sha1|sha256|sha384|'
120+
r'hours|minutes|seconds|timezone|tz|now|uuid|struuid|md5|sha1|sha256|sha384|'
121121
r'sha512|coalesce|if|strlang|strdt|sameterm|isiri|isuri|isblank|'
122122
r'isliteral|isnumeric|regex|substr|replace|exists|not\s+exists|'
123123
r'count|sum|min|max|avg|sample|group_concat|separator)\b',

0 commit comments

Comments
 (0)