|
| 1 | +/* ***** BEGIN LICENSE BLOCK ***** |
| 2 | + * Distributed under the BSD license: |
| 3 | + * |
| 4 | + * Copyright (c) 2010, Ajax.org B.V. |
| 5 | + * All rights reserved. |
| 6 | + * |
| 7 | + * Redistribution and use in source and binary forms, with or without |
| 8 | + * modification, are permitted provided that the following conditions are met: |
| 9 | + * * Redistributions of source code must retain the above copyright |
| 10 | + * notice, this list of conditions and the following disclaimer. |
| 11 | + * * Redistributions in binary form must reproduce the above copyright |
| 12 | + * notice, this list of conditions and the following disclaimer in the |
| 13 | + * documentation and/or other materials provided with the distribution. |
| 14 | + * * Neither the name of Ajax.org B.V. nor the |
| 15 | + * names of its contributors may be used to endorse or promote products |
| 16 | + * derived from this software without specific prior written permission. |
| 17 | + * |
| 18 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 19 | + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 20 | + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 21 | + * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY |
| 22 | + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 23 | + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 24 | + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 25 | + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 | + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 27 | + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | + * |
| 29 | + * ***** END LICENSE BLOCK ***** */ |
| 30 | + |
| 31 | +define(function(require, exports, module) { |
| 32 | +"use strict"; |
| 33 | + |
| 34 | +var oop = require("../lib/oop"); |
| 35 | +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; |
| 36 | + |
| 37 | +var GmqlHighlightRules = function() { |
| 38 | + |
| 39 | + var keywords = ( |
| 40 | + "select|project|extend|group|merge|order" //relational unary operations |
| 41 | + + "|sort" // ?do we have? //relational unary operations |
| 42 | + + "|union|difference" //relational binary operations |
| 43 | + + "|cover|flat|summit|histogram|map|join" //domain specific operations |
| 44 | + + "|materialize" //utility operations |
| 45 | + ); |
| 46 | + |
| 47 | + var builtinConstants = ( |
| 48 | + "true|false|distance|mindist|mindistance|dle|dge|md|any|all|start|stop|chr|strand|left|right|up|down|downstream|upstream" |
| 49 | + + "|and|or|not|as|in|allbut" |
| 50 | + + "|count|bag|sum|avg|min|max|median|std" |
| 51 | + + "|cat|contig" |
| 52 | + ); |
| 53 | + |
| 54 | + var builtinFunctions = ( |
| 55 | + "region|semijoin" // SELECT |
| 56 | + + "|metadata|region_update|metadata_update" // PROJECT |
| 57 | + + "|meta_aggregate|region_group|region_aggregate" //GROUP |
| 58 | + + "|groupby" // MERGE |
| 59 | + + "|desc|meta_top|meta_topg|region_order|region_top|region_topg|" // ORDER |
| 60 | + + "|groupby" // MERGE |
| 61 | + + "|joinby" //DIFFERENCE |
| 62 | + + "|aggregate" //COVER(flat/summit/histogram |
| 63 | + + "|output" //JOIN |
| 64 | + + "|into" //MATERIALIZE |
| 65 | + //+ "|parser|region_modifier|meta_modifier|meta_project" |
| 66 | + ); |
| 67 | + |
| 68 | + var dataTypes = ( |
| 69 | + "int|numeric|decimal|date|varchar|char|bigint|float|double|bit|binary|text|set|timestamp|" + |
| 70 | + "money|real|number|integer" |
| 71 | + ); |
| 72 | + |
| 73 | + var keywordMapper = this.createKeywordMapper({ |
| 74 | + "support.function": builtinFunctions, |
| 75 | + "keyword": keywords, |
| 76 | + "constant.language": builtinConstants, |
| 77 | + "storage.type": dataTypes |
| 78 | + }, "identifier", true); |
| 79 | + |
| 80 | + this.$rules = { |
| 81 | + "start" : [ { |
| 82 | + token : "comment", |
| 83 | + regex : "#.*$" |
| 84 | + }, { |
| 85 | + token : "string", // " string |
| 86 | + regex : '".*?"' |
| 87 | + }, { |
| 88 | + token : "string", // ' string |
| 89 | + regex : "'.*?'" |
| 90 | + }, { |
| 91 | + token : "constant.numeric", // float |
| 92 | + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" |
| 93 | + }, { |
| 94 | + token : keywordMapper, |
| 95 | + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" |
| 96 | + }, { |
| 97 | + token : "keyword.operator", |
| 98 | + regex : "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|=|,|;|:" |
| 99 | + }, { |
| 100 | + token : "paren.lparen", |
| 101 | + regex : "[\\(]" |
| 102 | + }, { |
| 103 | + token : "paren.rparen", |
| 104 | + regex : "[\\)]" |
| 105 | + }, { |
| 106 | + token : "text", |
| 107 | + regex : "\\s+" |
| 108 | + } ] |
| 109 | + }; |
| 110 | + this.normalizeRules(); |
| 111 | +}; |
| 112 | + |
| 113 | +oop.inherits(GmqlHighlightRules, TextHighlightRules); |
| 114 | + |
| 115 | +exports.GmqlHighlightRules = GmqlHighlightRules; |
| 116 | +}); |
| 117 | + |
0 commit comments