5
if (typeof exports == "object" && typeof module == "object")
6
mod(require("../../lib/codemirror"));
7
else if (typeof define == "function" && define.amd)
8
define(["../../lib/codemirror"], mod);
11
})(function(CodeMirror) {
14
function wordRegexp(words) {
15
return new RegExp("^((" + words.join(")|(") + "))\\b", "i");
19
"package", "message", "import", "syntax",
20
"required", "optional", "repeated", "reserved", "default", "extensions", "packed",
21
"bool", "bytes", "double", "enum", "float", "string",
22
"int32", "int64", "uint32", "uint64", "sint32", "sint64", "fixed32", "fixed64", "sfixed32", "sfixed64",
23
"option", "service", "rpc", "returns"
25
var keywords = wordRegexp(keywordArray);
27
CodeMirror.registerHelper("hintWords", "protobuf", keywordArray);
29
var identifiers = new RegExp("^[_A-Za-z\xa1-\uffff][_A-Za-z0-9\xa1-\uffff]*");
31
function tokenBase(stream) {
33
if (stream.eatSpace()) return null;
36
if (stream.match("//")) {
42
if (stream.match(/^[0-9\.+-]/, false)) {
43
if (stream.match(/^[+-]?0x[0-9a-fA-F]+/))
45
if (stream.match(/^[+-]?\d*\.\d+([EeDd][+-]?\d+)?/))
47
if (stream.match(/^[+-]?\d+([EeDd][+-]?\d+)?/))
52
if (stream.match(/^"([^"]|(""))*"/)) { return "string"; }
53
if (stream.match(/^'([^']|(''))*'/)) { return "string"; }
56
if (stream.match(keywords)) { return "keyword"; }
57
if (stream.match(identifiers)) { return "variable"; } ;
64
CodeMirror.defineMode("protobuf", function() {
71
CodeMirror.defineMIME("text/x-protobuf", "protobuf");