Closed robphoenix closed 5 years ago
Here is one for the ACE code editor
ace.define("ace/mode/epl_highlight_rules",[], function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var EplHighlightRules = function() {
var keywords = (
"after|all|and|any|as|asc|at|between|by|case|context|create|cube|" +
"dataflow|day|days|define|delete|desc|distinct|else|end|end|escape|events|every|every-distinct|expression|" +
"first|for|from|full|group|grouping|having|hour|hours|" +
"in|index|initiated|inner|insert|instanceof|into|irstream|is|istream|" +
"join|last|lastweekday|left|like|limit|" +
"match_recognize|matched|matches|measures|merge|metadatasql|microsecond|microseconds|millisecond|" +
"milliseconds|minute|minutes|month|months|msec|new|not|" +
"offset|on|or|order|outer|output|partition|pattern|" +
"retain-intersection|retain-union|right|rollup|rstream|schema|" +
"sec|second|seconds|select|set|snapshot|some|sql|start|" +
"table|terminated|then|unidirectional|until|update|usec|using|" +
"values|variable|week|weekday|weeks|when|where|while|window|year|years"
);
var builtinConstants = (
"true|false|null"
);
var builtinFunctions = (
"avg|count|first|last|max|min|sum|coalesce|regexp|median|stddev|avedev|window|sorted|minby|maxby|" +
"typeof|cast|current_timestamp|prev|prevtail|prevcount|prevwindow|prior|exists"
);
var dataTypes = (
"bool|boolean|byte|short|int|integer|char|character|float|double|long|string"
);
var keywordMapper = this.createKeywordMapper({
"support.function": builtinFunctions,
"keyword": keywords,
"constant.language": builtinConstants,
"storage.type": dataTypes
}, "identifier", true);
this.$rules = {
"start" : [ {
token : "comment",
regex : "//.*$"
}, {
token : "comment",
start : "/\\*",
end : "\\*/"
}, {
token : "string", // " string
regex : '".*?"'
}, {
token : "string", // ' string
regex : "'.*?'"
}, {
token : "string", // ` string (apache drill)
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+"
} ]
};
this.normalizeRules();
};
oop.inherits(EplHighlightRules, TextHighlightRules);
exports.EplHighlightRules = EplHighlightRules;
});
ace.define("ace/mode/epl",[], function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var EplHighlightRules = require("./epl_highlight_rules").EplHighlightRules;
var Mode = function() {
this.HighlightRules = EplHighlightRules;
this.$behaviour = this.$defaultBehaviour;
};
oop.inherits(Mode, TextMode);
(function() {
this.lineCommentStart = "//";
this.$id = "ace/mode/epl";
}).call(Mode.prototype);
exports.Mode = Mode;
});
(function() {
ace.require(["ace/mode/epl"], function(m) {
if (typeof module == "object") {
module.exports = m;
}
});
})();
thanks @bernhardttom
Hi,
Is there a EPL syntax formatter available? Specifically implemented in JavaScript? Some SQL formatter's work OK, but run into problems with things such as the different comment characters (
//
instead of--
).Thanks.