You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2013/10/29 16:39:48 UTC

[03/51] [partial] working replacement

http://git-wip-us.apache.org/repos/asf/couchdb/blob/9abd128c/src/fauxton/assets/js/libs/ace/mode/verilog_highlight_rules.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/mode/verilog_highlight_rules.js b/src/fauxton/assets/js/libs/ace/mode/verilog_highlight_rules.js
new file mode 100644
index 0000000..83aa16a
--- /dev/null
+++ b/src/fauxton/assets/js/libs/ace/mode/verilog_highlight_rules.js
@@ -0,0 +1,101 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Distributed under the BSD license:
+ *
+ * Copyright (c) 2010, Ajax.org B.V.
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Ajax.org B.V. nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+
+define(function(require, exports, module) {
+"use strict";
+
+var oop = require("../lib/oop");
+var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
+
+var VerilogHighlightRules = function() {
+var keywords = "always|and|assign|automatic|begin|buf|bufif0|bufif1|case|casex|casez|cell|cmos|config|" +
+    "deassign|default|defparam|design|disable|edge|else|end|endcase|endconfig|endfunction|endgenerate|endmodule|" +
+    "endprimitive|endspecify|endtable|endtask|event|for|force|forever|fork|function|generate|genvar|highz0|" +
+    "highz1|if|ifnone|incdir|include|initial|inout|input|instance|integer|join|large|liblist|library|localparam|" +
+    "macromodule|medium|module|nand|negedge|nmos|nor|noshowcancelled|not|notif0|notif1|or|output|parameter|pmos|" +
+    "posedge|primitive|pull0|pull1|pulldown|pullup|pulsestyle_onevent|pulsestyle_ondetect|rcmos|real|realtime|" +
+    "reg|release|repeat|rnmos|rpmos|rtran|rtranif0|rtranif1|scalared|showcancelled|signed|small|specify|specparam|" +
+    "strong0|strong1|supply0|supply1|table|task|time|tran|tranif0|tranif1|tri|tri0|tri1|triand|trior|trireg|" +
+    "unsigned|use|vectored|wait|wand|weak0|weak1|while|wire|wor|xnor|xor" +
+    "begin|bufif0|bufif1|case|casex|casez|config|else|end|endcase|endconfig|endfunction|" +
+    "endgenerate|endmodule|endprimitive|endspecify|endtable|endtask|for|forever|function|generate|if|ifnone|" +
+    "macromodule|module|primitive|repeat|specify|table|task|while";
+
+    var builtinConstants = (
+        "true|false|null"
+    );
+
+    var builtinFunctions = (
+        "count|min|max|avg|sum|rank|now|coalesce|main"
+    );
+
+    var keywordMapper = this.createKeywordMapper({
+        "support.function": builtinFunctions,
+        "keyword": keywords,
+        "constant.language": builtinConstants
+    }, "identifier", true);
+
+    this.$rules = {
+        "start" : [ {
+            token : "comment",
+            regex : "//.*$"
+        }, {
+            token : "string",           // " string
+            regex : '".*?"'
+        }, {
+            token : "string",           // ' string
+            regex : "'.*?'"
+        }, {
+            token : "constant.numeric", // float
+            regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
+        }, {
+            token : keywordMapper,
+            regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
+        }, {
+            token : "keyword.operator",
+            regex : "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="
+        }, {
+            token : "paren.lparen",
+            regex : "[\\(]"
+        }, {
+            token : "paren.rparen",
+            regex : "[\\)]"
+        }, {
+            token : "text",
+            regex : "\\s+"
+        } ]
+    };
+};
+
+oop.inherits(VerilogHighlightRules, TextHighlightRules);
+
+exports.VerilogHighlightRules = VerilogHighlightRules;
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/9abd128c/src/fauxton/assets/js/libs/ace/mode/vhdl.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/mode/vhdl.js b/src/fauxton/assets/js/libs/ace/mode/vhdl.js
new file mode 100644
index 0000000..13245e0
--- /dev/null
+++ b/src/fauxton/assets/js/libs/ace/mode/vhdl.js
@@ -0,0 +1,52 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Distributed under the BSD license:
+ *
+ * Copyright (c) 2013, Ajax.org B.V.
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Ajax.org B.V. nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***** END LICENSE BLOCK ***** */
+define(function(require, exports, module) {
+"use strict";
+
+var oop = require("../lib/oop");
+var TextMode = require("./text").Mode;
+var Tokenizer = require("../tokenizer").Tokenizer;
+var VHDLHighlightRules = require("./vhdl_highlight_rules").VHDLHighlightRules;
+var Range = require("../range").Range;
+
+var Mode = function() {
+    this.HighlightRules = VHDLHighlightRules;
+};
+oop.inherits(Mode, TextMode);
+
+(function() {
+
+    this.lineCommentStart = "--";
+
+}).call(Mode.prototype);
+
+exports.Mode = Mode;
+
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/9abd128c/src/fauxton/assets/js/libs/ace/mode/vhdl_highlight_rules.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/mode/vhdl_highlight_rules.js b/src/fauxton/assets/js/libs/ace/mode/vhdl_highlight_rules.js
new file mode 100644
index 0000000..671d0fe
--- /dev/null
+++ b/src/fauxton/assets/js/libs/ace/mode/vhdl_highlight_rules.js
@@ -0,0 +1,115 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Distributed under the BSD license:
+ *
+ * Copyright (c) 2013, Ajax.org B.V.
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Ajax.org B.V. nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***** END LICENSE BLOCK ***** */
+define(function(require, exports, module) {
+"use strict";
+
+var oop = require("../lib/oop");
+var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
+
+var VHDLHighlightRules = function() {
+
+
+    
+    var keywords = "access|after|ailas|all|architecture|assert|attribute|"+
+                   "begin|block|buffer|bus|case|component|configuration|"+
+                   "disconnect|downto|else|elsif|end|entity|file|for|function|"+
+                   "generate|generic|guarded|if|impure|in|inertial|inout|is|"+
+                   "label|linkage|literal|loop|mapnew|next|of|on|open|"+
+                   "others|out|port|process|pure|range|record|reject|"+
+                   "report|return|select|shared|subtype|then|to|transport|"+
+                   "type|unaffected|united|until|wait|when|while|with";
+    
+    var storageType = "bit|bit_vector|boolean|character|integer|line|natural|"+
+                      "positive|real|register|severity|signal|signed|"+
+                      "std_logic|std_logic_vector|string||text|time|unsigned|"+
+                      "variable";
+    
+    var storageModifiers = "array|constant";
+    
+    var keywordOperators = "abs|and|mod|nand|nor|not|rem|rol|ror|sla|sll|sra"+
+                           "srl|xnor|xor";
+    
+    var builtinConstants = (
+        "true|false|null"
+    );
+
+
+    var keywordMapper = this.createKeywordMapper({
+        "keyword.operator": keywordOperators,
+        "keyword": keywords,
+        "constant.language": builtinConstants,
+        "storage.modifier": storageModifiers,
+        "storage.type": storageType
+    }, "identifier", true);
+
+    this.$rules = {
+        "start" : [ {
+            token : "comment",
+            regex : "--.*$"
+        }, {
+            token : "string",           // " string
+            regex : '".*?"'
+        }, {
+            token : "string",           // ' string
+            regex : "'.*?'"
+        }, {
+            token : "constant.numeric", // float
+            regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
+        }, {
+            token : "keyword", // pre-compiler directives
+            regex : "\\s*(?:library|package|use)\\b",
+        }, {
+            token : keywordMapper,
+            regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
+        }, {
+            token : "keyword.operator",
+            regex : "&|\\*|\\+|\\-|\\/|<|=|>|\\||=>|\\*\\*|:=|\\/=|>=|<=|<>" 
+        }, {
+              token : "punctuation.operator",
+              regex : "\\'|\\:|\\,|\\;|\\."
+        },{
+            token : "paren.lparen",
+            regex : "[[(]"
+        }, {
+            token : "paren.rparen",
+            regex : "[\\])]"
+        }, {
+            token : "text",
+            regex : "\\s+"
+        } ],
+
+       
+    };
+};
+
+oop.inherits(VHDLHighlightRules, TextHighlightRules);
+
+exports.VHDLHighlightRules = VHDLHighlightRules;
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/9abd128c/src/fauxton/assets/js/libs/ace/mode/xml.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/mode/xml.js b/src/fauxton/assets/js/libs/ace/mode/xml.js
new file mode 100644
index 0000000..c6e18fc
--- /dev/null
+++ b/src/fauxton/assets/js/libs/ace/mode/xml.js
@@ -0,0 +1,56 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Distributed under the BSD license:
+ *
+ * Copyright (c) 2010, Ajax.org B.V.
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Ajax.org B.V. nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+define(function(require, exports, module) {
+"use strict";
+
+var oop = require("../lib/oop");
+var TextMode = require("./text").Mode;
+var Tokenizer = require("../tokenizer").Tokenizer;
+var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
+var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
+var XmlFoldMode = require("./folding/xml").FoldMode;
+
+var Mode = function() {
+    this.HighlightRules = XmlHighlightRules;
+    this.$behaviour = new XmlBehaviour();
+    this.foldingRules = new XmlFoldMode();
+};
+
+oop.inherits(Mode, TextMode);
+
+(function() {
+    
+    this.blockComment = {start: "<!--", end: "-->"};
+
+}).call(Mode.prototype);
+
+exports.Mode = Mode;
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/9abd128c/src/fauxton/assets/js/libs/ace/mode/xml_highlight_rules.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/mode/xml_highlight_rules.js b/src/fauxton/assets/js/libs/ace/mode/xml_highlight_rules.js
new file mode 100644
index 0000000..dd3d2a2
--- /dev/null
+++ b/src/fauxton/assets/js/libs/ace/mode/xml_highlight_rules.js
@@ -0,0 +1,216 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Distributed under the BSD license:
+ *
+ * Copyright (c) 2010, Ajax.org B.V.
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Ajax.org B.V. nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+define(function(require, exports, module) {
+"use strict";
+
+var oop = require("../lib/oop");
+var xmlUtil = require("./xml_util");
+var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
+
+var XmlHighlightRules = function(normalize) {
+    this.$rules = {
+        start : [
+            {token : "punctuation.string.begin", regex : "<\\!\\[CDATA\\[", next : "cdata"},
+            {
+                token : ["punctuation.instruction.begin", "keyword.instruction"],
+                regex : "(<\\?)(xml)(?=[\\s])", next : "xml_declaration"
+            },
+            {
+                token : ["punctuation.instruction.begin", "keyword.instruction"],
+                regex : "(<\\?)([-_a-zA-Z0-9]+)", next : "instruction"
+            },
+            {token : "comment", regex : "<\\!--", next : "comment"},
+            {
+                token : ["punctuation.doctype.begin", "meta.tag.doctype"],
+                regex : "(<\\!)(DOCTYPE)(?=[\\s])", next : "doctype"
+            },
+            {include : "tag"},
+            {include : "reference"}
+        ],
+
+        xml_declaration : [
+            {include : "attributes"},
+            {include : "instruction"}
+        ],
+
+        instruction : [
+            {token : "punctuation.instruction.end", regex : "\\?>", next : "start"}
+        ],
+
+        doctype : [
+            {include : "space"},
+            {include : "string"},
+            {token : "punctuation.doctype.end", regex : ">", next : "start"},
+            {token : "xml-pe", regex : "[-_a-zA-Z0-9:]+"},
+            {token : "punctuation.begin", regex : "\\[", push : "declarations"}
+        ],
+
+        declarations : [{
+            token : "text",
+            regex : "\\s+"
+        }, {
+            token: "punctuation.end",
+            regex: "]",
+            next: "pop"
+        }, {
+            token : ["punctuation.begin", "keyword"],
+            regex : "(<\\!)([-_a-zA-Z0-9]+)",
+            push : [{
+                token : "text",
+                regex : "\\s+"
+            },
+            {
+                token : "punctuation.end",
+                regex : ">",
+                next : "pop"
+            },
+            {include : "string"}]
+        }],
+
+        cdata : [
+            {token : "string.end", regex : "\\]\\]>", next : "start"},
+            {token : "text", regex : "\\s+"},
+            {token : "text", regex : "(?:[^\\]]|\\](?!\\]>))+"}
+        ],
+
+        comment : [
+            {token : "comment", regex : "-->", next : "start"},
+            {defaultToken : "comment"}
+        ],
+
+        tag : [{
+            token : ["meta.tag.punctuation.begin", "meta.tag.name"],
+            regex : "(<)((?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+)",
+            next: [
+                {include : "attributes"},
+                {token : "meta.tag.punctuation.end", regex : "/?>", next : "start"}
+            ]
+        }, {
+            token : ["meta.tag.punctuation.begin", "meta.tag.name"],
+            regex : "(</)((?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+)",
+            next: [
+                {include : "space"},
+                {token : "meta.tag.punctuation.end", regex : ">", next : "start"}
+            ]
+        }],
+
+        space : [
+            {token : "text", regex : "\\s+"}
+        ],
+
+        reference : [{
+            token : "constant.language.escape",
+            regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
+        }, {
+            token : "invalid.illegal", regex : "&"
+        }],
+
+        string: [{
+            token : "string",
+            regex : "'",
+            push : "qstring_inner"
+        }, {
+            token : "string",
+            regex : '"',
+            push : "qqstring_inner"
+        }],
+
+        qstring_inner: [
+            {token : "string", regex: "'", next: "pop"},
+            {include : "reference"},
+            {defaultToken : "string"}
+        ],
+
+        qqstring_inner: [
+            {token : "string", regex: '"', next: "pop"},
+            {include : "reference"},
+            {defaultToken : "string"}
+        ],
+
+        attributes: [{
+            token : "entity.other.attribute-name",
+            regex : "(?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+"
+        }, {
+            token : "keyword.operator.separator",
+            regex : "="
+        }, {
+            include : "space"
+        }, {
+            include : "string"
+        }]
+    };
+
+    if (this.constructor === XmlHighlightRules)
+        this.normalizeRules();
+};
+
+
+(function() {
+
+    this.embedTagRules = function(HighlightRules, prefix, tag){
+        this.$rules.tag.unshift({
+            token : ["meta.tag.punctuation.begin", "meta.tag.name." + tag],
+            regex : "(<)(" + tag + ")",
+            next: [
+                {include : "space"},
+                {include : "attributes"},
+                {token : "meta.tag.punctuation.end", regex : "/?>", next : prefix + "start"}
+            ]
+        });
+
+        this.$rules[tag + "-end"] = [
+            {include : "space"},
+            {token : "meta.tag.punctuation.end", regex : ">",  next: "start",
+                onMatch : function(value, currentState, stack) {
+                    stack.splice(0);
+                    return this.token;
+            }}
+        ]
+
+        this.embedRules(HighlightRules, prefix, [{
+            token: ["meta.tag.punctuation.begin", "meta.tag.name." + tag],
+            regex : "(</)(" + tag + ")",
+            next: tag + "-end"
+        }, {
+            token: "string.begin",
+            regex : "<\\!\\[CDATA\\["
+        }, {
+            token: "string.end",
+            regex : "\\]\\]>"
+        }]);
+    };
+
+}).call(TextHighlightRules.prototype);
+
+oop.inherits(XmlHighlightRules, TextHighlightRules);
+
+exports.XmlHighlightRules = XmlHighlightRules;
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/9abd128c/src/fauxton/assets/js/libs/ace/mode/xml_test.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/mode/xml_test.js b/src/fauxton/assets/js/libs/ace/mode/xml_test.js
new file mode 100644
index 0000000..39edf63
--- /dev/null
+++ b/src/fauxton/assets/js/libs/ace/mode/xml_test.js
@@ -0,0 +1,75 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Distributed under the BSD license:
+ *
+ * Copyright (c) 2010, Ajax.org B.V.
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Ajax.org B.V. nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+if (typeof process !== "undefined") {
+    require("amd-loader");
+}
+
+define(function(require, exports, module) {
+"use strict";
+
+var EditSession = require("../edit_session").EditSession;
+var Tokenizer = require("../tokenizer").Tokenizer;
+var XmlMode = require("./xml").Mode;
+var assert = require("../test/assertions");
+
+module.exports = {
+    setUp : function() {
+        this.mode = new XmlMode();
+    },
+
+    "test: getTokenizer() (smoke test)" : function() {
+        var tokenizer = this.mode.getTokenizer();
+
+        assert.ok(tokenizer instanceof Tokenizer);
+
+        var tokens = tokenizer.getLineTokens("<juhu>", "start").tokens;
+        assert.equal("meta.tag.punctuation.begin", tokens[0].type);
+    },
+
+    "test: toggle comment lines should not do anything" : function() {
+        var session = new EditSession(["    abc", "  cde", "fg"]);
+
+        this.mode.toggleCommentLines("start", session, 0, 1);
+        assert.equal(["  <!--  abc-->", "  <!--cde-->", "fg"].join("\n"), session.toString());
+    },
+
+    "test: next line indent should be the same as the current line indent" : function() {
+        assert.equal("     ", this.mode.getNextLineIndent("start", "     abc"));
+        assert.equal("", this.mode.getNextLineIndent("start", "abc"));
+        assert.equal("\t", this.mode.getNextLineIndent("start", "\tabc"));
+    }
+};
+
+});
+
+if (typeof module !== "undefined" && module === require.main) {
+    require("asyncjs").test.testcase(module.exports).exec();
+}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/9abd128c/src/fauxton/assets/js/libs/ace/mode/xml_util.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/mode/xml_util.js b/src/fauxton/assets/js/libs/ace/mode/xml_util.js
new file mode 100644
index 0000000..abae607
--- /dev/null
+++ b/src/fauxton/assets/js/libs/ace/mode/xml_util.js
@@ -0,0 +1,100 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Distributed under the BSD license:
+ *
+ * Copyright (c) 2010, Ajax.org B.V.
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Ajax.org B.V. nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+define(function(require, exports, module) {
+"use strict";
+
+function string(state) {
+    return [{
+        token : "string",
+        regex : '"',
+        next : state + "_qqstring"
+    }, {
+        token : "string",
+        regex : "'",
+        next : state + "_qstring"
+    }];
+}
+
+function multiLineString(quote, state) {
+    return [
+        {token : "string", regex : quote, next : state},
+        {
+            token : "constant.language.escape",
+            regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)" 
+        },
+        {defaultToken : "string"}
+    ];
+}
+
+exports.tag = function(states, name, nextState, tagMap) {
+    states[name] = [{
+        token : "text",
+        regex : "\\s+"
+    }, {
+        //token : "meta.tag",
+        
+    token : !tagMap ? "meta.tag.tag-name" : function(value) {
+            if (tagMap[value])
+                return "meta.tag.tag-name." + tagMap[value];
+            else
+                return "meta.tag.tag-name";
+        },
+        regex : "[-_a-zA-Z0-9:]+",
+        next : name + "_embed_attribute_list" 
+    }, {
+        token: "empty",
+        regex: "",
+        next : name + "_embed_attribute_list"
+    }];
+
+    states[name + "_qstring"] = multiLineString("'", name + "_embed_attribute_list");
+    states[name + "_qqstring"] = multiLineString("\"", name + "_embed_attribute_list");
+    
+    states[name + "_embed_attribute_list"] = [{
+        token : "meta.tag.r",
+        regex : "/?>",
+        next : nextState
+    }, {
+        token : "keyword.operator",
+        regex : "="
+    }, {
+        token : "entity.other.attribute-name",
+        regex : "[-_a-zA-Z0-9:]+"
+    }, {
+        token : "constant.numeric", // float
+        regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
+    }, {
+        token : "text",
+        regex : "\\s+"
+    }].concat(string(name));
+};
+
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/9abd128c/src/fauxton/assets/js/libs/ace/mode/xquery.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/mode/xquery.js b/src/fauxton/assets/js/libs/ace/mode/xquery.js
new file mode 100644
index 0000000..f316b90
--- /dev/null
+++ b/src/fauxton/assets/js/libs/ace/mode/xquery.js
@@ -0,0 +1,139 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Distributed under the BSD license:
+ *
+ * Copyright (c) 2010, Ajax.org B.V.
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Ajax.org B.V. nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***** END LICENSE BLOCK ***** */
+define(function(require, exports, module) {
+"use strict";
+
+var WorkerClient = require("../worker/worker_client").WorkerClient;
+var oop = require("../lib/oop");
+var TextMode = require("./text").Mode;
+var XQueryLexer = require("./xquery/XQueryLexer").XQueryLexer;
+var Range = require("../range").Range;
+var XQueryBehaviour = require("./behaviour/xquery").XQueryBehaviour;
+var CStyleFoldMode = require("./folding/cstyle").FoldMode;
+
+
+var Mode = function() {
+    this.$tokenizer   = new XQueryLexer();
+    this.$behaviour   = new XQueryBehaviour();
+    this.foldingRules = new CStyleFoldMode();
+};
+
+oop.inherits(Mode, TextMode);
+
+(function() {
+
+    this.getNextLineIndent = function(state, line, tab) {
+        var indent = this.$getIndent(line);
+        var match = line.match(/\s*(?:then|else|return|[{\(]|<\w+>)\s*$/);
+        if (match)
+            indent += tab;
+        return indent;
+    };
+    
+    this.checkOutdent = function(state, line, input) {
+        if (! /^\s+$/.test(line))
+            return false;
+
+        return /^\s*[\}\)]/.test(input);
+    };
+    
+    this.autoOutdent = function(state, doc, row) {
+        var line = doc.getLine(row);
+        var match = line.match(/^(\s*[\}\)])/);
+
+        if (!match) return 0;
+
+        var column = match[1].length;
+        var openBracePos = doc.findMatchingBracket({row: row, column: column});
+
+        if (!openBracePos || openBracePos.row == row) return 0;
+
+        var indent = this.$getIndent(doc.getLine(openBracePos.row));
+        doc.replace(new Range(row, 0, row, column-1), indent);
+    };
+
+    this.toggleCommentLines = function(state, doc, startRow, endRow) {
+        var i, line;
+        var outdent = true;
+        var re = /^\s*\(:(.*):\)/;
+
+        for (i=startRow; i<= endRow; i++) {
+            if (!re.test(doc.getLine(i))) {
+                outdent = false;
+                break;
+            }
+        }
+
+        var range = new Range(0, 0, 0, 0);
+        for (i=startRow; i<= endRow; i++) {
+            line = doc.getLine(i);
+            range.start.row  = i;
+            range.end.row    = i;
+            range.end.column = line.length;
+
+            doc.replace(range, outdent ? line.match(re)[1] : "(:" + line + ":)");
+        }
+    };
+    
+    this.createWorker = function(session) {
+        
+      var worker = new WorkerClient(["ace"], "ace/mode/xquery_worker", "XQueryWorker");
+        var that = this;
+
+        worker.attachToDocument(session.getDocument());
+        
+        worker.on("error", function(e) {
+          session.setAnnotations([e.data]);
+        });
+        
+        worker.on("ok", function(e) {
+          session.clearAnnotations();
+        });
+        
+        worker.on("highlight", function(tokens) {
+          that.$tokenizer.tokens = tokens.data.tokens;
+          that.$tokenizer.lines  = session.getDocument().getAllLines();
+          
+          var rows = Object.keys(that.$tokenizer.tokens);
+          for(var i=0; i < rows.length; i++) {
+            var row = parseInt(rows[i]);
+            delete session.bgTokenizer.lines[row];
+            delete session.bgTokenizer.states[row];
+            session.bgTokenizer.fireUpdateEvent(row, row);
+          }
+        });
+        
+        return worker;
+    };
+    
+}).call(Mode.prototype);
+
+exports.Mode = Mode;
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/9abd128c/src/fauxton/assets/js/libs/ace/mode/xquery/JSONParseTreeHandler.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/mode/xquery/JSONParseTreeHandler.js b/src/fauxton/assets/js/libs/ace/mode/xquery/JSONParseTreeHandler.js
new file mode 100644
index 0000000..9b85076
--- /dev/null
+++ b/src/fauxton/assets/js/libs/ace/mode/xquery/JSONParseTreeHandler.js
@@ -0,0 +1,178 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Distributed under the BSD license:
+ *
+ * Copyright (c) 2010, Ajax.org B.V.
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Ajax.org B.V. nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***** END LICENSE BLOCK ***** */
+ 
+define(function(require, exports, module){
+
+  var JSONParseTreeHandler = exports.JSONParseTreeHandler = function(code) {
+
+    //List of nodes that are not targeted by the parse tree size optimization.
+    var list = [
+        "OrExpr", "AndExpr", "ComparisonExpr", "StringConcatExpr", "RangeExpr"
+        //, "AdditiveExpr", "MultiplicativeExpr"
+        , "UnionExpr", "IntersectExceptExpr", "InstanceofExpr", "TreatExpr", "CastableExpr"
+        , "CastExpr", "UnaryExpr", "ValueExpr", "FTContainsExpr", "SimpleMapExpr", "PathExpr", "RelativePathExpr"
+        , "PostfixExpr", "StepExpr"
+    ];
+    
+    var ast = null;
+    var ptr = null;
+    var remains = code;
+    var cursor = 0;
+    var lineCursor = 0;
+    var line = 0;
+    var col = 0;
+
+    function createNode(name){
+      return { name: name, children: [], getParent: null, pos: { sl: 0, sc: 0, el: 0, ec: 0 } };
+    }
+  
+    function pushNode(name, begin){
+      var node = createNode(name);
+      if(ast === null) {
+        ast = node;
+        ptr = node;
+      } else {
+        node.getParent = ptr;
+        ptr.children.push(node);
+        ptr = ptr.children[ptr.children.length - 1];
+      }
+    }
+    
+    function popNode(){
+     
+      if(ptr.children.length > 0) {
+        var s = ptr.children[0];
+        var e = null;
+        //We want to skip empty non terminals. For instance PredicateList:
+        // [108] AxisStep ::= (ReverseStep | ForwardStep) PredicateList
+        // [120] PredicateList ::= Predicate*
+        for(var i= ptr.children.length - 1; i >= 0;i--) {
+          e = ptr.children[i];
+          if(e.pos.el !== 0 || e.pos.ec !== 0) {
+            break;
+          }
+        }
+        ptr.pos.sl = s.pos.sl;
+        ptr.pos.sc = s.pos.sc;
+        ptr.pos.el = e.pos.el;
+        ptr.pos.ec = e.pos.ec;
+      }
+      
+      //Normalize EQName && FunctionName
+      if(ptr.name === "FunctionName") {
+        ptr.name = "EQName";  
+      }
+      if(ptr.name === "EQName" && ptr.value === undefined) {
+        ptr.value = ptr.children[0].value;
+        ptr.children.pop();
+      }
+      
+      if(ptr.getParent !== null) {
+        ptr = ptr.getParent;
+        //for(var i in ptr.children) {
+          //delete ptr.children[i].getParent;
+        //}
+      } else {
+        //delete ptr.getParent;
+      }
+
+      //Parse tree size optimization
+      if(ptr.children.length > 0) {
+        var lastChild = ptr.children[ptr.children.length - 1];
+        if(lastChild.children.length === 1 && list.indexOf(lastChild.name) !== -1) {
+          ptr.children[ptr.children.length - 1] = lastChild.children[0];
+        }
+      }
+    }
+    
+    this.closeParseTree = function() {
+      while(ptr.getParent !== null) {
+        popNode();
+      }
+      popNode();
+    };
+
+    this.peek = function() {
+      return ptr;    
+    };
+    
+    this.getParseTree = function() {
+      return ast;
+    };
+ 
+    this.reset = function(input) {};
+
+    this.startNonterminal = function(name, begin) {
+      pushNode(name, begin);
+    };
+
+    this.endNonterminal = function(name, end) {
+      popNode();
+    };
+
+    this.terminal = function(name, begin, end) {
+      name = (name.substring(0, 1) === "'" && name.substring(name.length - 1) === "'") ? "TOKEN" : name;
+      pushNode(name, begin); 
+      setValue(ptr, begin, end);
+      popNode();
+    };
+
+    this.whitespace = function(begin, end) {
+      var name = "WS";
+      pushNode(name, begin);
+      setValue(ptr, begin, end);
+      popNode();
+    };
+
+    function setValue(node, begin, end) {
+      
+      var e = end - cursor;
+      ptr.value = remains.substring(0, e); 
+      remains = remains.substring(e);
+      cursor = end;
+      
+      var sl = line;
+      var sc = lineCursor;
+      var el = sl + ptr.value.split("\n").length - 1;
+      var lastIdx = ptr.value.lastIndexOf("\n");
+      var ec = lastIdx === -1 ? sc + ptr.value.length : ptr.value.substring(lastIdx + 1).length;
+//      ec = ec === 0 ? 0 : ec - 1;
+      
+      line = el;
+      //lineCursor = ec === 0 ? 0 : ec;
+      lineCursor = ec;
+
+      ptr.pos.sl = sl; 
+      ptr.pos.sc = sc; 
+      ptr.pos.el = el; 
+      ptr.pos.ec = ec; 
+    } 
+  };
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/9abd128c/src/fauxton/assets/js/libs/ace/mode/xquery/JSONiqLexer.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/mode/xquery/JSONiqLexer.js b/src/fauxton/assets/js/libs/ace/mode/xquery/JSONiqLexer.js
new file mode 100644
index 0000000..d2a9b48
--- /dev/null
+++ b/src/fauxton/assets/js/libs/ace/mode/xquery/JSONiqLexer.js
@@ -0,0 +1,302 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Distributed under the BSD license:
+ *
+ * Copyright (c) 2010, Ajax.org B.V.
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Ajax.org B.V. nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***** END LICENSE BLOCK ***** */
+ 
+define(function(require, exports, module){
+  
+  var JSONiqTokenizer = require("./JSONiqTokenizer").JSONiqTokenizer;
+  
+  var TokenHandler = function(code) {
+      
+    var input = code;
+    
+    this.tokens = [];
+ 
+    this.reset = function(code) {
+      input = input;
+      this.tokens = [];
+    };
+    
+    this.startNonterminal = function(name, begin) {};
+
+    this.endNonterminal = function(name, end) {};
+
+    this.terminal = function(name, begin, end) {
+      this.tokens.push({
+        name: name,
+        value: input.substring(begin, end)
+      });
+    };
+
+    this.whitespace = function(begin, end) {
+      this.tokens.push({
+        name: "WS",
+        value: input.substring(begin, end)
+      });
+    };
+  };
+    var keys = "NaN|after|allowing|ancestor|ancestor-or-self|and|append|array|as|ascending|at|attribute|base-uri|before|boundary-space|break|by|case|cast|castable|catch|child|collation|comment|constraint|construction|contains|context|continue|copy|copy-namespaces|count|decimal-format|decimal-separator|declare|default|delete|descendant|descendant-or-self|descending|digit|div|document|document-node|element|else|empty|empty-sequence|encoding|end|eq|every|except|exit|external|false|first|following|following-sibling|for|from|ft-option|function|ge|greatest|group|grouping-separator|gt|idiv|if|import|in|index|infinity|insert|instance|integrity|intersect|into|is|item|json|json-item|jsoniq|last|lax|le|least|let|loop|lt|minus-sign|mod|modify|module|namespace|namespace-node|ne|next|node|nodes|not|null|object|of|only|option|or|order|ordered|ordering|paragraphs|parent|pattern-separator|per-mille|percent|preceding|preceding-sibling|previous|processing-instruction|rename|replace|return|returning|re
 validation|satisfies|schema|schema-attribute|schema-element|score|select|self|sentences|sliding|some|stable|start|strict|switch|text|then|times|to|treat|true|try|tumbling|type|typeswitch|union|unordered|updating|validate|value|variable|version|when|where|while|window|with|words|xquery|zero-digit".split("|");
+    var keywords = keys.map(
+      function(val) { return { name: "'" + val + "'", token: "keyword" }; }
+    );
+    
+    var ncnames = keys.map(
+      function(val) { return { name: "'" + val + "'", token: "text", next: function(stack){ stack.pop(); } }; }
+    );
+
+    var cdata = "constant.language";
+    var number = "constant";
+    var xmlcomment = "comment";
+    var pi = "xml-pe";
+    var pragma = "constant.buildin";
+    
+    var Rules = {
+      start: [
+        { name: "'(#'", token: pragma, next: function(stack){ stack.push("Pragma"); } },
+        { name: "'(:'", token: "comment", next: function(stack){ stack.push("Comment"); } },
+        { name: "'(:~'", token: "comment.doc", next: function(stack){ stack.push("CommentDoc"); } },
+        { name: "'<!--'", token: xmlcomment, next: function(stack){ stack.push("XMLComment"); } },
+        { name: "'<?'", token: pi, next: function(stack) { stack.push("PI"); } },
+        { name: "''''", token: "string", next: function(stack){ stack.push("AposString"); } },
+        { name: "'\"'", token: "string", next: function(stack){ stack.push("QuotString"); } },
+        { name: "Annotation", token: "support.function" },
+        { name: "ModuleDecl", token: "keyword", next: function(stack){ stack.push("Prefix"); } },
+        { name: "OptionDecl", token: "keyword", next: function(stack){ stack.push("_EQName"); } },
+        { name: "AttrTest", token: "support.type" },
+        { name: "Variable",  token: "variable" },
+        { name: "'<![CDATA['", token: cdata, next: function(stack){ stack.push("CData"); } },
+        { name: "IntegerLiteral", token: number },
+        { name: "DecimalLiteral", token: number },
+        { name: "DoubleLiteral", token: number },
+        { name: "Operator", token: "keyword.operator" },
+        { name: "EQName", token: function(val) { return keys.indexOf(val) !== -1 ? "keyword" : "support.function"; } },
+        { name: "'('", token:"lparen" },
+        { name: "')'", token:"rparen" },
+        { name: "Tag", token: "meta.tag", next: function(stack){ stack.push("StartTag"); } },
+        { name: "'}'", token: "text", next: function(stack){ if(stack.length > 1) stack.pop();  } },
+        { name: "'{'", token: "text", next: function(stack){ stack.push("start"); } } //, next: function(stack){ if(stack.length > 1) { stack.pop(); } } }
+      ].concat(keywords),
+      _EQName: [
+        { name: "EQName", token: "text", next: function(stack) { stack.pop(); } }
+      ].concat(ncnames),
+      Prefix: [
+        { name: "NCName", token: "text", next: function(stack) { stack.pop(); } }
+      ].concat(ncnames),
+      StartTag: [
+        { name: "'>'", token: "meta.tag", next: function(stack){ stack.push("TagContent"); } },
+        { name: "QName", token: "entity.other.attribute-name" },
+        { name: "'='", token: "text" },
+        { name: "''''", token: "string", next: function(stack){ stack.push("AposAttr"); } },
+        { name: "'\"'", token: "string", next: function(stack){ stack.push("QuotAttr"); } },
+        { name: "'/>'", token: "meta.tag.r", next: function(stack){ stack.pop(); } }
+      ],
+      TagContent: [
+        { name: "ElementContentChar", token: "text" },
+        { name: "'<![CDATA['", token: cdata, next: function(stack){ stack.push("CData"); } },
+        { name: "'<!--'", token: xmlcomment, next: function(stack){ stack.push("XMLComment"); } },
+        { name: "Tag", token: "meta.tag", next: function(stack){ stack.push("StartTag"); } },
+        { name: "PredefinedEntityRef", token: "constant.language.escape" },
+        { name: "CharRef", token: "constant.language.escape" },
+        { name: "'{{'", token: "text" },
+        { name: "'}}'", token: "text" },
+        { name: "'{'", token: "text", next: function(stack){ stack.push("start"); } },
+        { name: "EndTag", token: "meta.tag", next: function(stack){ stack.pop(); stack.pop(); } }
+      ],
+      AposAttr: [
+        { name: "''''", token: "string", next: function(stack){ stack.pop(); } },
+        { name: "EscapeApos", token: "constant.language.escape" },
+        { name: "AposAttrContentChar", token: "string" },
+        { name: "PredefinedEntityRef", token: "constant.language.escape" },
+        { name: "CharRef", token: "constant.language.escape" },
+        { name: "'{{'", token: "string" },
+        { name: "'}}'", token: "string" },
+        { name: "'{'", token: "text", next: function(stack){ stack.push("start"); } }
+      ],
+      QuotAttr: [
+        { name: "'\"'", token: "string", next: function(stack){ stack.pop(); } },
+        { name: "EscapeQuot", token: "constant.language.escape" },
+        { name: "QuotAttrContentChar", token: "string" },
+        { name: "PredefinedEntityRef", token: "constant.language.escape" },
+        { name: "CharRef", token: "constant.language.escape" },
+        { name: "'{{'", token: "string" },
+        { name: "'}}'", token: "string" },
+        { name: "'{'", token: "text", next: function(stack){ stack.push("start"); } }
+      ],
+      Pragma: [
+        { name: "PragmaContents", token: pragma },
+        { name: "'#'", token: pragma },
+        { name: "'#)'", token: pragma, next: function(stack){ stack.pop(); } }
+      ],
+      Comment: [
+        { name: "CommentContents", token: "comment" },
+        { name: "'(:'", token: "comment", next: function(stack){ stack.push("Comment"); } },
+        { name: "':)'", token: "comment", next: function(stack){ stack.pop(); } }
+      ],
+      CommentDoc: [
+        { name: "DocCommentContents", token: "comment.doc" },
+        { name: "DocTag", token: "comment.doc.tag" },
+        { name: "'(:'", token: "comment.doc", next: function(stack){ stack.push("CommentDoc"); } },
+        { name: "':)'", token: "comment.doc", next: function(stack){ stack.pop(); } }
+      ],
+      XMLComment: [
+        { name: "DirCommentContents", token: xmlcomment },
+        { name: "'-->'", token: xmlcomment, next: function(stack){ stack.pop(); } }
+      ],
+      CData: [
+        { name: "CDataSectionContents", token: cdata },
+        { name: "']]>'", token: cdata, next: function(stack){ stack.pop(); } }
+      ],
+      PI: [
+        { name: "DirPIContents", token: pi },
+        { name: "'?'", token: pi },
+        { name: "'?>'", token: pi, next: function(stack){ stack.pop(); } }
+      ],
+      AposString: [
+        { name: "''''", token: "string", next: function(stack){ stack.pop(); } },
+        { name: "PredefinedEntityRef", token: "constant.language.escape" },
+        { name: "CharRef", token: "constant.language.escape" },
+        { name: "EscapeApos", token: "constant.language.escape" },
+        { name: "AposChar", token: "string" }
+      ],
+      QuotString: [
+        { name: "'\"'", token: "string", next: function(stack){ stack.pop(); } },
+        { name: "PredefinedEntityRef", token: "constant.language.escape" },
+        { name: "CharRef", token: "constant.language.escape" },
+        { name: "EscapeQuot", token: "constant.language.escape" },
+        { name: "QuotChar", token: "string" }
+      ]
+    };
+    
+exports.JSONiqLexer = function() {
+  
+  this.tokens = [];
+  
+  this.getLineTokens = function(line, state, row) {
+    state = (state === "start" || !state) ? '["start"]' : state;
+    var stack = JSON.parse(state);
+    var h = new TokenHandler(line);
+    var tokenizer = new JSONiqTokenizer(line, h);
+    var tokens = [];
+    
+    while(true) {
+      var currentState = stack[stack.length - 1];
+      try {
+        
+        h.tokens = [];
+        tokenizer["parse_" + currentState]();
+        var info = null;
+        
+        if(h.tokens.length > 1 && h.tokens[0].name === "WS") {
+          tokens.push({
+            type: "text",
+            value: h.tokens[0].value
+          });
+          h.tokens.splice(0, 1);
+        }
+        
+        var token = h.tokens[0];
+        var rules  = Rules[currentState];
+        for(var k = 0; k < rules.length; k++) {
+          var rule = Rules[currentState][k];
+          if((typeof(rule.name) === "function" && rule.name(token)) || rule.name === token.name) {
+            info = rule;
+            break;
+          }
+        }
+        
+        if(token.name === "EOF") { break; }
+        if(token.value === "") { throw "Encountered empty string lexical rule."; }
+        
+        tokens.push({
+          type: info === null ? "text" : (typeof(info.token) === "function" ? info.token(token.value) : info.token),
+          value: token.value
+        });
+        
+        if(info && info.next) {
+          info.next(stack);    
+        }
+      
+      } catch(e) {
+        if(e instanceof tokenizer.ParseException) {
+          var index = 0;
+          for(var i=0; i < tokens.length; i++) {
+            index += tokens[i].value.length;
+          }
+          tokens.push({ type: "text", value: line.substring(index) });
+          return {
+            tokens: tokens,
+            state: JSON.stringify(["start"])
+          };
+        } else {
+          throw e;
+        }  
+      }
+    }
+   
+    
+    if(this.tokens[row] !== undefined) {
+      var cachedLine = this.lines[row];
+      var begin = sharedStart([line, cachedLine]);
+      var diff = cachedLine.length - line.length;
+      var idx = 0;
+      var col = 0;
+      for(var i = 0; i < tokens.length; i++) {
+        var token = tokens[i];
+        for(var j = 0; j < this.tokens[row].length; j++) {
+          var semanticToken = this.tokens[row][j];
+          if(
+             ((col + token.value.length) <= begin.length && semanticToken.sc === col && semanticToken.ec === (col + token.value.length)) ||
+             (semanticToken.sc === (col + diff) && semanticToken.ec === (col + token.value.length + diff))
+            ) {
+            idx = i;
+            tokens[i].type = semanticToken.type;
+          }
+        }
+        col += token.value.length;
+      }
+    }
+
+    return {
+      tokens: tokens,
+      state: JSON.stringify(stack)
+    };
+  };
+  
+  function sharedStart(A) {
+    var tem1, tem2, s, A = A.slice(0).sort();
+    tem1 = A[0];
+    s = tem1.length;
+    tem2 = A.pop();
+    while(s && tem2.indexOf(tem1) == -1) {
+        tem1 = tem1.substring(0, --s);
+    }
+    return tem1;
+  }
+};
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/9abd128c/src/fauxton/assets/js/libs/ace/mode/xquery/JSONiqTokenizer.ebnf
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/mode/xquery/JSONiqTokenizer.ebnf b/src/fauxton/assets/js/libs/ace/mode/xquery/JSONiqTokenizer.ebnf
new file mode 100644
index 0000000..b032948
--- /dev/null
+++ b/src/fauxton/assets/js/libs/ace/mode/xquery/JSONiqTokenizer.ebnf
@@ -0,0 +1,544 @@
+<?xqlint
+/* ***** BEGIN LICENSE BLOCK *****
+ * Distributed under the BSD license:
+ *
+ * Copyright (c) 2010, Ajax.org B.V.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Ajax.org B.V. nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+define(function(require, exports, module){
+var JSONiqTokenizer = exports.JSONiqTokenizer = function JSONiqTokenizer(string, parsingEventHandler)
+{
+  init(string, parsingEventHandler);
+?>
+
+start   ::= '<![CDATA['
+          | '<!--'
+          | '<?'
+          | '(#'
+          | '(:~'
+          | '(:'
+          | '"'
+          | "'"
+          | "}"
+          | "{"
+          | "("
+          | ")"
+          | "/"
+          | "["
+          | "]"
+          | ","
+          | "."
+          | ";"
+          | ":"
+          | "!"
+          | "|"
+          | Annotation
+          | ModuleDecl
+          | OptionDecl
+          | AttrTest
+          | Wildcard
+          | IntegerLiteral
+          | DecimalLiteral
+          | DoubleLiteral
+          | Variable
+          | EQName
+          | Tag
+          | Operator
+          | EOF
+
+StartTag  ::= '>' | '/>' | QName | "=" | '"' | "'" | EOF
+
+
+TagContent
+         ::= ElementContentChar | Tag | EndTag | '<![CDATA[' | '<!--' | PredefinedEntityRef | CharRef | '{{' | '}}' | '{' | EOF
+          /* ws: explicit */
+
+AposAttr
+        ::= EscapeApos | AposAttrContentChar | PredefinedEntityRef | CharRef | '{{' | '}}' | '{' | "'" | EOF
+          /* ws: explicit */
+
+QuotAttr
+        ::= EscapeQuot | QuotAttrContentChar | PredefinedEntityRef | CharRef | '{{' | '}}' | '{' | '"' | EOF
+          /* ws: explicit */
+
+CData    ::= CDataSectionContents | ']]>' | EOF
+          /* ws: explicit */
+
+XMLComment
+         ::= DirCommentContents | '-->' | EOF
+          /* ws: explicit */
+
+PI       ::= DirPIContents | '?' | '?>' | EOF
+          /* ws: explicit */
+
+Pragma   ::= PragmaContents | '#' | '#)' | EOF
+          /* ws: explicit */
+
+Comment  ::= ':)' | '(:' | CommentContents | EOF
+          /* ws: explicit */
+
+CommentDoc
+         ::= DocTag | DocCommentContents | ':)' | '(:' | EOF
+          /* ws: explicit */
+
+QuotString
+         ::= PredefinedEntityRef | CharRef | EscapeQuot | QuotChar | '"' | EOF
+          /* ws: explicit */
+
+AposString
+         ::= PredefinedEntityRef | CharRef | EscapeApos | AposChar | "'" | EOF
+          /* ws: explicit */
+
+Prefix  ::= NCName
+
+_EQName ::= EQName
+
+Whitespace
+         ::= S^WS
+          /* ws: definition */
+
+EQName   ::= FunctionName
+           | 'attribute'
+           | 'comment'
+           | 'document-node'
+           | 'element'
+           | 'empty-sequence'
+           | 'function'
+           | 'if'
+           | 'item'
+           | 'namespace-node'
+           | 'node'
+           | 'processing-instruction'
+           | 'schema-attribute'
+           | 'schema-element'
+           | 'switch'
+           | 'text'
+           | 'typeswitch'
+FunctionName
+         ::= EQName^Token
+           | 'after'
+           | 'ancestor'
+           | 'ancestor-or-self'
+           | 'and'
+           | 'as'
+           | 'ascending'
+           | 'before'
+           | 'case'
+           | 'cast'
+           | 'castable'
+           | 'child'
+           | 'collation'
+           | 'copy'
+           | 'count'
+           | 'declare'
+           | 'default'
+           | 'delete'
+           | 'descendant'
+           | 'descendant-or-self'
+           | 'descending'
+           | 'div'
+           | 'document'
+           | 'else'
+           | 'empty'
+           | 'end'
+           | 'eq'
+           | 'every'
+           | 'except'
+           | 'first'
+           | 'following'
+           | 'following-sibling'
+           | 'for'
+           | 'ge'
+           | 'group'
+           | 'gt'
+           | 'idiv'
+           | 'import'
+           | 'insert'
+           | 'instance'
+           | 'intersect'
+           | 'into'
+           | 'is'
+           | 'last'
+           | 'le'
+           | 'let'
+           | 'lt'
+           | 'mod'
+           | 'modify'
+           | 'module'
+           | 'namespace'
+           | 'ne'
+           | 'only'
+           | 'or'
+           | 'order'
+           | 'ordered'
+           | 'parent'
+           | 'preceding'
+           | 'preceding-sibling'
+           | 'rename'
+           | 'replace'
+           | 'return'
+           | 'satisfies'
+           | 'self'
+           | 'some'
+           | 'stable'
+           | 'start'
+           | 'to'
+           | 'treat'
+           | 'try'
+           | 'union'
+           | 'unordered'
+           | 'validate'
+           | 'where'
+           | 'with'
+           | 'xquery'
+           | 'allowing'
+           | 'at'
+           | 'base-uri'
+           | 'boundary-space'
+           | 'break'
+           | 'catch'
+           | 'construction'
+           | 'context'
+           | 'continue'
+           | 'copy-namespaces'
+           | 'decimal-format'
+           | 'encoding'
+           | 'exit'
+           | 'external'
+           | 'ft-option'
+           | 'in'
+           | 'index'
+           | 'integrity'
+           | 'lax'
+           | 'nodes'
+           | 'option'
+           | 'ordering'
+           | 'revalidation'
+           | 'schema'
+           | 'score'
+           | 'sliding'
+           | 'strict'
+           | 'tumbling'
+           | 'type'
+           | 'updating'
+           | 'value'
+           | 'variable'
+           | 'version'
+           | 'while'
+           | 'constraint'
+           | 'loop'
+           | 'returning'
+NCName   ::= NCName^Token
+           | 'after'
+           | 'and'
+           | 'as'
+           | 'ascending'
+           | 'before'
+           | 'case'
+           | 'cast'
+           | 'castable'
+           | 'collation'
+           | 'count'
+           | 'default'
+           | 'descending'
+           | 'div'
+           | 'else'
+           | 'empty'
+           | 'end'
+           | 'eq'
+           | 'except'
+           | 'for'
+           | 'ge'
+           | 'group'
+           | 'gt'
+           | 'idiv'
+           | 'instance'
+           | 'intersect'
+           | 'into'
+           | 'is'
+           | 'le'
+           | 'let'
+           | 'lt'
+           | 'mod'
+           | 'modify'
+           | 'ne'
+           | 'only'
+           | 'or'
+           | 'order'
+           | 'return'
+           | 'satisfies'
+           | 'stable'
+           | 'start'
+           | 'to'
+           | 'treat'
+           | 'union'
+           | 'where'
+           | 'with'
+           | 'ancestor'
+           | 'ancestor-or-self'
+           | 'attribute'
+           | 'child'
+           | 'comment'
+           | 'copy'
+           | 'declare'
+           | 'delete'
+           | 'descendant'
+           | 'descendant-or-self'
+           | 'document'
+           | 'document-node'
+           | 'element'
+           | 'empty-sequence'
+           | 'every'
+           | 'first'
+           | 'following'
+           | 'following-sibling'
+           | 'function'
+           | 'if'
+           | 'import'
+           | 'insert'
+           | 'item'
+           | 'last'
+           | 'module'
+           | 'namespace'
+           | 'namespace-node'
+           | 'node'
+           | 'ordered'
+           | 'parent'
+           | 'preceding'
+           | 'preceding-sibling'
+           | 'processing-instruction'
+           | 'rename'
+           | 'replace'
+           | 'schema-attribute'
+           | 'schema-element'
+           | 'self'
+           | 'some'
+           | 'switch'
+           | 'text'
+           | 'try'
+           | 'typeswitch'
+           | 'unordered'
+           | 'validate'
+           | 'variable'
+           | 'xquery'
+           | 'allowing'
+           | 'at'
+           | 'base-uri'
+           | 'boundary-space'
+           | 'break'
+           | 'catch'
+           | 'construction'
+           | 'context'
+           | 'continue'
+           | 'copy-namespaces'
+           | 'decimal-format'
+           | 'encoding'
+           | 'exit'
+           | 'external'
+           | 'ft-option'
+           | 'in'
+           | 'index'
+           | 'integrity'
+           | 'lax'
+           | 'nodes'
+           | 'option'
+           | 'ordering'
+           | 'revalidation'
+           | 'schema'
+           | 'score'
+           | 'sliding'
+           | 'strict'
+           | 'tumbling'
+           | 'type'
+           | 'updating'
+           | 'value'
+           | 'version'
+           | 'while'
+           | 'constraint'
+           | 'loop'
+           | 'returning'
+<?TOKENS?>
+
+ModuleDecl
+         ::= ('import' S)? ('module' | 'schema') S 'namespace'
+
+Annotation
+         ::= '%' EQName ?
+
+OptionDecl
+         ::= 'declare' S ( ( 'decimal-format' | 'option' ) 
+           |  ('default' S 'decimal-format') ) 
+
+Operator ::= '!=' | ':=' | '>=' | '<=' | '=' | '<' | '>' | '-' | '+' | 'div' | '||' | '?'
+
+Variable ::= '$' EQName
+
+Tag      ::= '<' QName
+
+EndTag   ::= '</' QName S? '>'
+
+PragmaContents
+         ::= ( Char* - ( Char* '#' Char* ) )+
+DirCommentContents
+         ::= ( ( Char - '-' ) | '-' ( Char - '-' ) )+
+DirPIContents
+         ::= ( Char* - ( Char* '?' Char* ) )+ 
+CDataSectionContents
+         ::= ( Char+ - ( Char* ']]>' Char* ) ) & ']]'
+           | ( Char+ - ( Char* ']]>' Char* ) ) & $ 
+AttrTest  ::= "@" ( Wildcard | QName )
+Wildcard ::= "*"
+         | (NCName ":" "*")
+         | ("*" ":" NCName)
+         | (BracedURILiteral "*")
+EQName   ::= QName
+           | URIQualifiedName
+URIQualifiedName
+         ::= BracedURILiteral NCName
+BracedURILiteral
+         ::= 'Q' '{' (PredefinedEntityRef | CharRef  | [^&{}] )* '}'
+URILiteral
+         ::= StringLiteral
+IntegerLiteral
+         ::= Digits
+DecimalLiteral
+         ::= '.' Digits
+           | Digits '.' [0-9]*
+          /* ws: explicit */
+DoubleLiteral
+         ::= ( '.' Digits | Digits ( '.' [0-9]* )? ) [Ee] [+#x002D]? Digits
+          /* ws: explicit */
+PredefinedEntityRef
+         ::= '&' ( 'lt' | 'gt' | 'amp' | 'quot' | 'apos' ) ';'
+          /* ws: explicit */
+EscapeQuot
+         ::= '""'
+EscapeApos
+         ::= "''"
+QuotChar ::= (Char - ["&])+
+AposChar ::= (Char - [&'])+
+ElementContentChar
+         ::= (Char - [&<{}])+
+QuotAttrContentChar
+         ::= (Char - ["&<{}])+
+AposAttrContentChar
+         ::= (Char - [&'<{}])+
+PITarget ::= NCName - ( ( 'X' | 'x' ) ( 'M' | 'm' ) ( 'L' | 'l' ) )
+Name     ::= NameStartChar NameChar*
+NameStartChar
+         ::= [:A-Z_a-z#x00C0-#x00D6#x00D8-#x00F6#x00F8-#x02FF#x0370-#x037D#x037F-#x1FFF#x200C-#x200D#x2070-#x218F#x2C00-#x2FEF#x3001-#xD7FF#xF900-#xFDCF#xFDF0-#xFFFD#x10000-#xEFFFF]
+NameChar ::= NameStartChar
+           | [-.0-9#x00B7#x0300-#x036F#x203F-#x2040]
+NCName   ::= Name - ( Char* (':' | '.') Char* )
+Char     ::= [#x0009#x000A#x000D#x0020-#xD7FF#xE000-#xFFFD#x10000-#x10FFFF]
+QName    ::= PrefixedName
+           | UnprefixedName
+PrefixedName
+         ::= Prefix ':' LocalPart
+UnprefixedName
+         ::= LocalPart
+Prefix   ::= NCName
+LocalPart
+         ::= NCName
+S        ::= [#x0009#x000A#x000D#x0020]+
+CharRef  ::= '&#' [0-9]+ ';'
+           | '&#x' [0-9A-Fa-f]+ ';'
+Digits   ::= [0-9]+
+CommentContents
+         ::= ( Char+ - ( Char* ( '(:' | ':)' ) Char* ) ) & '(:'
+           | ( Char+ - ( Char* ( '(:' | ':)' ) Char* ) ) & $
+           | ( ( Char+ - ( Char* ( '(:' | ':)' ) Char* ) ) - ( Char* '(' ) ) & ':'
+DocTag   ::= ' @' NCName?
+DocCommentContents
+         ::= ( ( Char+ - ( Char* ( '(:' | ':)' | ' @' ) Char* ) ) - ( Char* '(' ) ) & ':'
+           |   ( Char+ - ( Char* ( '(:' | ':)' | ' @' ) Char* ) )                   & '(:'
+           |   ( Char+ - ( Char* ( '(:' | ':)' | ' @' ) Char* ) )                   & ' @'
+           | ( Char+ - ( Char* ( '(:' | ':)' | ' @') Char* ) ) & $
+EOF      ::= $
+NonNCNameChar
+          ::= $
+            | ':'
+            | '.'
+            | ( Char - NameChar )
+DelimitingChar
+          ::= NonNCNameChar
+            | '-'
+            | '.'
+DelimitingChar
+           \\ IntegerLiteral DecimalLiteral DoubleLiteral 
+NonNCNameChar
+           \\ EQName^Token QName NCName^Token 'NaN' 'after' 'all'
+              'allowing' 'ancestor' 'ancestor-or-self' 'and' 'any' 
+              'append' 'array' 'as' 'ascending' 'at' 'attribute' 
+              'base-uri' 'before' 'boundary-space' 'break' 'by' 'case'
+              'cast' 'castable' 'catch' 'check' 'child' 'collation' 
+              'collection' 'comment' 'constraint' 'construction'
+              'contains' 'content' 'context' 'continue' 'copy' 
+              'copy-namespaces' 'count' 'decimal-format' 
+              'decimal-separator' 'declare' 'default' 'delete' 
+              'descendant' 'descendant-or-self' 'descending' 
+              'diacritics' 'different' 'digit' 'distance' 'div' 
+              'document' 'document-node' 'element' 'else' 'empty'
+              'empty-sequence' 'encoding' 'end' 'entire' 'eq' 'every'
+              'exactly' 'except' 'exit' 'external' 'first' 'following'
+              'following-sibling' 'for' 'foreach' 'foreign' 'from'
+              'ft-option' 'ftand' 'ftnot' 'ftor' 'function' 'ge'
+              'greatest' 'group' 'grouping-separator' 'gt' 'idiv' 'if'
+              'import' 'in' 'index' 'infinity' 'inherit' 'insensitive'
+              'insert' 'instance' 'integrity' 'intersect' 'into' 'is'
+              'item' 'json' 'json-item' 'key' 'language' 'last' 'lax'
+              'le' 'least' 'let' 'levels' 'loop' 'lowercase' 'lt'
+              'minus-sign' 'mod' 'modify' 'module' 'most' 'namespace'
+              'namespace-node' 'ne' 'next' 'no' 'no-inherit'
+              'no-preserve' 'node' 'nodes' 'not' 'object' 'occurs'
+              'of' 'on' 'only' 'option' 'or' 'order' 'ordered'
+              'ordering' 'paragraph' 'paragraphs' 'parent'
+              'pattern-separator' 'per-mille' 'percent' 'phrase'
+              'position' 'preceding' 'preceding-sibling' 'preserve'
+              'previous' 'processing-instruction' 'relationship'
+              'rename' 'replace' 'return' 'returning' 'revalidation'
+              'same' 'satisfies' 'schema' 'schema-attribute'
+              'schema-element' 'score' 'self' 'sensitive' 'sentence'
+              'sentences' 'skip' 'sliding' 'some' 'stable' 'start'
+              'stemming' 'stop' 'strict' 'strip' 'structured-item'
+              'switch' 'text' 'then' 'thesaurus' 'times' 'to'
+              'treat' 'try' 'tumbling' 'type' 'typeswitch' 'union'
+              'unique' 'unordered' 'updating' 'uppercase' 'using'
+              'validate' 'value' 'variable' 'version' 'weight'
+              'when' 'where' 'while' 'wildcards' 'window' 'with'
+              'without' 'word' 'words' 'xquery' 'zero-digit'
+'*'       << Wildcard '*'^OccurrenceIndicator
+EQName^Token
+          << 'after' 'ancestor' 'ancestor-or-self' 'and' 'as' 'ascending' 'attribute' 'before' 'case' 'cast' 'castable' 'child' 'collation' 'comment' 'copy' 'count' 'declare' 'default' 'delete' 'descendant' 'descendant-or-self' 'descending' 'div' 'document' 'document-node' 'element' 'else' 'empty' 'empty-sequence' 'end' 'eq' 'every' 'except' 'first' 'following' 'following-sibling' 'for' 'function' 'ge' 'group' 'gt' 'idiv' 'if' 'import' 'insert' 'instance' 'intersect' 'into' 'is' 'item' 'last' 'le' 'let' 'lt' 'mod' 'modify' 'module' 'namespace' 'namespace-node' 'ne' 'node' 'only' 'or' 'order' 'ordered' 'parent' 'preceding' 'preceding-sibling' 'processing-instruction' 'rename' 'replace' 'return' 'satisfies' 'schema-attribute' 'schema-element' 'self' 'some' 'stable' 'start' 'switch' 'text' 'to' 'treat' 'try' 'typeswitch' 'union' 'unordered' 'validate' 'where' 'with' 'xquery' 'contains' 'paragraphs' 'sentences' 'times' 'words' 'by' 'collection' 'allowing' 'at' 'base-uri' 'boundary-space
 ' 'break' 'catch' 'construction' 'context' 'continue' 'copy-namespaces' 'decimal-format' 'encoding' 'exit' 'external' 'ft-option' 'in' 'index' 'integrity' 'lax' 'nodes' 'option' 'ordering' 'revalidation' 'schema' 'score' 'sliding' 'strict' 'tumbling' 'type' 'updating' 'value' 'variable' 'version' 'while' 'constraint' 'loop' 'returning' 'append' 'array' 'json-item' 'object' 'structured-item'
+NCName^Token
+          << 'after' 'and' 'as' 'ascending' 'before' 'case' 'cast' 'castable' 'collation' 'count' 'default' 'descending' 'div' 'else' 'empty' 'end' 'eq' 'except' 'for' 'ge' 'group' 'gt' 'idiv' 'instance' 'intersect' 'into' 'is' 'le' 'let' 'lt' 'mod' 'modify' 'ne' 'only' 'or' 'order' 'return' 'satisfies' 'stable' 'start' 'to' 'treat' 'union' 'where' 'with' 'contains' 'paragraphs' 'sentences' 'times' 'words' 'by' 'ancestor' 'ancestor-or-self' 'attribute' 'child' 'comment' 'copy' 'declare' 'delete' 'descendant' 'descendant-or-self' 'document' 'document-node' 'element' 'empty-sequence' 'every' 'first' 'following' 'following-sibling' 'function' 'if' 'import' 'insert' 'item' 'last' 'module' 'namespace' 'namespace-node' 'node' 'ordered' 'parent' 'preceding' 'preceding-sibling' 'processing-instruction' 'rename' 'replace' 'schema-attribute' 'schema-element' 'self' 'some' 'switch' 'text' 'try' 'typeswitch' 'unordered' 'validate' 'variable' 'xquery' 'allowing' 'at' 'base-uri' 'boundary-space' 
 'break' 'catch' 'construction' 'context' 'continue' 'copy-namespaces' 'decimal-format' 'encoding' 'exit' 'external' 'ft-option' 'in' 'index' 'integrity' 'lax' 'nodes' 'option' 'ordering' 'revalidation' 'schema' 'score' 'sliding' 'strict' 'tumbling' 'type' 'updating' 'value' 'version' 'while' 'constraint' 'loop' 'returning'
+
+<?ENCORE?>
+
+<?xqlint
+});
+?>