Skip to content

Commit

Permalink
[spaqrl mode] Fix parsing of veriables after operators
Browse files Browse the repository at this point in the history
Question-mark characters should only be styled as operators within triple patterns. For example the command

SELECT * WHERE { BIND(?A+?B AS ?C) }

should not have the "+?" sequence styled as "operator".  NB the problem does not occur if there is a space between these two characters.
With the fix "?A" and "?B" will both be styled as variable-2 (and "+" as operator).

By processing operators characters (mostly) one at a time,  the existing code on line 40 to zealously interpret anything beginning with '?' as a variable can run in this case. 

NB Line 40 actually causes a false positive in the case where the '?' appears in a triple pattern as a property path operator: this fix does not address this existing bug: it is quite complicated as '?' can appear in both variables and property paths while the parser is in the "pattern" state.
  • Loading branch information
MarkBoyes committed May 6, 2022
1 parent 6597cc2 commit c955a0f
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions mode/sparql/sparql.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,7 @@ CodeMirror.defineMode("sparql", function(config) {
stream.skipToEnd();
return "comment";
}
else if (ch === "^") {
ch = stream.peek();
if (ch === "^") stream.eat("^");
else stream.eatWhile(operatorChars);
return "operator";
}
else if (operatorChars.test(ch)) {
stream.eatWhile(operatorChars);
return "operator";
}
else if (ch == ":") {
Expand Down

0 comments on commit c955a0f

Please sign in to comment.