mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-04 20:54:53 -05:00
66 lines
2.3 KiB
JavaScript
66 lines
2.3 KiB
JavaScript
|
define(function(require, exports, module) {
|
||
|
"use strict";
|
||
|
|
||
|
var oop = require("../lib/oop");
|
||
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||
|
|
||
|
var ProtobufHighlightRules = function() {
|
||
|
|
||
|
var builtinTypes = "double|float|int32|int64|uint32|uint64|sint32|" +
|
||
|
"sint64|fixed32|fixed64|sfixed32|sfixed64|bool|" +
|
||
|
"string|bytes";
|
||
|
var keywordDeclaration = "message|required|optional|repeated|package|" +
|
||
|
"import|option|enum";
|
||
|
|
||
|
var keywordMapper = this.createKeywordMapper({
|
||
|
"keyword.declaration.protobuf": keywordDeclaration,
|
||
|
"support.type": builtinTypes
|
||
|
}, "identifier");
|
||
|
|
||
|
this.$rules = {
|
||
|
"start": [{
|
||
|
token: "comment",
|
||
|
regex: /\/\/.*$/
|
||
|
}, {
|
||
|
token: "comment",
|
||
|
regex: /\/\*/,
|
||
|
next: "comment"
|
||
|
}, {
|
||
|
token: "constant",
|
||
|
regex: "<[^>]+>"
|
||
|
}, {
|
||
|
regex: "=",
|
||
|
token: "keyword.operator.assignment.protobuf"
|
||
|
}, {
|
||
|
token : "string", // single line
|
||
|
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
|
||
|
}, {
|
||
|
token : "string", // single line
|
||
|
regex : '[\'](?:(?:\\\\.)|(?:[^\'\\\\]))*?[\']'
|
||
|
}, {
|
||
|
token: "constant.numeric", // hex
|
||
|
regex: "0[xX][0-9a-fA-F]+\\b"
|
||
|
}, {
|
||
|
token: "constant.numeric", // float
|
||
|
regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
||
|
}, {
|
||
|
token: keywordMapper,
|
||
|
regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
||
|
}],
|
||
|
"comment": [{
|
||
|
token: "comment", // closing comment
|
||
|
regex: ".*?\\*\\/",
|
||
|
next: "start"
|
||
|
}, {
|
||
|
token: "comment", // comment spanning whole line
|
||
|
regex: ".+"
|
||
|
}]
|
||
|
};
|
||
|
|
||
|
this.normalizeRules();
|
||
|
};
|
||
|
|
||
|
oop.inherits(ProtobufHighlightRules, TextHighlightRules);
|
||
|
|
||
|
exports.ProtobufHighlightRules = ProtobufHighlightRules;
|
||
|
});
|