Skip to content

Commit 096a20a

Browse files
bollwyvlmarijnh
authored andcommitted
[sparql mode] Property paths
1 parent fc25da4 commit 096a20a

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

mode/sparql/index.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,23 @@ <h2>SPARQL mode</h2>
2929
PREFIX a: &lt;http://www.w3.org/2000/10/annotation-ns#>
3030
PREFIX dc: &lt;http://purl.org/dc/elements/1.1/>
3131
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/>
32+
PREFIX rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#>
3233

3334
# Comment!
3435

3536
SELECT ?given ?family
3637
WHERE {
37-
?annot a:annotates &lt;http://www.w3.org/TR/rdf-sparql-query/> .
38-
?annot dc:creator ?c .
39-
OPTIONAL {?c foaf:given ?given ;
40-
foaf:family ?family } .
38+
{
39+
?annot a:annotates &lt;http://www.w3.org/TR/rdf-sparql-query/> .
40+
?annot dc:creator ?c .
41+
OPTIONAL {?c foaf:givenName ?given ;
42+
foaf:familyName ?family }
43+
} UNION {
44+
?c !foaf:knows/foaf:knows? ?thing.
45+
?thing rdfs
46+
} MINUS {
47+
?thing rdfs:label "剛柔流"@jp
48+
}
4149
FILTER isBlank(?c)
4250
}
4351
</textarea></form>

mode/sparql/sparql.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ CodeMirror.defineMode("sparql", function(config) {
3232
"minus", "in", "not", "service", "silent", "using", "insert", "delete", "union",
3333
"true", "false", "with",
3434
"data", "copy", "to", "move", "add", "create", "drop", "clear", "load"]);
35-
var operatorChars = /[*+\-<>=&|]/;
35+
var operatorChars = /[*+\-<>=&|\^\/!\?]/;
3636

3737
function tokenBase(stream, state) {
3838
var ch = stream.next();
3939
curPunc = null;
4040
if (ch == "$" || ch == "?") {
41+
if(ch == "?" && stream.match(/\s/, false)){
42+
return "operator";
43+
}
4144
stream.match(/^[\w\d]*/);
4245
return "variable-2";
4346
}
@@ -69,10 +72,6 @@ CodeMirror.defineMode("sparql", function(config) {
6972
stream.eatWhile(/[a-z\d\-]/i);
7073
return "meta";
7174
}
72-
else if (ch == "^") {
73-
stream.eatWhile(/\^/);
74-
return "meta";
75-
}
7675
else {
7776
stream.eatWhile(/[_\w\d]/);
7877
if (stream.eat(":")) {

0 commit comments

Comments
 (0)