Skip to content

Commit

Permalink
[sparql mode] Identify all characters in prefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkBoyes committed Oct 6, 2022
1 parent e5071eb commit e1fe210
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions mode/sparql/sparql.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ CodeMirror.defineMode("sparql", function(config) {
"true", "false", "with",
"data", "copy", "to", "move", "add", "create", "drop", "clear", "load", "into"]);
var operatorChars = /[*+\-<>=&|\^\/!\?]/;
var PN_CHARS = "[A-Za-z_\\-0-9]";
var PREFIX_START = new RegExp("[A-Za-z]");
var PREFIX_REMAINDER = new RegExp("((" + PN_CHARS + "|\\.)*(" + PN_CHARS + "))?:");

function tokenBase(stream, state) {
var ch = stream.next();
Expand Down Expand Up @@ -71,20 +74,18 @@ CodeMirror.defineMode("sparql", function(config) {
stream.eatWhile(/[a-z\d\-]/i);
return "meta";
}
else {
stream.eatWhile(/[_\w\d]/);
if (stream.eat(":")) {
else if (PREFIX_START.test(ch) && stream.match(PREFIX_REMAINDER)) {
eatPnLocal(stream);
return "atom";
}
var word = stream.current();
if (ops.test(word))
return "builtin";
else if (keywords.test(word))
return "keyword";
else
return "variable";
}
stream.eatWhile(/[_\w\d]/);
var word = stream.current();
if (ops.test(word))
return "builtin";
else if (keywords.test(word))
return "keyword";
else
return "variable";
}

function eatPnLocal(stream) {
Expand Down

0 comments on commit e1fe210

Please sign in to comment.