Closed m4lvin closed 10 months ago
A first attempt, based off the COBOL rules :wink:
"use strict";
var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var SmcdelHighlightRules = function() {
var keywords = "VARS|LAW|OBS|VALID|WHERE|TRUE"; // TODO: how to include "?"
var builtinConstants = "AND|OR|knows|that|whether|comknow|";
var builtinFunctions = "alice|bob|carol"; // unused
var keywordMapper = this.createKeywordMapper({
"support.function": builtinFunctions,
"keyword": keywords,
"constant.language": builtinConstants
}, "identifier", true);
this.$rules = {
"start" : [ {
token : "comment",
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+"
} ]
};
};
oop.inherits(SmcdelHighlightRules, TextHighlightRules);
exports.SmcdelHighlightRules = SmcdelHighlightRules;
Highlighting keywords such as
OBS
would be nice, and also giving different colors to agents, formula connectives etc.We are using Ace, so according to https://ace.c9.io/#nav=higlighter it should be easy to define our own highlighting mode. See https://ace.c9.io/tool/mode_creator.html and try to find a minimal example.
Other helpful notes: https://github.com/ajaxorg/ace/wiki/Creating-or-Extending-an-Edit-Mode