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
CodeMirror.defineMode("rpm-changes", function() {
15
var headerSeparator = /^-+$/;
16
var headerLine = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ?\d{1,2} \d{2}:\d{2}(:\d{2})? [A-Z]{3,4} \d{4} - /;
17
var simpleEmail = /^[\w+.-]+@[\w.-]+/;
20
token: function(stream) {
22
if (stream.match(headerSeparator)) { return 'tag'; }
23
if (stream.match(headerLine)) { return 'tag'; }
25
if (stream.match(simpleEmail)) { return 'string'; }
32
CodeMirror.defineMIME("text/x-rpm-changes", "rpm-changes");
36
CodeMirror.defineMode("rpm-spec", function() {
37
var arch = /^(i386|i586|i686|x86_64|ppc64le|ppc64|ppc|ia64|s390x|s390|sparc64|sparcv9|sparc|noarch|alphaev6|alpha|hppa|mipsel)/;
39
var preamble = /^[a-zA-Z0-9()]+:/;
40
var section = /^%(debug_package|package|description|prep|build|install|files|clean|changelog|preinstall|preun|postinstall|postun|pretrans|posttrans|pre|post|triggerin|triggerun|verifyscript|check|triggerpostun|triggerprein|trigger)/;
41
var control_flow_complex = /^%(ifnarch|ifarch|if)/;
42
var control_flow_simple = /^%(else|endif)/;
43
var operators = /^(\!|\?|\<\=|\<|\>\=|\>|\=\=|\&\&|\|\|)/;
46
startState: function () {
49
macroParameters: false,
53
token: function (stream, state) {
54
var ch = stream.peek();
55
if (ch == "#") { stream.skipToEnd(); return "comment"; }
58
if (stream.match(preamble)) { return "header"; }
59
if (stream.match(section)) { return "atom"; }
62
if (stream.match(/^\$\w+/)) { return "def"; }
63
if (stream.match(/^\$\{\w+\}/)) { return "def"; }
65
if (stream.match(control_flow_simple)) { return "keyword"; }
66
if (stream.match(control_flow_complex)) {
67
state.controlFlow = true;
70
if (state.controlFlow) {
71
if (stream.match(operators)) { return "operator"; }
72
if (stream.match(/^(\d+)/)) { return "number"; }
73
if (stream.eol()) { state.controlFlow = false; }
76
if (stream.match(arch)) {
77
if (stream.eol()) { state.controlFlow = false; }
82
if (stream.match(/^%[\w]+/)) {
83
if (stream.match('(')) { state.macroParameters = true; }
86
if (state.macroParameters) {
87
if (stream.match(/^\d+/)) { return "number";}
88
if (stream.match(')')) {
89
state.macroParameters = false;
95
if (stream.match(/^%\{\??[\w \-\:\!]+\}/)) {
96
if (stream.eol()) { state.controlFlow = false; }
107
CodeMirror.defineMIME("text/x-rpm-spec", "rpm-spec");