21
if (typeof exports == "object" && typeof module == "object")
22
mod(require("../../lib/codemirror"));
23
else if (typeof define == "function" && define.amd)
24
define(["../../lib/codemirror"], mod);
27
})(function(CodeMirror) {
30
CodeMirror.defineMode("asterisk", function() {
31
var atoms = ["exten", "same", "include","ignorepat","switch"],
32
dpcmd = ["#include","#exec"],
34
"addqueuemember","adsiprog","aelsub","agentlogin","agentmonitoroutgoing","agi",
35
"alarmreceiver","amd","answer","authenticate","background","backgrounddetect",
36
"bridge","busy","callcompletioncancel","callcompletionrequest","celgenuserevent",
37
"changemonitor","chanisavail","channelredirect","chanspy","clearhash","confbridge",
38
"congestion","continuewhile","controlplayback","dahdiacceptr2call","dahdibarge",
39
"dahdiras","dahdiscan","dahdisendcallreroutingfacility","dahdisendkeypadfacility",
40
"datetime","dbdel","dbdeltree","deadagi","dial","dictate","directory","disa",
41
"dumpchan","eagi","echo","endwhile","exec","execif","execiftime","exitwhile","extenspy",
42
"externalivr","festival","flash","followme","forkcdr","getcpeid","gosub","gosubif",
43
"goto","gotoif","gotoiftime","hangup","iax2provision","ices","importvar","incomplete",
44
"ivrdemo","jabberjoin","jabberleave","jabbersend","jabbersendgroup","jabberstatus",
45
"jack","log","macro","macroexclusive","macroexit","macroif","mailboxexists","meetme",
46
"meetmeadmin","meetmechanneladmin","meetmecount","milliwatt","minivmaccmess","minivmdelete",
47
"minivmgreet","minivmmwi","minivmnotify","minivmrecord","mixmonitor","monitor","morsecode",
48
"mp3player","mset","musiconhold","nbscat","nocdr","noop","odbc","odbc","odbcfinish",
49
"originate","ospauth","ospfinish","osplookup","ospnext","page","park","parkandannounce",
50
"parkedcall","pausemonitor","pausequeuemember","pickup","pickupchan","playback","playtones",
51
"privacymanager","proceeding","progress","queue","queuelog","raiseexception","read","readexten",
52
"readfile","receivefax","receivefax","receivefax","record","removequeuemember",
53
"resetcdr","retrydial","return","ringing","sayalpha","saycountedadj","saycountednoun",
54
"saycountpl","saydigits","saynumber","sayphonetic","sayunixtime","senddtmf","sendfax",
55
"sendfax","sendfax","sendimage","sendtext","sendurl","set","setamaflags",
56
"setcallerpres","setmusiconhold","sipaddheader","sipdtmfmode","sipremoveheader","skel",
57
"slastation","slatrunk","sms","softhangup","speechactivategrammar","speechbackground",
58
"speechcreate","speechdeactivategrammar","speechdestroy","speechloadgrammar","speechprocessingsound",
59
"speechstart","speechunloadgrammar","stackpop","startmusiconhold","stopmixmonitor","stopmonitor",
60
"stopmusiconhold","stopplaytones","system","testclient","testserver","transfer","tryexec",
61
"trysystem","unpausemonitor","unpausequeuemember","userevent","verbose","vmauthenticate",
62
"vmsayname","voicemail","voicemailmain","wait","waitexten","waitfornoise","waitforring",
63
"waitforsilence","waitmusiconhold","waituntil","while","zapateller"
66
function basicToken(stream,state){
68
var ch = stream.next();
70
if (state.blockComment) {
71
if (ch == "-" && stream.match("-;", true)) {
72
state.blockComment = false;
73
} else if (stream.skipTo("--;")) {
77
state.blockComment = false;
84
if (stream.match("--", true)) {
85
if (!stream.match("-", false)) {
86
state.blockComment = true;
110
stream.eatWhile(/\w/);
111
cur = stream.current();
112
if(dpcmd.indexOf(cur) !== -1) {
119
var ch1 = stream.peek();
127
stream.eatWhile(/\w/);
128
cur = stream.current();
129
if(atoms.indexOf(cur) !== -1) {
130
state.extenStart = true;
132
case 'same': state.extenSame = true; break;
136
state.extenInclude = true;break;
144
startState: function() {
151
extenPriority: false,
152
extenApplication: false
155
token: function(stream, state) {
158
if(stream.eatSpace()) return null;
160
if(state.extenStart){
161
stream.eatWhile(/[^\s]/);
162
cur = stream.current();
163
if(/^=>?$/.test(cur)){
164
state.extenExten = true;
165
state.extenStart = false;
168
state.extenStart = false;
172
} else if(state.extenExten) {
174
state.extenExten = false;
175
state.extenPriority = true;
176
stream.eatWhile(/[^,]/);
177
if(state.extenInclude) {
179
state.extenPriority = false;
180
state.extenInclude = false;
182
if(state.extenSame) {
183
state.extenPriority = false;
184
state.extenSame = false;
185
state.extenApplication = true;
188
} else if(state.extenPriority) {
189
state.extenPriority = false;
190
state.extenApplication = true;
192
if(state.extenSame) return null;
193
stream.eatWhile(/[^,]/);
195
} else if(state.extenApplication) {
196
stream.eatWhile(/,/);
197
cur = stream.current();
198
if(cur === ',') return null;
199
stream.eatWhile(/\w/);
200
cur = stream.current().toLowerCase();
201
state.extenApplication = false;
202
if(apps.indexOf(cur) !== -1){
206
return basicToken(stream,state);
212
blockCommentStart: ";--",
213
blockCommentEnd: "--;",
218
CodeMirror.defineMIME("text/x-asterisk", "asterisk");