Skip to content

Commit

Permalink
http-server: add EMG and Pinset syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
agarciadom committed Dec 3, 2024
1 parent b960fb0 commit b62b86f
Show file tree
Hide file tree
Showing 3 changed files with 186 additions and 1 deletion.
93 changes: 93 additions & 0 deletions http-server/src/main/js/emg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import {define} from "ace-builds";

define("ace/mode/emg_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
"use strict";

var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;

var emgHighlightRules = function() {

var keywords = (
"match|onmatch|nomatch|pattern|do|from|pre|post|not|delete|import|for|while|in|and|or|operation|return|var|throw|if|new|else|transaction|abort|break|continue|assert|assertError|not|function|default|switch|case|as|ext|driver|alias|model|breakAll|async|group|nor|xor|implies|$instances"
);

var builtinConstants = (
"true|false|self"
);

var builtinFunctions = (
""
);

var dataTypes = (
"Any|String|Integer|Real|Boolean|Native|Bag|Set|List|Sequence|Map|OrderedSet|Collection|Tuple|ConcurrentBag|ConcurrentMap|ConcurrentSet"
);

var keywordMapper = this.createKeywordMapper({
"support.function": builtinFunctions,
"keyword": keywords,
"constant.language": builtinConstants,
"storage.type": dataTypes
}, "identifier", false);

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: "keyword",
regex: "(@list|@probability)"
}, {
token : keywordMapper,
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "text",
regex : "\\s+"
}]
};
this.normalizeRules();
};

oop.inherits(emgHighlightRules, TextHighlightRules);

exports.emgHighlightRules = emgHighlightRules;
});

define("ace/mode/emg",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/emg_highlight_rules"], function(require, exports, module) {
"use strict";

var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var emgHighlightRules = require("./emg_highlight_rules").emgHighlightRules;

var Mode = function() {
this.HighlightRules = emgHighlightRules;
this.$behaviour = this.$defaultBehaviour;
};
oop.inherits(Mode, TextMode);

(function() {
this.$id = "ace/mode/emg";
this.snippetFileId = "ace/snippets/emg";
}).call(Mode.prototype);

exports.Mode = Mode;

});
4 changes: 3 additions & 1 deletion http-server/src/main/js/highlighting.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ import './etl.js';
import './evl.js';
import './flexmi.js';
import './flock.js';
import './json.js';
import './json.js';
import './emg.js';
import './pinset.js';
90 changes: 90 additions & 0 deletions http-server/src/main/js/pinset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import {define} from "ace-builds";

define("ace/mode/pinset_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
"use strict";

var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;

var pinsetHighlightRules = function() {

var keywords = (
"|dataset|over|from|column|properties|reference|grid|keys|header|body|guard|pre|post|not|delete|import|for|while|in|and|or|operation|return|var|throw|if|new|else|transaction|abort|break|continue|assert|assertError|not|function|default|switch|case|as|ext|driver|alias|model|breakAll|async|group|nor|xor|implies|extends"
);

var builtinConstants = (
"true|false|self"
);

var builtinFunctions = (
""
);

var dataTypes = (
"Any|String|Integer|Real|Boolean|Native|Bag|Set|List|Sequence|Map|OrderedSet|Collection|Tuple|ConcurrentBag|ConcurrentMap|ConcurrentSet"
);

var keywordMapper = this.createKeywordMapper({
"support.function": builtinFunctions,
"keyword": keywords,
"constant.language": builtinConstants,
"storage.type": dataTypes
}, "identifier", false);

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 : "text",
regex : "\\s+"
} ]
};
this.normalizeRules();
};

oop.inherits(pinsetHighlightRules, TextHighlightRules);

exports.pinsetHighlightRules = pinsetHighlightRules;
});

define("ace/mode/pinset",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/pinset_highlight_rules"], function(require, exports, module) {
"use strict";

var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var pinsetHighlightRules = require("./pinset_highlight_rules").pinsetHighlightRules;

var Mode = function() {
this.HighlightRules = pinsetHighlightRules;
this.$behaviour = this.$defaultBehaviour;
};
oop.inherits(Mode, TextMode);

(function() {
this.$id = "ace/mode/pinset";
this.snippetFileId = "ace/snippets/pinset";
}).call(Mode.prototype);

exports.Mode = Mode;

});

0 comments on commit b62b86f

Please sign in to comment.