Skip to content
Snippets Groups Projects
Commit c49bb5fe authored by Christian Gruen's avatar Christian Gruen Committed by Marijn Haverbeke
Browse files

[xquery mode] Update keyword list (support for XQ31, XQFT, XQUP)

parent 55aa5066
No related branches found
No related tags found
No related merge requests found
...@@ -29,31 +29,45 @@ CodeMirror.defineMode("xquery", function() { ...@@ -29,31 +29,45 @@ CodeMirror.defineMode("xquery", function() {
// kwObj is what is return from this function at the end // kwObj is what is return from this function at the end
var kwObj = { var kwObj = {
'if': A, 'switch': A, 'while': A, 'for': A, ',': punctuation
'else': B, 'then': B, 'try': B, 'finally': B, 'catch': B,
'element': C, 'attribute': C, 'let': C, 'implements': C, 'import': C, 'module': C, 'namespace': C,
'return': C, 'super': C, 'this': C, 'throws': C, 'where': C, 'private': C,
',': punctuation,
'null': atom, 'fn:false()': atom, 'fn:true()': atom
}; };
// a list of 'basic' keywords. For each add a property to kwObj with the value of // a list of 'basic' keywords. For each add a property to kwObj with the value of
// {type: basic[i], style: "keyword"} e.g. 'after' --> {type: "after", style: "keyword"} // {type: basic[i], style: "keyword"} e.g. 'after' --> {type: "after", style: "keyword"}
var basic = ['after','ancestor','ancestor-or-self','and','as','ascending','assert','attribute','before', var basic = ['after', 'all', 'allowing', 'ancestor', 'ancestor-or-self', 'any', 'array', 'as',
'by','case','cast','child','comment','declare','default','define','descendant','descendant-or-self', 'ascending', 'at', 'attribute', 'base-uri', 'before', 'boundary-space', 'by', 'case', 'cast',
'descending','document','document-node','element','else','eq','every','except','external','following', 'castable', 'catch', 'child', 'collation', 'comment', 'construction', 'contains', 'content',
'following-sibling','follows','for','function','if','import','in','instance','intersect','item', 'context', 'copy', 'copy-namespaces', 'count', 'decimal-format', 'declare', 'default', 'delete',
'let','module','namespace','node','node','of','only','or','order','parent','precedes','preceding', 'descendant', 'descendant-or-self', 'descending', 'diacritics', 'different', 'distance',
'preceding-sibling','processing-instruction','ref','return','returns','satisfies','schema','schema-element', 'document', 'document-node', 'element', 'else', 'empty', 'empty-sequence', 'encoding', 'end',
'self','some','sortby','stable','text','then','to','treat','typeswitch','union','variable','version','where', 'entire', 'every', 'exactly', 'except', 'external', 'first', 'following', 'following-sibling',
'xquery', 'empty-sequence']; 'for', 'from', 'ftand', 'ftnot', 'ft-option', 'ftor', 'function', 'fuzzy', 'greatest', 'group',
'if', 'import', 'in', 'inherit', 'insensitive', 'insert', 'instance', 'intersect', 'into',
'invoke', 'is', 'item', 'language', 'last', 'lax', 'least', 'let', 'levels', 'lowercase', 'map',
'modify', 'module', 'most', 'namespace', 'next', 'no', 'node', 'nodes', 'no-inherit',
'no-preserve', 'not', 'occurs', 'of', 'only', 'option', 'order', 'ordered', 'ordering',
'paragraph', 'paragraphs', 'parent', 'phrase', 'preceding', 'preceding-sibling', 'preserve',
'previous', 'processing-instruction', 'relationship', 'rename', 'replace', 'return',
'revalidation', 'same', 'satisfies', 'schema', 'schema-attribute', 'schema-element', 'score',
'self', 'sensitive', 'sentence', 'sentences', 'sequence', 'skip', 'sliding', 'some', 'stable',
'start', 'stemming', 'stop', 'strict', 'strip', 'switch', 'text', 'then', 'thesaurus', 'times',
'to', 'transform', 'treat', 'try', 'tumbling', 'type', 'typeswitch', 'union', 'unordered',
'update', 'updating', 'uppercase', 'using', 'validate', 'value', 'variable', 'version',
'weight', 'when', 'where', 'wildcards', 'window', 'with', 'without', 'word', 'words', 'xquery'];
for(var i=0, l=basic.length; i < l; i++) { kwObj[basic[i]] = kw(basic[i]);}; for(var i=0, l=basic.length; i < l; i++) { kwObj[basic[i]] = kw(basic[i]);};
// a list of types. For each add a property to kwObj with the value of // a list of types. For each add a property to kwObj with the value of
// {type: "atom", style: "atom"} // {type: "atom", style: "atom"}
var types = ['xs:string', 'xs:float', 'xs:decimal', 'xs:double', 'xs:integer', 'xs:boolean', 'xs:date', 'xs:dateTime', var types = ['xs:anyAtomicType', 'xs:anySimpleType', 'xs:anyType', 'xs:anyURI',
'xs:time', 'xs:duration', 'xs:dayTimeDuration', 'xs:time', 'xs:yearMonthDuration', 'numeric', 'xs:hexBinary', 'xs:base64Binary', 'xs:boolean', 'xs:byte', 'xs:date', 'xs:dateTime', 'xs:dateTimeStamp',
'xs:base64Binary', 'xs:anyURI', 'xs:QName', 'xs:byte','xs:boolean','xs:anyURI','xf:yearMonthDuration']; 'xs:dayTimeDuration', 'xs:decimal', 'xs:double', 'xs:duration', 'xs:ENTITIES', 'xs:ENTITY',
'xs:float', 'xs:gDay', 'xs:gMonth', 'xs:gMonthDay', 'xs:gYear', 'xs:gYearMonth', 'xs:hexBinary',
'xs:ID', 'xs:IDREF', 'xs:IDREFS', 'xs:int', 'xs:integer', 'xs:item', 'xs:java', 'xs:language',
'xs:long', 'xs:Name', 'xs:NCName', 'xs:negativeInteger', 'xs:NMTOKEN', 'xs:NMTOKENS',
'xs:nonNegativeInteger', 'xs:nonPositiveInteger', 'xs:normalizedString', 'xs:NOTATION',
'xs:numeric', 'xs:positiveInteger', 'xs:precisionDecimal', 'xs:QName', 'xs:short', 'xs:string',
'xs:time', 'xs:token', 'xs:unsignedByte', 'xs:unsignedInt', 'xs:unsignedLong',
'xs:unsignedShort', 'xs:untyped', 'xs:untypedAtomic', 'xs:yearMonthDuration'];
for(var i=0, l=types.length; i < l; i++) { kwObj[types[i]] = atom;}; for(var i=0, l=types.length; i < l; i++) { kwObj[types[i]] = atom;};
// each operator will add a property to kwObj with value of {type: "operator", style: "keyword"} // each operator will add a property to kwObj with value of {type: "operator", style: "keyword"}
...@@ -102,7 +116,7 @@ CodeMirror.defineMode("xquery", function() { ...@@ -102,7 +116,7 @@ CodeMirror.defineMode("xquery", function() {
} }
// start code block // start code block
else if(ch == "{") { else if(ch == "{") {
pushStateStack(state,{ type: "codeblock"}); pushStateStack(state, { type: "codeblock"});
return null; return null;
} }
// end code block // end code block
...@@ -132,7 +146,7 @@ CodeMirror.defineMode("xquery", function() { ...@@ -132,7 +146,7 @@ CodeMirror.defineMode("xquery", function() {
return chain(stream, state, tokenComment); return chain(stream, state, tokenComment);
} }
// quoted string // quoted string
else if ( !isEQName && (ch === '"' || ch === "'")) else if (!isEQName && (ch === '"' || ch === "'"))
return chain(stream, state, tokenString(ch)); return chain(stream, state, tokenString(ch));
// variable // variable
else if(ch === "$") { else if(ch === "$") {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment