LaravelTest

Форк
0
359 строк · 8.5 Кб
1
// CodeMirror, copyright (c) by Marijn Haverbeke and others
2
// Distributed under an MIT license: https://codemirror.net/LICENSE
3

4
(function(mod) {
5
  if (typeof exports == "object" && typeof module == "object") // CommonJS
6
    mod(require("../../lib/codemirror"));
7
  else if (typeof define == "function" && define.amd) // AMD
8
    define(["../../lib/codemirror"], mod);
9
  else // Plain browser env
10
    mod(CodeMirror);
11
})(function(CodeMirror) {
12
"use strict";
13

14
CodeMirror.defineMode('mllike', function(_config, parserConfig) {
15
  var words = {
16
    'as': 'keyword',
17
    'do': 'keyword',
18
    'else': 'keyword',
19
    'end': 'keyword',
20
    'exception': 'keyword',
21
    'fun': 'keyword',
22
    'functor': 'keyword',
23
    'if': 'keyword',
24
    'in': 'keyword',
25
    'include': 'keyword',
26
    'let': 'keyword',
27
    'of': 'keyword',
28
    'open': 'keyword',
29
    'rec': 'keyword',
30
    'struct': 'keyword',
31
    'then': 'keyword',
32
    'type': 'keyword',
33
    'val': 'keyword',
34
    'while': 'keyword',
35
    'with': 'keyword'
36
  };
37

38
  var extraWords = parserConfig.extraWords || {};
39
  for (var prop in extraWords) {
40
    if (extraWords.hasOwnProperty(prop)) {
41
      words[prop] = parserConfig.extraWords[prop];
42
    }
43
  }
44
  var hintWords = [];
45
  for (var k in words) { hintWords.push(k); }
46
  CodeMirror.registerHelper("hintWords", "mllike", hintWords);
47

48
  function tokenBase(stream, state) {
49
    var ch = stream.next();
50

51
    if (ch === '"') {
52
      state.tokenize = tokenString;
53
      return state.tokenize(stream, state);
54
    }
55
    if (ch === '{') {
56
      if (stream.eat('|')) {
57
        state.longString = true;
58
        state.tokenize = tokenLongString;
59
        return state.tokenize(stream, state);
60
      }
61
    }
62
    if (ch === '(') {
63
      if (stream.match(/^\*(?!\))/)) {
64
        state.commentLevel++;
65
        state.tokenize = tokenComment;
66
        return state.tokenize(stream, state);
67
      }
68
    }
69
    if (ch === '~' || ch === '?') {
70
      stream.eatWhile(/\w/);
71
      return 'variable-2';
72
    }
73
    if (ch === '`') {
74
      stream.eatWhile(/\w/);
75
      return 'quote';
76
    }
77
    if (ch === '/' && parserConfig.slashComments && stream.eat('/')) {
78
      stream.skipToEnd();
79
      return 'comment';
80
    }
81
    if (/\d/.test(ch)) {
82
      if (ch === '0' && stream.eat(/[bB]/)) {
83
        stream.eatWhile(/[01]/);
84
      } if (ch === '0' && stream.eat(/[xX]/)) {
85
        stream.eatWhile(/[0-9a-fA-F]/)
86
      } if (ch === '0' && stream.eat(/[oO]/)) {
87
        stream.eatWhile(/[0-7]/);
88
      } else {
89
        stream.eatWhile(/[\d_]/);
90
        if (stream.eat('.')) {
91
          stream.eatWhile(/[\d]/);
92
        }
93
        if (stream.eat(/[eE]/)) {
94
          stream.eatWhile(/[\d\-+]/);
95
        }
96
      }
97
      return 'number';
98
    }
99
    if ( /[+\-*&%=<>!?|@\.~:]/.test(ch)) {
100
      return 'operator';
101
    }
102
    if (/[\w\xa1-\uffff]/.test(ch)) {
103
      stream.eatWhile(/[\w\xa1-\uffff]/);
104
      var cur = stream.current();
105
      return words.hasOwnProperty(cur) ? words[cur] : 'variable';
106
    }
107
    return null
108
  }
109

110
  function tokenString(stream, state) {
111
    var next, end = false, escaped = false;
112
    while ((next = stream.next()) != null) {
113
      if (next === '"' && !escaped) {
114
        end = true;
115
        break;
116
      }
117
      escaped = !escaped && next === '\\';
118
    }
119
    if (end && !escaped) {
120
      state.tokenize = tokenBase;
121
    }
122
    return 'string';
123
  };
124

125
  function tokenComment(stream, state) {
126
    var prev, next;
127
    while(state.commentLevel > 0 && (next = stream.next()) != null) {
128
      if (prev === '(' && next === '*') state.commentLevel++;
129
      if (prev === '*' && next === ')') state.commentLevel--;
130
      prev = next;
131
    }
132
    if (state.commentLevel <= 0) {
133
      state.tokenize = tokenBase;
134
    }
135
    return 'comment';
136
  }
137

138
  function tokenLongString(stream, state) {
139
    var prev, next;
140
    while (state.longString && (next = stream.next()) != null) {
141
      if (prev === '|' && next === '}') state.longString = false;
142
      prev = next;
143
    }
144
    if (!state.longString) {
145
      state.tokenize = tokenBase;
146
    }
147
    return 'string';
148
  }
149

150
  return {
151
    startState: function() {return {tokenize: tokenBase, commentLevel: 0, longString: false};},
152
    token: function(stream, state) {
153
      if (stream.eatSpace()) return null;
154
      return state.tokenize(stream, state);
155
    },
156

157
    blockCommentStart: "(*",
158
    blockCommentEnd: "*)",
159
    lineComment: parserConfig.slashComments ? "//" : null
160
  };
161
});
162

163
CodeMirror.defineMIME('text/x-ocaml', {
164
  name: 'mllike',
165
  extraWords: {
166
    'and': 'keyword',
167
    'assert': 'keyword',
168
    'begin': 'keyword',
169
    'class': 'keyword',
170
    'constraint': 'keyword',
171
    'done': 'keyword',
172
    'downto': 'keyword',
173
    'external': 'keyword',
174
    'function': 'keyword',
175
    'initializer': 'keyword',
176
    'lazy': 'keyword',
177
    'match': 'keyword',
178
    'method': 'keyword',
179
    'module': 'keyword',
180
    'mutable': 'keyword',
181
    'new': 'keyword',
182
    'nonrec': 'keyword',
183
    'object': 'keyword',
184
    'private': 'keyword',
185
    'sig': 'keyword',
186
    'to': 'keyword',
187
    'try': 'keyword',
188
    'value': 'keyword',
189
    'virtual': 'keyword',
190
    'when': 'keyword',
191

192
    // builtins
193
    'raise': 'builtin',
194
    'failwith': 'builtin',
195
    'true': 'builtin',
196
    'false': 'builtin',
197

198
    // Pervasives builtins
199
    'asr': 'builtin',
200
    'land': 'builtin',
201
    'lor': 'builtin',
202
    'lsl': 'builtin',
203
    'lsr': 'builtin',
204
    'lxor': 'builtin',
205
    'mod': 'builtin',
206
    'or': 'builtin',
207

208
    // More Pervasives
209
    'raise_notrace': 'builtin',
210
    'trace': 'builtin',
211
    'exit': 'builtin',
212
    'print_string': 'builtin',
213
    'print_endline': 'builtin',
214

215
     'int': 'type',
216
     'float': 'type',
217
     'bool': 'type',
218
     'char': 'type',
219
     'string': 'type',
220
     'unit': 'type',
221

222
     // Modules
223
     'List': 'builtin'
224
  }
225
});
226

227
CodeMirror.defineMIME('text/x-fsharp', {
228
  name: 'mllike',
229
  extraWords: {
230
    'abstract': 'keyword',
231
    'assert': 'keyword',
232
    'base': 'keyword',
233
    'begin': 'keyword',
234
    'class': 'keyword',
235
    'default': 'keyword',
236
    'delegate': 'keyword',
237
    'do!': 'keyword',
238
    'done': 'keyword',
239
    'downcast': 'keyword',
240
    'downto': 'keyword',
241
    'elif': 'keyword',
242
    'extern': 'keyword',
243
    'finally': 'keyword',
244
    'for': 'keyword',
245
    'function': 'keyword',
246
    'global': 'keyword',
247
    'inherit': 'keyword',
248
    'inline': 'keyword',
249
    'interface': 'keyword',
250
    'internal': 'keyword',
251
    'lazy': 'keyword',
252
    'let!': 'keyword',
253
    'match': 'keyword',
254
    'member': 'keyword',
255
    'module': 'keyword',
256
    'mutable': 'keyword',
257
    'namespace': 'keyword',
258
    'new': 'keyword',
259
    'null': 'keyword',
260
    'override': 'keyword',
261
    'private': 'keyword',
262
    'public': 'keyword',
263
    'return!': 'keyword',
264
    'return': 'keyword',
265
    'select': 'keyword',
266
    'static': 'keyword',
267
    'to': 'keyword',
268
    'try': 'keyword',
269
    'upcast': 'keyword',
270
    'use!': 'keyword',
271
    'use': 'keyword',
272
    'void': 'keyword',
273
    'when': 'keyword',
274
    'yield!': 'keyword',
275
    'yield': 'keyword',
276

277
    // Reserved words
278
    'atomic': 'keyword',
279
    'break': 'keyword',
280
    'checked': 'keyword',
281
    'component': 'keyword',
282
    'const': 'keyword',
283
    'constraint': 'keyword',
284
    'constructor': 'keyword',
285
    'continue': 'keyword',
286
    'eager': 'keyword',
287
    'event': 'keyword',
288
    'external': 'keyword',
289
    'fixed': 'keyword',
290
    'method': 'keyword',
291
    'mixin': 'keyword',
292
    'object': 'keyword',
293
    'parallel': 'keyword',
294
    'process': 'keyword',
295
    'protected': 'keyword',
296
    'pure': 'keyword',
297
    'sealed': 'keyword',
298
    'tailcall': 'keyword',
299
    'trait': 'keyword',
300
    'virtual': 'keyword',
301
    'volatile': 'keyword',
302

303
    // builtins
304
    'List': 'builtin',
305
    'Seq': 'builtin',
306
    'Map': 'builtin',
307
    'Set': 'builtin',
308
    'Option': 'builtin',
309
    'int': 'builtin',
310
    'string': 'builtin',
311
    'not': 'builtin',
312
    'true': 'builtin',
313
    'false': 'builtin',
314

315
    'raise': 'builtin',
316
    'failwith': 'builtin'
317
  },
318
  slashComments: true
319
});
320

321

322
CodeMirror.defineMIME('text/x-sml', {
323
  name: 'mllike',
324
  extraWords: {
325
    'abstype': 'keyword',
326
    'and': 'keyword',
327
    'andalso': 'keyword',
328
    'case': 'keyword',
329
    'datatype': 'keyword',
330
    'fn': 'keyword',
331
    'handle': 'keyword',
332
    'infix': 'keyword',
333
    'infixr': 'keyword',
334
    'local': 'keyword',
335
    'nonfix': 'keyword',
336
    'op': 'keyword',
337
    'orelse': 'keyword',
338
    'raise': 'keyword',
339
    'withtype': 'keyword',
340
    'eqtype': 'keyword',
341
    'sharing': 'keyword',
342
    'sig': 'keyword',
343
    'signature': 'keyword',
344
    'structure': 'keyword',
345
    'where': 'keyword',
346
    'true': 'keyword',
347
    'false': 'keyword',
348

349
    // types
350
    'int': 'builtin',
351
    'real': 'builtin',
352
    'string': 'builtin',
353
    'char': 'builtin',
354
    'bool': 'builtin'
355
  },
356
  slashComments: true
357
});
358

359
});
360

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.