Minor improvements in the XQuery syntax highlighter.

This commit is contained in:
William Candillon 2012-02-13 10:04:06 +01:00
commit 240f68cd9a
8 changed files with 44 additions and 38 deletions

View file

@ -25,9 +25,11 @@ var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightR
var XQueryHighlightRules = function() {
var keywords = lang.arrayToMap(
("return|for|let|where|order|by|declare|function|variable|xquery|version|option|namespace|import|module|" +
("return|for|let|where|order|by|declare|function|variable|xquery|version|option|namespace|import|module|when|" +
"switch|default|try|catch|group|tumbling|sliding|window|start|end|at|only|" +
"if|then|else|as|and|or|typeswitch|case|ascending|descending|empty|in|count|updating|insert|delete|replace|value|node|attribute|text|element|into|of|with").split("|")
"using|stemming|" +
"while|" +
"if|then|else|as|and|or|typeswitch|case|ascending|descending|empty|in|count|updating|insert|delete|replace|value|node|attribute|text|element|into|of|with|contains").split("|")
);
// regexp must not have capturing parentheses
@ -72,6 +74,14 @@ var XQueryHighlightRules = function() {
token: "support.function",
regex: "\\w[\\w+_\\-:]+(?=\\()"
}, {
token : function(value) {
if (keywords[value])
return "keyword";
else
return "identifier";
},
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token: "keyword.operator",
regex: "\\*|=|<|>|\\-|\\+|and|or|eq|ne|lt|gt"
}, {
@ -80,15 +90,7 @@ var XQueryHighlightRules = function() {
}, {
token: "rparen",
regex: "[\\])}]"
}, {
token : function(value) {
if (keywords[value])
return "keyword";
else
return "identifier";
},
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
} ],
} ],
tag : [ {
token : "text",