e45785d75be4c2f53fa20671f372fa6ffab497dd
[Packages/TYPO3.CMS.git] / typo3 / sysext / t3editor / Resources / Public / JavaScript / Mode / typoscript / typoscript.js
1 (function (mod) {
2 if (typeof exports === "object" && typeof module === "object") // CommonJS
3 mod(require("cm/lib/codemirror"));
4 else if (typeof define === "function" && define.amd) // AMD
5 define(["cm/lib/codemirror"], mod);
6 else // Plain browser env
7 mod(CodeMirror);
8 })(function (CodeMirror) {
9 "use strict";
10
11 function expressionAllowed(stream, state, backUp) {
12 return /^(?:operator|sof|keyword c|case|new|export|default|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
13 (state.lastType === "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
14 }
15
16 CodeMirror.defineMode("typoscript", function (config, parserConfig) {
17 var indentUnit = config.indentUnit;
18 var statementIndent = parserConfig.statementIndent;
19 var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
20
21 // Tokenizer
22
23 var keywords = function () {
24 function kw(type) {
25 return {type: type, style: "keyword"};
26 }
27
28 var A = kw("keyword a"), B = kw("keyword b");
29
30 return {
31 '_CSS_DEFAULT_STYLE': kw('_CSS_DEFAULT_STYLE'),
32 '_DEFAULT_PI_VARS': kw('_DEFAULT_PI_VARS'),
33 '_GIFBUILDER': kw('_GIFBUILDER'),
34 '_LOCAL_LANG': kw('_LOCAL_LANG'),
35 '_offset': kw('_offset'),
36 'absRefPrefix': kw('absRefPrefix'),
37 'accessibility': kw('accessibility'),
38 'accessKey': kw('accessKey'),
39 'ACT': B,
40 'ACTIFSUB': B,
41 'ACTIFSUBRO': kw('ACTIFSUBRO'),
42 'ACTRO': B,
43 'addAttributes': kw('addAttributes'),
44 'addExtUrlsAndShortCuts': kw('addExtUrlsAndShortCuts'),
45 'addItems': kw('addItems'),
46 'additionalHeaders': kw('additionalHeaders'),
47 'additionalParams': kw('additionalParams'),
48 'addParams': kw('addParams'),
49 'addQueryString': kw('addQueryString'),
50 'adjustItemsH': kw('adjustItemsH'),
51 'adjustSubItemsH': kw('adjustSubItemsH'),
52 'admPanel': A,
53 'after': kw('after'),
54 'afterImg': kw('afterImg'),
55 'afterImgLink': kw('afterImgLink'),
56 'afterImgTagParams': kw('afterImgTagParams'),
57 'afterROImg': kw('afterROImg'),
58 'afterWrap': kw('afterWrap'),
59 'age': kw('age'),
60 'alertPopups': kw('alertPopups'),
61 'align': kw('align'),
62 'all': B,
63 'allow': kw('allow'),
64 'allowCaching': kw('allowCaching'),
65 'allowedAttribs': kw('allowedAttribs'),
66 'allowedClasses': kw('allowedClasses'),
67 'allowedCols': kw('allowedCols'),
68 'allowedNewTables': kw('allowedNewTables'),
69 'allowTags': kw('allowTags'),
70 'allStdWrap': kw('allStdWrap'),
71 'allWrap': kw('allWrap'),
72 'alt_print': A,
73 'alternativeSortingField': kw('alternativeSortingField'),
74 'alternativeTempPath': kw('alternativeTempPath'),
75 'altIcons': kw('altIcons'),
76 'altImgResource': kw('altImgResource'),
77 'altLabels': kw('altLabels'),
78 'altTarget': kw('altTarget'),
79 'altText': kw('altText'),
80 'altUrl': kw('altUrl'),
81 'altUrl_noDefaultParams': kw('altUrl_noDefaultParams'),
82 'altWrap': kw('altWrap'),
83 'always': kw('always'),
84 'alwaysActivePIDlist': kw('alwaysActivePIDlist'),
85 'alwaysLink': kw('alwaysLink'),
86 'andWhere': kw('andWhere'),
87 'angle': kw('angle'),
88 'antiAlias': kw('antiAlias'),
89 'append': kw('append'),
90 'applyTotalH': kw('applyTotalH'),
91 'applyTotalW': kw('applyTotalW'),
92 'archive': kw('archive'),
93 'ascii': B,
94 'ATagAfterWrap': kw('ATagAfterWrap'),
95 'ATagBeforeWrap': kw('ATagBeforeWrap'),
96 'ATagParams': kw('ATagParams'),
97 'ATagTitle': kw('ATagTitle'),
98 'atLeast': B,
99 'atMost': B,
100 'attribute': kw('attribute'),
101 'auth': A,
102 'autoLevels': kw('autoLevels'),
103 'autonumber': kw('autonumber'),
104 'backColor': kw('backColor'),
105 'background': kw('background'),
106 'baseURL': kw('baseURL'),
107 'BE': B,
108 'be_groups': B,
109 'be_users': B,
110 'before': kw('before'),
111 'beforeImg': kw('beforeImg'),
112 'beforeImgLink': kw('beforeImgLink'),
113 'beforeImgTagParams': kw('beforeImgTagParams'),
114 'beforeROImg': kw('beforeROImg'),
115 'beforeWrap': kw('beforeWrap'),
116 'begin': kw('begin'),
117 'bgCol': kw('bgCol'),
118 'bgImg': kw('bgImg'),
119 'blur': kw('blur'),
120 'bm': kw('bm'),
121 'bodyTag': kw('bodyTag'),
122 'bodyTagAdd': kw('bodyTagAdd'),
123 'bodyTagCObject': kw('bodyTagCObject'),
124 'bodytext': kw('bodytext'),
125 'border': kw('border'),
126 'borderCol': kw('borderCol'),
127 'borderThick': kw('borderThick'),
128 'bottomBackColor': kw('bottomBackColor'),
129 'bottomContent': kw('bottomContent'),
130 'bottomHeight': kw('bottomHeight'),
131 'bottomImg': kw('bottomImg'),
132 'bottomImg_mask': kw('bottomImg_mask'),
133 'BOX': B,
134 'br': kw('br'),
135 'browse': B,
136 'browser': A,
137 'brTag': kw('brTag'),
138 'bullet': kw('bullet'),
139 'bulletlist': kw('bulletlist'),
140 'bullets': B,
141 'bytes': kw('bytes'),
142 'cache': A,
143 'cache_clearAtMidnight': kw('cache_clearAtMidnight'),
144 'cache_period': kw('cache_period'),
145 'caption': kw('caption'),
146 'caption_stdWrap': kw('caption_stdWrap'),
147 'captionHeader': kw('captionHeader'),
148 'captionSplit': kw('captionSplit'),
149 'CARRAY': kw('CARRAY'),
150 'CASE': kw('CASE'),
151 'case': kw('case'),
152 'casesensitiveComp': kw('casesensitiveComp'),
153 'cellpadding': kw('cellpadding'),
154 'cellspacing': kw('cellspacing'),
155 'char': kw('char'),
156 'charcoal': kw('charcoal'),
157 'charMapConfig': kw('charMapConfig'),
158 'CHECK': A,
159 'check': kw('check'),
160 'class': kw('class'),
161 'classesAnchor': kw('classesAnchor'),
162 'classesCharacter': kw('classesCharacter'),
163 'classesImage': kw('classesImage'),
164 'classesParagraph': kw('classesParagraph'),
165 'clear': kw('clear'),
166 'clearCache': kw('clearCache'),
167 'clearCache_disable': kw('clearCache_disable'),
168 'clearCache_pageGrandParent': kw('clearCache_pageGrandParent'),
169 'clearCache_pageSiblingChildren': kw('clearCache_pageSiblingChildren'),
170 'clearCacheCmd': kw('clearCacheCmd'),
171 'clearCacheLevels': kw('clearCacheLevels'),
172 'clearCacheOfPages': kw('clearCacheOfPages'),
173 'clickTitleMode': kw('clickTitleMode'),
174 'clipboardNumberPads': kw('clipboardNumberPads'),
175 'cMargins': kw('cMargins'),
176 'COA': kw('COA'),
177 'COA_INT': kw('COA_INT'),
178 'cObj': A,
179 'COBJ_ARRAY': kw('COBJ_ARRAY'),
180 'cObject': A,
181 'cObjNum': kw('cObjNum'),
182 'collapse': kw('collapse'),
183 'collections': kw('collections'),
184 'color': kw('color'),
185 'color1': kw('color1'),
186 'color2': kw('color2'),
187 'color3': kw('color3'),
188 'color4': kw('color4'),
189 'colors': kw('colors'),
190 'colour': kw('colour'),
191 'colPos_list': kw('colPos_list'),
192 'colRelations': kw('colRelations'),
193 'cols': kw('cols'),
194 'colSpace': kw('colSpace'),
195 'COMMENT': A,
196 'comment_auto': kw('comment_auto'),
197 'commentWrap': kw('commentWrap'),
198 'compX': kw('compX'),
199 'compY': kw('compY'),
200 'conf': kw('conf'),
201 'CONFIG': kw('CONFIG'),
202 'config': A,
203 'CONSTANTS': kw('CONSTANTS'),
204 'constants': kw('constants'),
205 'CONTENT': kw('CONTENT'),
206 'content': A,
207 'content_from_pid_allowOutsideDomain': kw('content_from_pid_allowOutsideDomain'),
208 'contextMenu': kw('contextMenu'),
209 'copy': A,
210 'copyLevels': kw('copyLevels'),
211 'count_HMENU_MENUOBJ': kw('count_HMENU_MENUOBJ'),
212 'count_menuItems': kw('count_menuItems'),
213 'count_MENUOBJ': kw('count_MENUOBJ'),
214 'create': kw('create'),
215 'createFoldersInEB': kw('createFoldersInEB'),
216 'crop': kw('crop'),
217 'csConv': kw('csConv'),
218 'CSS_inlineStyle': A,
219 'CType': kw('CType'),
220 'CUR': B,
221 'CURIFSUB': B,
222 'CURIFSUBRO': B,
223 'current': kw('current'),
224 'CURRO': B,
225 'curUid': kw('curUid'),
226 'cut': A,
227 'cWidth': kw('cWidth'),
228 'data': kw('data'),
229 'dataArray': A,
230 'dataWrap': kw('dataWrap'),
231 'date': kw('date'),
232 'date_stdWrap': kw('date_stdWrap'),
233 'datePrefix': kw('datePrefix'),
234 'dayofmonth': A,
235 'dayofweek': A,
236 'DB': kw('DB'),
237 'db_list': A,
238 'debug': kw('debug'),
239 'debugData': kw('debugData'),
240 'debugFunc': kw('debugFunc'),
241 'debugItemConf': kw('debugItemConf'),
242 'debugRenumberedObject': kw('debugRenumberedObject'),
243 'default': B,
244 'defaultAlign': kw('defaultAlign'),
245 'defaultCmd': kw('defaultCmd'),
246 'defaultFileUploads': kw('defaultFileUploads'),
247 'defaultHeaderType': kw('defaultHeaderType'),
248 'defaultOutput': kw('defaultOutput'),
249 'defaults': kw('defaults'),
250 'defaultType': kw('defaultType'),
251 'delete': kw('delete'),
252 'denyTags': kw('denyTags'),
253 'depth': kw('depth'),
254 'DESC': kw('DESC'),
255 'description': B,
256 'dimensions': kw('dimensions'),
257 'direction': kw('direction'),
258 'directory': B,
259 'directReturn': B,
260 'disableAdvanced': kw('disableAdvanced'),
261 'disableAllHeaderCode': kw('disableAllHeaderCode'),
262 'disableAltText': kw('disableAltText'),
263 'disableBodyTag': kw('disableBodyTag'),
264 'disableCacheSelector': kw('disableCacheSelector'),
265 'disableCharsetHeader': kw('disableCharsetHeader'),
266 'disabled': kw('disabled'),
267 'disableDelete': kw('disableDelete'),
268 'disableDocSelector': kw('disableDocSelector'),
269 'disableHideAtCopy': kw('disableHideAtCopy'),
270 'disableItems': kw('disableItems'),
271 'disableNewContentElementWizard': kw('disableNewContentElementWizard'),
272 'disableNoMatchingValueElement': kw('disableNoMatchingValueElement'),
273 'disablePageExternalUrl': kw('disablePageExternalUrl'),
274 'disablePrefixComment': kw('disablePrefixComment'),
275 'disablePrependAtCopy': kw('disablePrependAtCopy'),
276 'disableSearchBox': kw('disableSearchBox'),
277 'disableSingleTableView': kw('disableSingleTableView'),
278 'displayContent': kw('displayContent'),
279 'displayFieldIcons': kw('displayFieldIcons'),
280 'displayIcons': kw('displayIcons'),
281 'displayMessages': kw('displayMessages'),
282 'displayRecord': kw('displayRecord'),
283 'displayTimes': kw('displayTimes'),
284 'distributeX': kw('distributeX'),
285 'distributeY': kw('distributeY'),
286 'div': B,
287 'DIV': kw('DIV'),
288 'doctype': kw('doctype'),
289 'doctypeSwitch': kw('doctypeSwitch'),
290 'DOCUMENT_BODY': kw('DOCUMENT_BODY'),
291 'doktype': kw('doktype'),
292 'doNotLinkIt': kw('doNotLinkIt'),
293 'doNotShowLink': kw('doNotShowLink'),
294 'doNotStripHTML': kw('doNotStripHTML'),
295 'dontCheckPid': kw('dontCheckPid'),
296 'dontLinkIfSubmenu': kw('dontLinkIfSubmenu'),
297 'dontWrapInTable': kw('dontWrapInTable'),
298 'doubleBrTag': kw('doubleBrTag'),
299 'dWorkArea': kw('dWorkArea'),
300 'dynCSS': A,
301 'edge': kw('edge'),
302 'edit': A,
303 'edit_access': A,
304 'edit_docModuleUpload': kw('edit_docModuleUpload'),
305 'edit_pageheader': A,
306 'edit_RTE': kw('edit_RTE'),
307 'editFieldsAtATime': kw('editFieldsAtATime'),
308 'editFormsOnPage': kw('editFormsOnPage'),
309 'editIcons': kw('editIcons'),
310 'editNoPopup': kw('editNoPopup'),
311 'EDITPANEL': kw('EDITPANEL'),
312 'editPanel': kw('editPanel'),
313 'EFFECT': kw('EFFECT'),
314 'elements': kw('elements'),
315 'else': B,
316 'email': B,
317 'emailMeAtLogin': kw('emailMeAtLogin'),
318 'emailMess': kw('emailMess'),
319 'emboss': kw('emboss'),
320 'enable': kw('enable'),
321 'encapsLines': kw('encapsLines'),
322 'encapsLinesStdWrap': kw('encapsLinesStdWrap'),
323 'encapsTagList': kw('encapsTagList'),
324 'end': B,
325 'entryLevel': kw('entryLevel'),
326 'equalH': kw('equalH'),
327 'equals': B,
328 'everybody': kw('everybody'),
329 'excludeDoktypes': kw('excludeDoktypes'),
330 'excludeUidList': kw('excludeUidList'),
331 'expAll': kw('expAll'),
332 'expand': kw('expand'),
333 'explode': kw('explode'),
334 'ext': kw('ext'),
335 'external': B,
336 'externalBlocks': kw('externalBlocks'),
337 'extTarget': kw('extTarget'),
338 'face': kw('face'),
339 'false': B,
340 'FE': B,
341 'fe_adminLib': kw('fe_adminLib'),
342 'fe_groups': B,
343 'fe_users': B,
344 'feadmin': B,
345 'field': kw('field'),
346 'fieldName': kw('fieldName'),
347 'fieldOrder': kw('fieldOrder'),
348 'fieldRequired': kw('fieldRequired'),
349 'fields': kw('fields'),
350 'fieldWrap': kw('fieldWrap'),
351 'FILE': kw('FILE'),
352 'file': kw('file'),
353 'file1': kw('file1'),
354 'file2': kw('file2'),
355 'file3': kw('file3'),
356 'file4': kw('file4'),
357 'file5': kw('file5'),
358 'filelink': kw('filelink'),
359 'filelist': kw('filelist'),
360 'FILES': kw('FILES'),
361 'files': kw('files'),
362 'firstLabel': kw('firstLabel'),
363 'firstLabelGeneral': kw('firstLabelGeneral'),
364 'fixAttrib': kw('fixAttrib'),
365 'flip': kw('flip'),
366 'flop': kw('flop'),
367 'FLUIDTEMPLATE': kw('FLUIDTEMPLATE'),
368 'folder': A,
369 'folders': kw('folders'),
370 'folderTree': A,
371 'foldoutMenu': A,
372 'fontColor': kw('fontColor'),
373 'fontFile': kw('fontFile'),
374 'fontOffset': kw('fontOffset'),
375 'fontSize': kw('fontSize'),
376 'fontSizeMultiplicator': kw('fontSizeMultiplicator'),
377 'forceDisplayFieldIcons': kw('forceDisplayFieldIcons'),
378 'forceDisplayIcons': kw('forceDisplayIcons'),
379 'forceTemplateParsing': kw('forceTemplateParsing'),
380 'forceTypeValue': kw('forceTypeValue'),
381 'FORM': kw('FORM'),
382 'format': kw('format'),
383 'ftu': kw('ftu'),
384 'function': kw('function'),
385 'Functions': A,
386 'gamma': kw('gamma'),
387 'gapBgCol': kw('gapBgCol'),
388 'gapLineCol': kw('gapLineCol'),
389 'gapLineThickness': kw('gapLineThickness'),
390 'gapWidth': kw('gapWidth'),
391 'get': kw('get'),
392 'getBorder': kw('getBorder'),
393 'getLeft': kw('getLeft'),
394 'getRight': kw('getRight'),
395 'GIFBUILDER': kw('GIFBUILDER'),
396 'global': kw('global'),
397 'globalNesting': kw('globalNesting'),
398 'globalString': kw('globalString'),
399 'globalVar': kw('globalVar'),
400 'GMENU': kw('GMENU'),
401 'GP': kw('GP'),
402 'gray': kw('gray'),
403 'group': kw('group'),
404 'groupBy': kw('groupBy'),
405 'groupid': kw('groupid'),
406 'header': B,
407 'header_layout': kw('header_layout'),
408 'headerComment': kw('headerComment'),
409 'headerData': kw('headerData'),
410 'headerSpace': kw('headerSpace'),
411 'headTag': kw('headTag'),
412 'height': kw('height'),
413 'helpText': kw('helpText'),
414 'hidden': kw('hidden'),
415 'hiddenFields': kw('hiddenFields'),
416 'hide': kw('hide'),
417 'hideButCreateMap': kw('hideButCreateMap'),
418 'hidePStyleItems': kw('hidePStyleItems'),
419 'hideRecords': kw('hideRecords'),
420 'highColor': kw('highColor'),
421 'history': kw('history'),
422 'HMENU': kw('HMENU'),
423 'hostname': A,
424 'hour': A,
425 'HTML': kw('HTML'),
426 'html': B,
427 'HTMLparser': kw('HTMLparser'),
428 'HTMLparser_tags': kw('HTMLparser_tags'),
429 'htmlSpecialChars': kw('htmlSpecialChars'),
430 'htmlTag_dir': kw('htmlTag_dir'),
431 'htmlTag_langKey': kw('htmlTag_langKey'),
432 'htmlTag_setParams': kw('htmlTag_setParams'),
433 'http': kw('http'),
434 'icon': kw('icon'),
435 'icon_image_ext_list': kw('icon_image_ext_list'),
436 'icon_link': kw('icon_link'),
437 'iconCObject': kw('iconCObject'),
438 'id': B,
439 'IENV': kw('IENV'),
440 'if': B,
441 'ifEmpty': B,
442 'IFSUB': B,
443 'IFSUBRO': B,
444 'IMAGE': kw('IMAGE'),
445 'image': B,
446 'image_frames': kw('image_frames'),
447 'imageLinkWrap': kw('imageLinkWrap'),
448 'imagePath': kw('imagePath'),
449 'images': kw('images'),
450 'imageWrapIfAny': kw('imageWrapIfAny'),
451 'IMG_RESOURCE': kw('IMG_RESOURCE'),
452 'imgList': A,
453 'imgMap': kw('imgMap'),
454 'imgMapExtras': kw('imgMapExtras'),
455 'imgMax': kw('imgMax'),
456 'IMGMENU': kw('IMGMENU'),
457 'IMGMENUITEM': kw('IMGMENUITEM'),
458 'imgNameNotRandom': kw('imgNameNotRandom'),
459 'imgNamePrefix': kw('imgNamePrefix'),
460 'imgObjNum': kw('imgObjNum'),
461 'imgParams': kw('imgParams'),
462 'imgPath': kw('imgPath'),
463 'imgResource': A,
464 'imgStart': kw('imgStart'),
465 'IMGTEXT': kw('IMGTEXT'),
466 'imgText': A,
467 'import': kw('import'),
468 'inBranch': B,
469 'inc': kw('inc'),
470 'INCLUDE_TYPOSCRIPT': kw('INCLUDE_TYPOSCRIPT'),
471 'includeCSS': kw('includeCSS'),
472 'includeLibrary': kw('includeLibrary'),
473 'includeNotInMenu': kw('includeNotInMenu'),
474 'index': kw('index'),
475 'index_descrLgd': kw('index_descrLgd'),
476 'index_enable': kw('index_enable'),
477 'index_externals': kw('index_externals'),
478 'info': A,
479 'inlineStyle2TempFile': kw('inlineStyle2TempFile'),
480 'innerStdWrap': kw('innerStdWrap'),
481 'innerStdWrap_all': kw('innerStdWrap_all'),
482 'innerWrap': kw('innerWrap'),
483 'innerWrap2': kw('innerWrap2'),
484 'input': kw('input'),
485 'inputLevels': kw('inputLevels'),
486 'insertData': kw('insertData'),
487 'intensity': kw('intensity'),
488 'intTarget': kw('intTarget'),
489 'intval': kw('intval'),
490 'invert': kw('invert'),
491 'IP': A,
492 'IProcFunc': kw('IProcFunc'),
493 'isFalse': B,
494 'isGreaterThan': B,
495 'isInList': B,
496 'isLessThan': B,
497 'isPositive': B,
498 'isTrue': B,
499 'itemArrayProcFunc': kw('itemArrayProcFunc'),
500 'itemH': kw('itemH'),
501 'items': kw('items'),
502 'itemsProcFunc': kw('itemsProcFunc'),
503 'iterations': kw('iterations'),
504 'join': kw('join'),
505 'JSwindow': A,
506 'JSWindow': kw('JSWindow'),
507 'JSwindow_params': kw('JSwindow_params'),
508 'keep': kw('keep'),
509 'keepEntries': kw('keepEntries'),
510 'keepNonMatchedTags': kw('keepNonMatchedTags'),
511 'key': kw('key'),
512 'keyword3': B,
513 'LABEL': A,
514 'label': kw('label'),
515 'labelStdWrap': kw('labelStdWrap'),
516 'labelWrap': kw('labelWrap'),
517 'lang': kw('lang'),
518 'language': B,
519 'language_alt': kw('language_alt'),
520 'languageField': kw('languageField'),
521 'layout': A,
522 'left': kw('left'),
523 'leftjoin': kw('leftjoin'),
524 'levels': kw('levels'),
525 'leveltitle': B,
526 'leveluid': kw('leveluid'),
527 'lib': A,
528 'limit': kw('limit'),
529 'line': kw('line'),
530 'lineColor': kw('lineColor'),
531 'lineThickness': kw('lineThickness'),
532 'linkPrefix': kw('linkPrefix'),
533 'linkTitleToSelf': kw('linkTitleToSelf'),
534 'linkVars': kw('linkVars'),
535 'linkWrap': kw('linkWrap'),
536 'list': B,
537 'listNum': kw('listNum'),
538 'listOnlyInSingleTableView': kw('listOnlyInSingleTableView'),
539 'LIT': kw('LIT'),
540 'lm': kw('lm'),
541 'LOAD_REGISTER': kw('LOAD_REGISTER'),
542 'locale_all': kw('locale_all'),
543 'localNesting': kw('localNesting'),
544 'locationData': kw('locationData'),
545 'lockFilePath': kw('lockFilePath'),
546 'lockToIP': kw('lockToIP'),
547 'login': B,
548 'loginUser': A,
549 'longdescURL': kw('longdescURL'),
550 'lowColor': kw('lowColor'),
551 'lower': kw('lower'),
552 'LR': kw('LR'),
553 'mailform': B,
554 'mailto': kw('mailto'),
555 'main': kw('main'),
556 'makelinks': kw('makelinks'),
557 'markerWrap': kw('markerWrap'),
558 'marks': A,
559 'mask': kw('mask'),
560 'max': kw('max'),
561 'maxAge': kw('maxAge'),
562 'maxChars': kw('maxChars'),
563 'maxH': kw('maxH'),
564 'maxHeight': kw('maxHeight'),
565 'maxItems': kw('maxItems'),
566 'maxW': kw('maxW'),
567 'maxWidth': kw('maxWidth'),
568 'maxWInText': kw('maxWInText'),
569 'media': B,
570 'menu': B,
571 'menu_type': kw('menu_type'),
572 'menuHeight': kw('menuHeight'),
573 'menuName': kw('menuName'),
574 'menuOffset': kw('menuOffset'),
575 'menuWidth': kw('menuWidth'),
576 'message_page_is_being_generated': kw('message_page_is_being_generated'),
577 'message_preview': kw('message_preview'),
578 'META': kw('META'),
579 'meta': kw('meta'),
580 'metaCharset': kw('metaCharset'),
581 'method': kw('method'),
582 'min': kw('min'),
583 'minH': kw('minH'),
584 'minItems': kw('minItems'),
585 'minute': A,
586 'minW': kw('minW'),
587 'mod': B,
588 'mode': kw('mode'),
589 'module': A,
590 'month': A,
591 'move_wizard': A,
592 'MP_defaults': kw('MP_defaults'),
593 'MP_disableTypolinkClosestMPvalue': kw('MP_disableTypolinkClosestMPvalue'),
594 'MP_mapRootPoints': kw('MP_mapRootPoints'),
595 'MULTIMEDIA': kw('MULTIMEDIA'),
596 'multimedia': B,
597 'name': kw('name'),
598 'negate': B,
599 'nesting': kw('nesting'),
600 'neverHideAtCopy': kw('neverHideAtCopy'),
601 'new': A,
602 'NEW': B,
603 'new_wizard': A,
604 'newPageWiz': kw('newPageWiz'),
605 'newRecordFromTable': kw('newRecordFromTable'),
606 'newWindow': kw('newWindow'),
607 'newWizards': kw('newWizards'),
608 'next': kw('next'),
609 'niceText': kw('niceText'),
610 'nicetext': kw('nicetext'),
611 'NO': B,
612 'no_cache': kw('no_cache'),
613 'no_search': kw('no_search'),
614 'noAttrib': kw('noAttrib'),
615 'noCache': kw('noCache'),
616 'noCreateRecordsLink': kw('noCreateRecordsLink'),
617 'noLink': kw('noLink'),
618 'noMatchingValue_label': kw('noMatchingValue_label'),
619 'nonCachedSubst': kw('nonCachedSubst'),
620 'none': B,
621 'nonTypoTagStdWrap': kw('nonTypoTagStdWrap'),
622 'nonTypoTagUserFunc': kw('nonTypoTagUserFunc'),
623 'nonWrappedTag': kw('nonWrappedTag'),
624 'noOrderBy': kw('noOrderBy'),
625 'noPageTitle': kw('noPageTitle'),
626 'noResultObj': A,
627 'noThumbsInEB': kw('noThumbsInEB'),
628 'noThumbsInRTEimageSelect': kw('noThumbsInRTEimageSelect'),
629 'noTrimWrap': kw('noTrimWrap'),
630 'noValueInsert': kw('noValueInsert'),
631 'numRows': A,
632 'obj': kw('obj'),
633 'offset': kw('offset'),
634 'onlineWorkspaceInfo': kw('onlineWorkspaceInfo'),
635 'onlyCurrentPid': kw('onlyCurrentPid'),
636 'opacity': kw('opacity'),
637 'options': A,
638 'orderBy': kw('orderBy'),
639 'outerWrap': kw('outerWrap'),
640 'outline': kw('outline'),
641 'outputLevels': kw('outputLevels'),
642 'override': kw('override'),
643 'overrideAttribs': kw('overrideAttribs'),
644 'overrideId': kw('overrideId'),
645 'overridePageModule': kw('overridePageModule'),
646 'overrideWithExtension': kw('overrideWithExtension'),
647 'PAGE': kw('PAGE'),
648 'page': A,
649 'PAGE_TARGET': kw('PAGE_TARGET'),
650 'PAGE_TSCONFIG_ID': kw('PAGE_TSCONFIG_ID'),
651 'PAGE_TSCONFIG_IDLIST': kw('PAGE_TSCONFIG_IDLIST'),
652 'PAGE_TSCONFIG_STR': kw('PAGE_TSCONFIG_STR'),
653 'pageFrameObj': kw('pageFrameObj'),
654 'pages': B,
655 'pages_language_overlay': B,
656 'pageTitleFirst': kw('pageTitleFirst'),
657 'pageTree': A,
658 'parameter': kw('parameter'),
659 'params': kw('params'),
660 'parseFunc': kw('parseFunc'),
661 'parseFunc_RTE': B,
662 'parser': kw('parser'),
663 'password': kw('password'),
664 'paste': A,
665 'path': kw('path'),
666 'permissions': kw('permissions'),
667 'perms': A,
668 'pid': B,
669 'pid_list': kw('pid_list'),
670 'pidInList': kw('pidInList'),
671 'PIDinRootline': A,
672 'PIDupinRootline': A,
673 'pixelSpaceFontSizeRef': kw('pixelSpaceFontSizeRef'),
674 'plaintextLib': kw('plaintextLib'),
675 'plainTextStdWrap': kw('plainTextStdWrap'),
676 'plugin': A,
677 'postCObject': kw('postCObject'),
678 'postLineBlanks': kw('postLineBlanks'),
679 'postLineChar': kw('postLineChar'),
680 'postLineLen': kw('postLineLen'),
681 'postUserFunc': kw('postUserFunc'),
682 'postUserFuncInt': kw('postUserFuncInt'),
683 'preBlanks': kw('preBlanks'),
684 'preCObject': kw('preCObject'),
685 'prefix': kw('prefix'),
686 'prefixComment': kw('prefixComment'),
687 'prefixLocalAnchors': kw('prefixLocalAnchors'),
688 'prefixRelPathWith': kw('prefixRelPathWith'),
689 'preIfEmptyListNum': kw('preIfEmptyListNum'),
690 'preLineBlanks': kw('preLineBlanks'),
691 'preLineChar': kw('preLineChar'),
692 'preLineLen': kw('preLineLen'),
693 'prepend': kw('prepend'),
694 'preserveEntities': kw('preserveEntities'),
695 'preUserFunc': kw('preUserFunc'),
696 'prev': kw('prev'),
697 'preview': A,
698 'previewBorder': kw('previewBorder'),
699 'prevnextToSection': kw('prevnextToSection'),
700 'prioriCalc': kw('prioriCalc'),
701 'proc': kw('proc'),
702 'processor_allowUpscaling': kw('processor_allowUpscaling'),
703 'properties': kw('properties'),
704 'protect': kw('protect'),
705 'protectLvar': kw('protectLvar'),
706 'publish': A,
707 'publish_levels': kw('publish_levels'),
708 'QEisDefault': kw('QEisDefault'),
709 'quality': kw('quality'),
710 'RADIO': A,
711 'radio': kw('radio'),
712 'radioWrap': kw('radioWrap'),
713 'range': kw('range'),
714 'rawUrlEncode': kw('rawUrlEncode'),
715 'recipient': kw('recipient'),
716 'RECORDS': kw('RECORDS'),
717 'recursive': kw('recursive'),
718 'recursiveDelete': kw('recursiveDelete'),
719 'redirect': kw('redirect'),
720 'redirectToURL': kw('redirectToURL'),
721 'reduceColors': kw('reduceColors'),
722 'references': kw('references'),
723 'register': kw('register'),
724 'relPathPrefix': kw('relPathPrefix'),
725 'remap': kw('remap'),
726 'remapTag': kw('remapTag'),
727 'REMOTE_ADDR': kw('REMOTE_ADDR'),
728 'removeDefaultJS': kw('removeDefaultJS'),
729 'removeIfEquals': kw('removeIfEquals'),
730 'removeIfFalse': kw('removeIfFalse'),
731 'removeItems': kw('removeItems'),
732 'removeObjectsOfDummy': kw('removeObjectsOfDummy'),
733 'removePrependedNumbers': kw('removePrependedNumbers'),
734 'removeTags': kw('removeTags'),
735 'removeWrapping': kw('removeWrapping'),
736 'renderObj': A,
737 'renderWrap': kw('renderWrap'),
738 'REQ': A,
739 'required': B,
740 'reset': kw('reset'),
741 'resources': kw('resources'),
742 'RESTORE_REGISTER': kw('RESTORE_REGISTER'),
743 'resultObj': kw('resultObj'),
744 'returnLast': kw('returnLast'),
745 'returnUrl': kw('returnUrl'),
746 'rightjoin': kw('rightjoin'),
747 'rm': kw('rm'),
748 'rmTagIfNoAttrib': kw('rmTagIfNoAttrib'),
749 'RO': B,
750 'rootline': B,
751 'rotate': kw('rotate'),
752 'rows': kw('rows'),
753 'rowSpace': kw('rowSpace'),
754 'RTE': A,
755 'RTE_compliant': A,
756 'RTEfullScreenWidth': kw('RTEfullScreenWidth'),
757 'rules': kw('rules'),
758 'sample': kw('sample'),
759 'saveClipboard': kw('saveClipboard'),
760 'saveDocNew': kw('saveDocNew'),
761 'script': B,
762 'search': B,
763 'SEARCHRESULT': kw('SEARCHRESULT'),
764 'secondRow': kw('secondRow'),
765 'section': kw('section'),
766 'sectionIndex': kw('sectionIndex'),
767 'select': A,
768 'selectFields': kw('selectFields'),
769 'separator': kw('separator'),
770 'set': kw('set'),
771 'setContentToCurrent': kw('setContentToCurrent'),
772 'setCurrent': kw('setCurrent'),
773 'setfixed': kw('setfixed'),
774 'setOnly': kw('setOnly'),
775 'setup': A,
776 'shadow': kw('shadow'),
777 'SHARED': kw('SHARED'),
778 'sharpen': kw('sharpen'),
779 'shear': kw('shear'),
780 'short': kw('short'),
781 'shortcut': B,
782 'shortcutFrame': kw('shortcutFrame'),
783 'shortcutIcon': kw('shortcutIcon'),
784 'show': kw('show'),
785 'showAccessRestrictedPages': kw('showAccessRestrictedPages'),
786 'showActive': kw('showActive'),
787 'showClipControlPanelsDespiteOfCMlayers': kw('showClipControlPanelsDespiteOfCMlayers'),
788 'showFirst': kw('showFirst'),
789 'showHiddenPages': kw('showHiddenPages'),
790 'showHiddenRecords': kw('showHiddenRecords'),
791 'showHistory': kw('showHistory'),
792 'showPageIdWithTitle': kw('showPageIdWithTitle'),
793 'showTagFreeClasses': kw('showTagFreeClasses'),
794 'simulateDate': kw('simulateDate'),
795 'simulateUserGroup': kw('simulateUserGroup'),
796 'singlePid': kw('singlePid'),
797 'site_author': kw('site_author'),
798 'site_reserved': kw('site_reserved'),
799 'sitemap': B,
800 'sitetitle': kw('sitetitle'),
801 'siteUrl': kw('siteUrl'),
802 'size': kw('size'),
803 'solarize': kw('solarize'),
804 'sorting': kw('sorting'),
805 'source': kw('source'),
806 'space': kw('space'),
807 'spaceAfter': kw('spaceAfter'),
808 'spaceBefore': kw('spaceBefore'),
809 'spaceBelowAbove': kw('spaceBelowAbove'),
810 'spaceLeft': kw('spaceLeft'),
811 'spaceRight': kw('spaceRight'),
812 'spacing': kw('spacing'),
813 'spamProtectEmailAddresses': kw('spamProtectEmailAddresses'),
814 'spamProtectEmailAddresses_atSubst': kw('spamProtectEmailAddresses_atSubst'),
815 'spamProtectEmailAddresses_lastDotSubst': kw('spamProtectEmailAddresses_lastDotSubst'),
816 'SPC': B,
817 'special': kw('special'),
818 'split': A,
819 'splitChar': kw('splitChar'),
820 'splitRendering': kw('splitRendering'),
821 'src': kw('src'),
822 'stdheader': kw('stdheader'),
823 'stdWrap': A,
824 'stdWrap2': kw('stdWrap2'),
825 'strftime': kw('strftime'),
826 'stripHtml': kw('stripHtml'),
827 'styles': kw('styles'),
828 'submenuObjSuffixes': kw('submenuObjSuffixes'),
829 'subMenuOffset': kw('subMenuOffset'),
830 'submit': kw('submit'),
831 'subparts': A,
832 'subst_elementUid': kw('subst_elementUid'),
833 'substMarksSeparately': kw('substMarksSeparately'),
834 'substring': kw('substring'),
835 'swirl': kw('swirl'),
836 'sword': kw('sword'),
837 'sword_noMixedCase': kw('sword_noMixedCase'),
838 'SWORD_PARAMS': kw('SWORD_PARAMS'),
839 'sword_standAlone': kw('sword_standAlone'),
840 'sys_dmail': B,
841 'sys_domain': B,
842 'sys_filemounts': B,
843 'sys_language_mode': kw('sys_language_mode'),
844 'sys_language_overlay': kw('sys_language_overlay'),
845 'sys_language_uid': kw('sys_language_uid'),
846 'sys_note': B,
847 'sys_template': B,
848 'system': A,
849 'table': B,
850 'tableCellColor': kw('tableCellColor'),
851 'tableParams': kw('tableParams'),
852 'tables': kw('tables'),
853 'tableStdWrap': kw('tableStdWrap'),
854 'tableWidth': kw('tableWidth'),
855 'tags': kw('tags'),
856 'target': kw('target'),
857 'TCAdefaults': kw('TCAdefaults'),
858 'TCEFORM': kw('TCEFORM'),
859 'TCEMAIN': kw('TCEMAIN'),
860 'TDparams': kw('TDparams'),
861 'temp': A,
862 'TEMPLATE': kw('TEMPLATE'),
863 'template': A,
864 'templateContent': kw('templateContent'),
865 'templateFile': kw('templateFile'),
866 'TEXT': kw('TEXT'),
867 'text': B,
868 'textarea': kw('textarea'),
869 'textMargin': kw('textMargin'),
870 'textMargin_outOfText': kw('textMargin_outOfText'),
871 'textMaxLength': kw('textMaxLength'),
872 'textObjNum': kw('textObjNum'),
873 'textpic': B,
874 'textPos': kw('textPos'),
875 'thickness': kw('thickness'),
876 'this': B,
877 'thumbnailsByDefault': kw('thumbnailsByDefault'),
878 'tile': kw('tile'),
879 'time_stdWrap': kw('time_stdWrap'),
880 'tipafriendLib': kw('tipafriendLib'),
881 'title': kw('title'),
882 'titleLen': kw('titleLen'),
883 'titleTagFunction': kw('titleTagFunction'),
884 'titleText': kw('titleText'),
885 'tm': kw('tm'),
886 'TMENU': kw('TMENU'),
887 'TMENUITEM': kw('TMENUITEM'),
888 'token': kw('token'),
889 'top': B,
890 'totalWidth': kw('totalWidth'),
891 'transparentBackground': kw('transparentBackground'),
892 'transparentColor': kw('transparentColor'),
893 'treeLevel': A,
894 'trim': kw('trim'),
895 'true': B,
896 'tsdebug': A,
897 'tsdebug_tree': kw('tsdebug_tree'),
898 'TSFE': kw('TSFE'),
899 'type': kw('type'),
900 'typeNum': kw('typeNum'),
901 'types': kw('types'),
902 'typolink': A,
903 'uid': B,
904 'uidInList': kw('uidInList'),
905 'uniqueGlobal': B,
906 'uniqueLocal': B,
907 'unset': kw('unset'),
908 'unsetEmpty': B,
909 'updated': B,
910 'uploadFieldsInTopOfEB': kw('uploadFieldsInTopOfEB'),
911 'uploads': B,
912 'upper': kw('upper'),
913 'url': A,
914 'us': B,
915 'useCacheHash': kw('useCacheHash'),
916 'useLargestItemX': kw('useLargestItemX'),
917 'useLargestItemY': kw('useLargestItemY'),
918 'USER': kw('USER'),
919 'user': kw('user'),
920 'USER_INT': kw('USER_INT'),
921 'user_task': B,
922 'useragent': A,
923 'USERDEF1': B,
924 'USERDEF1RO': B,
925 'USERDEF2': B,
926 'USERDEF2RO': B,
927 'userdefined': kw('userdefined'),
928 'userFunc': A,
929 'userfunction': kw('userfunction'),
930 'usergroup': B,
931 'userid': kw('userid'),
932 'USERNAME_substToken': kw('USERNAME_substToken'),
933 'userProc': kw('userProc'),
934 'USR': B,
935 'USRRO': B,
936 'value': kw('value'),
937 'valueArray': kw('valueArray'),
938 'version': A,
939 'view': A,
940 'wave': kw('wave'),
941 'web_func': B,
942 'web_info': B,
943 'web_layout': B,
944 'web_list': B,
945 'web_ts': kw('web_ts'),
946 'where': kw('where'),
947 'width': kw('width'),
948 'wiz': kw('wiz'),
949 'wordSpacing': kw('wordSpacing'),
950 'workArea': kw('workArea'),
951 'workOnSubpart': A,
952 'wrap': kw('wrap'),
953 'wrap1': kw('wrap1'),
954 'wrap2': kw('wrap2'),
955 'wrap3': kw('wrap3'),
956 'wrapAfterTags': kw('wrapAfterTags'),
957 'wrapAlign': kw('wrapAlign'),
958 'wrapFieldName': kw('wrapFieldName'),
959 'wrapItemAndSub': kw('wrapItemAndSub'),
960 'wrapNonWrappedLines': kw('wrapNonWrappedLines'),
961 'wraps': kw('wraps'),
962 'xhtml_cleaning': kw('xhtml_cleaning'),
963 'xhtml_strict': B,
964 'xhtml_trans': B,
965 'xmlprologue': kw('xmlprologue'),
966 'XY': B
967 };
968 }();
969
970 var isOperatorChar = /[\+\-\*\&\%\/=<>!\?]/;
971 var inValue = false;
972
973 function readRegexp(stream) {
974 var escaped = false, next, inSet = false;
975 while ((next = stream.next()) != null) {
976 if (!escaped) {
977 if (next === "/" && !inSet) return;
978 if (next === "[") inSet = true;
979 else if (inSet && next === "]") inSet = false;
980 }
981 escaped = !escaped && next === "\\";
982 }
983 }
984
985 // Used as scratch variables to communicate multiple values without
986 // consing up tons of objects.
987 var type, content;
988
989 function ret(tp, style, cont) {
990 type = tp;
991 content = cont;
992 return style;
993 }
994
995 function tokenBase(stream, state) {
996 var ch = stream.next();
997 if (ch === "\n") {
998 inValue = false;
999 }
1000
1001 if (ch === "." && stream.match(/^\d+(?:[eE][+\-]?\d+)?/)) {
1002 return ret("number", "number");
1003 }
1004 if (ch === "." && stream.match("..")) {
1005 return ret("spread", "meta");
1006 }
1007 if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
1008 return ret(ch);
1009 }
1010 if ((ch === '<' || ch === '>' || ch === '.' || (ch === '=' && stream.peek() !== '<'))) {
1011 inValue = true;
1012 return ret(ch, 'operator')
1013 }
1014 if (!inValue && /[\[\]\(\),;\:\.\<\>\=]/.test(ch)) {
1015 return ret(ch, 'operator')
1016 }
1017 if (ch === "0" && stream.eat(/x/i)) {
1018 stream.eatWhile(/[\da-f]/i);
1019 return ret("number", "number");
1020 }
1021 if (ch === "0" && stream.eat(/o/i)) {
1022 stream.eatWhile(/[0-7]/i);
1023 return ret("number", "number");
1024 }
1025 if (ch === "0" && stream.eat(/b/i)) {
1026 stream.eatWhile(/[01]/i);
1027 return ret("number", "number");
1028 }
1029 if (/\d/.test(ch)) {
1030 stream.match(/^\d*(?:\.\d+)?(?:[eE][+\-]?\d+)?/);
1031 return ret("number", "number");
1032 }
1033 if (ch === "/") {
1034 if (stream.eat("*")) {
1035 state.tokenize = tokenComment;
1036 return tokenComment(stream, state);
1037 }
1038 if (stream.eat("/")) {
1039 stream.skipToEnd();
1040 return ret("comment", "comment");
1041 }
1042 if (expressionAllowed(stream, state, 1)) {
1043 readRegexp(stream);
1044 stream.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/);
1045 return ret("regexp", "string-2");
1046 }
1047
1048 stream.eatWhile(isOperatorChar);
1049 return ret("operator", "operator", stream.current());
1050 }
1051 if (ch === "`") {
1052 state.tokenize = tokenQuasi;
1053 return tokenQuasi(stream, state);
1054 }
1055 if (ch === "#") {
1056 stream.skipToEnd();
1057 return ret("comment", "comment");
1058 }
1059 if (isOperatorChar.test(ch)) {
1060 if (ch !== ">" || !state.lexical || state.lexical.type !== ">") {
1061 stream.eatWhile(isOperatorChar);
1062 }
1063 return ret("operator", "operator", stream.current());
1064 }
1065 if (wordRE.test(ch)) {
1066 stream.eatWhile(wordRE);
1067 var word = stream.current();
1068 if (keywords.propertyIsEnumerable(word)) {
1069 var kw = keywords[word];
1070 return ret(kw.type, kw.style, word);
1071 }
1072 if (word === "async" && stream.match(/^\s*[\(\w]/, false)) {
1073 return ret("async", "keyword", word);
1074 }
1075 if (inValue) {
1076 return ret('string', 'string', word);
1077 }
1078 return ret("variable", "other", word);
1079 }
1080 }
1081
1082 function tokenString(quote) {
1083 return function (stream, state) {
1084 var escaped = false, next;
1085 while ((next = stream.next()) != null) {
1086 if (next == quote && !escaped) break;
1087 escaped = !escaped && next === "\\";
1088 }
1089 if (!escaped) state.tokenize = tokenBase;
1090 return ret("string", "string");
1091 };
1092 }
1093
1094 function tokenComment(stream, state) {
1095 var maybeEnd = false, ch;
1096 while (ch = stream.next()) {
1097 if (ch === "/" && maybeEnd) {
1098 state.tokenize = tokenBase;
1099 break;
1100 }
1101 maybeEnd = (ch === "*");
1102 }
1103 return ret("comment", "comment");
1104 }
1105
1106 function tokenQuasi(stream, state) {
1107 var escaped = false, next;
1108 while ((next = stream.next()) != null) {
1109 if (!escaped && (next === "`" || next === "$" && stream.eat("{"))) {
1110 state.tokenize = tokenBase;
1111 break;
1112 }
1113 escaped = !escaped && next === "\\";
1114 }
1115 return ret("quasi", "string-2", stream.current());
1116 }
1117
1118 var brackets = "([{}])";
1119 // This is a crude lookahead trick to try and notice that we're
1120 // parsing the argument patterns for a fat-arrow function before we
1121 // actually hit the arrow token. It only works if the arrow is on
1122 // the same line as the arguments and there's no strange noise
1123 // (comments) in between. Fallback is to only notice when we hit the
1124 // arrow, and not declare the arguments as locals for the arrow
1125 // body.
1126 function findFatArrow(stream, state) {
1127 if (state.fatArrowAt) state.fatArrowAt = null;
1128 var arrow = stream.string.indexOf("=>", stream.start);
1129 if (arrow < 0) return;
1130
1131 var depth = 0, sawSomething = false;
1132 for (var pos = arrow - 1; pos >= 0; --pos) {
1133 var ch = stream.string.charAt(pos);
1134 var bracket = brackets.indexOf(ch);
1135 if (bracket >= 0 && bracket < 3) {
1136 if (!depth) {
1137 ++pos;
1138 break;
1139 }
1140 if (--depth == 0) {
1141 if (ch === "(") sawSomething = true;
1142 break;
1143 }
1144 } else if (bracket >= 3 && bracket < 6) {
1145 ++depth;
1146 } else if (wordRE.test(ch)) {
1147 sawSomething = true;
1148 } else if (/["'\/]/.test(ch)) {
1149 return;
1150 } else if (sawSomething && !depth) {
1151 ++pos;
1152 break;
1153 }
1154 }
1155 if (sawSomething && !depth) state.fatArrowAt = pos;
1156 }
1157
1158 // Parser
1159
1160 var atomicTypes = {
1161 "atom": true,
1162 "number": true,
1163 "variable": true,
1164 "string": true,
1165 "regexp": true
1166 };
1167
1168 function TSLexical(indented, column, type, align, prev, info) {
1169 this.indented = indented;
1170 this.column = column;
1171 this.type = type;
1172 this.prev = prev;
1173 this.info = info;
1174 if (align != null) this.align = align;
1175 }
1176
1177 function inScope(state, varname) {
1178 for (var v = state.localVars; v; v = v.next)
1179 if (v.name == varname) return true;
1180 for (var cx = state.context; cx; cx = cx.prev) {
1181 for (var v = cx.vars; v; v = v.next)
1182 if (v.name == varname) return true;
1183 }
1184 }
1185
1186 function parseTS(state, style, type, content, stream) {
1187 var cc = state.cc;
1188 // Communicate our context to the combinators.
1189 // (Less wasteful than consing up a hundred closures on every call.)
1190 cx.state = state;
1191 cx.stream = stream;
1192 cx.marked = null, cx.cc = cc;
1193 cx.style = style;
1194
1195 if (!state.lexical.hasOwnProperty("align"))
1196 state.lexical.align = true;
1197
1198 while (true) {
1199 var combinator = cc.length ? cc.pop() : statement;
1200 if (combinator(type, content)) {
1201 while (cc.length && cc[cc.length - 1].lex)
1202 cc.pop()();
1203 if (cx.marked) return cx.marked;
1204 if (type === "variable" && inScope(state, content)) return "variable-2";
1205 return style;
1206 }
1207 }
1208 }
1209
1210 // Combinator utils
1211
1212 var cx = {state: null, column: null, marked: null, cc: null};
1213
1214 function pass() {
1215 for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
1216 }
1217
1218 function cont() {
1219 pass.apply(null, arguments);
1220 return true;
1221 }
1222
1223 function register(varname) {
1224 function inList(list) {
1225 for (var v = list; v; v = v.next)
1226 if (v.name == varname) return true;
1227 return false;
1228 }
1229
1230 var state = cx.state;
1231 cx.marked = "def";
1232 if (state.context) {
1233 if (inList(state.localVars)) return;
1234 state.localVars = {name: varname, next: state.localVars};
1235 } else {
1236 if (inList(state.globalVars)) return;
1237 if (parserConfig.globalVars)
1238 state.globalVars = {name: varname, next: state.globalVars};
1239 }
1240 }
1241
1242 // Combinators
1243
1244 var defaultVars = {name: "this", next: {name: "arguments"}};
1245
1246 function pushcontext() {
1247 cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};
1248 cx.state.localVars = defaultVars;
1249 }
1250
1251 function popcontext() {
1252 cx.state.localVars = cx.state.context.vars;
1253 cx.state.context = cx.state.context.prev;
1254 }
1255
1256 function pushlex(type, info) {
1257 var result = function () {
1258 var state = cx.state, indent = state.indented;
1259 if (state.lexical.type === "stat") indent = state.lexical.indented;
1260 else for (var outer = state.lexical; outer && outer.type === ")" && outer.align; outer = outer.prev)
1261 indent = outer.indented;
1262 state.lexical = new TSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
1263 };
1264 result.lex = true;
1265 return result;
1266 }
1267
1268 function poplex() {
1269 var state = cx.state;
1270 if (state.lexical.prev) {
1271 if (state.lexical.type === ")")
1272 state.indented = state.lexical.indented;
1273 state.lexical = state.lexical.prev;
1274 }
1275 }
1276
1277 poplex.lex = true;
1278
1279 function expect(wanted) {
1280 function exp(type) {
1281 if (type == wanted) return cont();
1282 else if (wanted === ";") return pass();
1283 else return cont(exp);
1284 };
1285 return exp;
1286 }
1287
1288 function statement(type, value) {
1289 if (type === "var") return cont(pushlex("vardef", value.length), vardef, expect(";"), poplex);
1290 if (type === "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex);
1291 if (type === "keyword b") return cont(pushlex("form"), statement, poplex);
1292 if (type === "{") return cont(pushlex("}"), block, poplex);
1293 if (type === ";") return cont();
1294 if (type === "if") {
1295 if (cx.state.lexical.info === "else" && cx.state.cc[cx.state.cc.length - 1] == poplex) {
1296 cx.state.cc.pop()();
1297 }
1298 return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse);
1299 }
1300 if (type === "function") return cont(functiondef);
1301 if (type === "for") return cont(pushlex("form"), forspec, statement, poplex);
1302 if (type === "variable") {
1303 return cont(pushlex("stat"), maybelabel);
1304 }
1305 if (type === "switch") return cont(pushlex("form"), parenExpr, expect("{"), pushlex("}", "switch"),
1306 block, poplex, poplex);
1307 if (type === "case") return cont(expression, expect(":"));
1308 if (type === "default") return cont(expect(":"));
1309 if (type === "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
1310 statement, poplex, popcontext);
1311 if (type === "class") return cont(pushlex("form"), className, poplex);
1312 if (type === "export") return cont(pushlex("stat"), afterExport, poplex);
1313 if (type === "import") return cont(pushlex("stat"), afterImport, poplex);
1314 if (type === "module") return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex)
1315 if (type === "async") return cont(statement)
1316 if (value === "@") return cont(expression, statement)
1317 return pass(pushlex("stat"), expression, expect(";"), poplex);
1318 }
1319
1320 function expression(type) {
1321 return expressionInner(type, false);
1322 }
1323
1324 function expressionNoComma(type) {
1325 return expressionInner(type, true);
1326 }
1327
1328 function parenExpr(type) {
1329 if (type !== "(") return pass()
1330 return cont(pushlex(")"), expression, expect(")"), poplex)
1331 }
1332
1333 function expressionInner(type, noComma) {
1334 var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
1335 if (atomicTypes.hasOwnProperty(type)) {
1336 return cont(maybeop);
1337 }
1338 if (type === "keyword c") {
1339 return cont(noComma ? maybeexpressionNoComma : maybeexpression);
1340 }
1341 if (type === "(") {
1342 return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop);
1343 }
1344 if (type === "operator" || type === "spread") {
1345 return cont(noComma ? expressionNoComma : expression);
1346 }
1347 if (type === "[") {
1348 return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
1349 }
1350 if (type === "{") {
1351 return contCommasep(objprop, "}", null, maybeop);
1352 }
1353 return cont();
1354 }
1355
1356 function maybeexpression(type) {
1357 if (type.match(/[;\}\)\],]/)) return pass();
1358 return pass(expression);
1359 }
1360
1361 function maybeexpressionNoComma(type) {
1362 if (type.match(/[;\}\)\],]/)) return pass();
1363 return pass(expressionNoComma);
1364 }
1365
1366 function maybeoperatorComma(type, value) {
1367 if (type === ",") return cont(expression);
1368 return maybeoperatorNoComma(type, value, false);
1369 }
1370
1371 function maybeoperatorNoComma(type, value, noComma) {
1372 var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
1373 var expr = noComma == false ? expression : expressionNoComma;
1374 if (type === "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
1375 if (type === "operator") {
1376 if (/\+\+|--/.test(value)) return cont(me);
1377 if (value === "?") return cont(expression, expect(":"), expr);
1378 return cont(expr);
1379 }
1380 if (type === "quasi") {
1381 return pass(quasi, me);
1382 }
1383 if (type === ";") return;
1384 if (type === "(") return contCommasep(expressionNoComma, ")", "call", me);
1385 if (type === ".") return cont(property, me);
1386 if (type === "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
1387 }
1388
1389 function quasi(type, value) {
1390 if (type !== "quasi") return pass();
1391 if (value.slice(value.length - 2) !== "${") return cont(quasi);
1392 return cont(expression, continueQuasi);
1393 }
1394
1395 function continueQuasi(type) {
1396 if (type === "}") {
1397 cx.marked = "string-2";
1398 cx.state.tokenize = tokenQuasi;
1399 return cont(quasi);
1400 }
1401 }
1402
1403 function arrowBody(type) {
1404 findFatArrow(cx.stream, cx.state);
1405 return pass(type === "{" ? statement : expression);
1406 }
1407
1408 function arrowBodyNoComma(type) {
1409 findFatArrow(cx.stream, cx.state);
1410 return pass(type === "{" ? statement : expressionNoComma);
1411 }
1412
1413 function maybeTarget(noComma) {
1414 return function (type) {
1415 if (type === ".") return cont(noComma ? targetNoComma : target);
1416 else return pass(noComma ? expressionNoComma : expression);
1417 };
1418 }
1419
1420 function target(_, value) {
1421 if (value === "target") {
1422 cx.marked = "keyword";
1423 return cont(maybeoperatorComma);
1424 }
1425 }
1426
1427 function targetNoComma(_, value) {
1428 if (value === "target") {
1429 cx.marked = "keyword";
1430 return cont(maybeoperatorNoComma);
1431 }
1432 }
1433
1434 function maybelabel(type) {
1435 if (type === ":") return cont(poplex, statement);
1436 return pass(maybeoperatorComma, expect(";"), poplex);
1437 }
1438
1439 function property(type) {
1440 if (type === "variable") {
1441 cx.marked = "property";
1442 return cont();
1443 }
1444 }
1445
1446 function objprop(type, value) {
1447 if (type === "async") {
1448 cx.marked = "property";
1449 return cont(objprop);
1450 } else if (type === "variable" || cx.style === "keyword") {
1451 cx.marked = "property";
1452 if (value === "get" || value === "set") return cont(getterSetter);
1453 return cont(afterprop);
1454 } else if (type === "number" || type === "string") {
1455 cx.marked = cx.style + " property";
1456 return cont(afterprop);
1457 } else if (type === "jsonld-keyword") {
1458 return cont(afterprop);
1459 } else if (type === "modifier") {
1460 return cont(objprop)
1461 } else if (type === "[") {
1462 return cont(expression, expect("]"), afterprop);
1463 } else if (type === "spread") {
1464 return cont(expression, afterprop);
1465 } else if (type === ":") {
1466 return pass(afterprop)
1467 }
1468 }
1469
1470 function getterSetter(type) {
1471 if (type !== "variable") return pass(afterprop);
1472 cx.marked = "property";
1473 return cont(functiondef);
1474 }
1475
1476 function afterprop(type) {
1477 if (type === ":") return cont(expressionNoComma);
1478 if (type === "(") return pass(functiondef);
1479 }
1480
1481 function commasep(what, end, sep) {
1482 function proceed(type, value) {
1483 if (sep ? sep.indexOf(type) > -1 : type === ",") {
1484 var lex = cx.state.lexical;
1485 if (lex.info === "call") lex.pos = (lex.pos || 0) + 1;
1486 return cont(function (type, value) {
1487 if (type == end || value == end) return pass()
1488 return pass(what)
1489 }, proceed);
1490 }
1491 if (type == end || value == end) return cont();
1492 return cont(expect(end));
1493 }
1494
1495 return function (type, value) {
1496 if (type == end || value == end) return cont();
1497 return pass(what, proceed);
1498 };
1499 }
1500
1501 function contCommasep(what, end, info) {
1502 for (var i = 3; i < arguments.length; i++)
1503 cx.cc.push(arguments[i]);
1504 return cont(pushlex(end, info), commasep(what, end), poplex);
1505 }
1506
1507 function block(type) {
1508 if (type === "}") return cont();
1509 return pass(statement, block);
1510 }
1511
1512 function typeexpr(type) {
1513 if (type === "variable") {
1514 cx.marked = "type";
1515 return cont(afterType);
1516 }
1517 if (type === "string" || type === "number" || type === "atom") return cont(afterType);
1518 if (type === "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType)
1519 if (type === "(") return cont(commasep(typearg, ")"), maybeReturnType)
1520 }
1521
1522 function maybeReturnType(type) {
1523 if (type === "=>") return cont(typeexpr)
1524 }
1525
1526 function typeprop(type, value) {
1527 if (type === "variable" || cx.style === "keyword") {
1528 cx.marked = "property"
1529 return cont(typeprop)
1530 } else if (value === "?") {
1531 return cont(typeprop)
1532 } else if (type === ":") {
1533 return cont(typeexpr)
1534 } else if (type === "[") {
1535 return cont(expression, null, expect("]"), typeprop)
1536 }
1537 }
1538
1539 function typearg(type) {
1540 if (type === "variable") return cont(typearg)
1541 else if (type === ":") return cont(typeexpr)
1542 }
1543
1544 function afterType(type, value) {
1545 if (value === "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
1546 if (value === "|" || type === ".") return cont(typeexpr)
1547 if (type === "[") return cont(expect("]"), afterType)
1548 if (value === "extends") return cont(typeexpr)
1549 }
1550
1551 function vardef() {
1552 return pass(pattern, null, maybeAssign, vardefCont);
1553 }
1554
1555 function pattern(type, value) {
1556 if (type === "modifier") return cont(pattern)
1557 if (type === "variable") {
1558 register(value);
1559 return cont();
1560 }
1561 if (type === "spread") return cont(pattern);
1562 if (type === "[") return contCommasep(pattern, "]");
1563 if (type === "{") return contCommasep(proppattern, "}");
1564 }
1565
1566 function proppattern(type, value) {
1567 if (type === "variable" && !cx.stream.match(/^\s*:/, false)) {
1568 register(value);
1569 return cont(maybeAssign);
1570 }
1571 if (type === "variable") cx.marked = "property";
1572 if (type === "spread") return cont(pattern);
1573 if (type === "}") return pass();
1574 return cont(expect(":"), pattern, maybeAssign);
1575 }
1576
1577 function maybeAssign(_type, value) {
1578 if (value === "=") return cont(expressionNoComma);
1579 }
1580
1581 function vardefCont(type) {
1582 if (type === ",") return cont(vardef);
1583 }
1584
1585 function maybeelse(type, value) {
1586 if (type === "keyword b" && value === "else") return cont(pushlex("form", "else"), statement, poplex);
1587 }
1588
1589 function forspec(type) {
1590 if (type === "(") return cont(pushlex(")"), forspec1, expect(")"), poplex);
1591 }
1592
1593 function forspec1(type) {
1594 if (type === "var") return cont(vardef, expect(";"), forspec2);
1595 if (type === ";") return cont(forspec2);
1596 if (type === "variable") return cont(formaybeinof);
1597 return pass(expression, expect(";"), forspec2);
1598 }
1599
1600 function formaybeinof(_type, value) {
1601 if (value === "in" || value === "of") {
1602 cx.marked = "keyword";
1603 return cont(expression);
1604 }
1605 return cont(maybeoperatorComma, forspec2);
1606 }
1607
1608 function forspec2(type, value) {
1609 if (type === ";") return cont(forspec3);
1610 if (value === "in" || value === "of") {
1611 cx.marked = "keyword";
1612 return cont(expression);
1613 }
1614 return pass(expression, expect(";"), forspec3);
1615 }
1616
1617 function forspec3(type) {
1618 if (type !== ")") cont(expression);
1619 }
1620
1621 function functiondef(type, value) {
1622 if (value === "*") {
1623 cx.marked = "keyword";
1624 return cont(functiondef);
1625 }
1626 if (type === "variable") {
1627 register(value);
1628 return cont(functiondef);
1629 }
1630 if (type === "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, null, statement, popcontext);
1631 }
1632
1633 function funarg(type) {
1634 if (type === "spread") return cont(funarg);
1635 return pass(pattern, null, maybeAssign);
1636 }
1637
1638 function classExpression(type, value) {
1639 // Class expressions may have an optional name.
1640 if (type === "variable") return className(type, value);
1641 return classNameAfter(type, value);
1642 }
1643
1644 function className(type, value) {
1645 if (type === "variable") {
1646 register(value);
1647 return cont(classNameAfter);
1648 }
1649 }
1650
1651 function classNameAfter(type, value) {
1652 if (value === "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, classNameAfter)
1653 if (value === "extends" || value === "implements")
1654 return cont(expression, classNameAfter);
1655 if (type === "{") return cont(pushlex("}"), classBody, poplex);
1656 }
1657
1658 function classBody(type, value) {
1659 if (type === "variable" || cx.style === "keyword") {
1660 if ((value === "async" || value === "static" || value === "get" || value === "set") &&
1661 cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false)) {
1662 cx.marked = "keyword";
1663 return cont(classBody);
1664 }
1665 cx.marked = "property";
1666 return cont(functiondef, classBody);
1667 }
1668 if (type === "[")
1669 return cont(expression, expect("]"), functiondef, classBody)
1670 if (value === "*") {
1671 cx.marked = "keyword";
1672 return cont(classBody);
1673 }
1674 if (type === ";") return cont(classBody);
1675 if (type === "}") return cont();
1676 if (value === "@") return cont(expression, classBody)
1677 }
1678
1679 function classfield(type, value) {
1680 if (value === "?") return cont(classfield)
1681 if (type === ":") return cont(typeexpr, maybeAssign)
1682 if (value === "=") return cont(expressionNoComma)
1683 return pass(functiondef)
1684 }
1685
1686 function afterExport(type, value) {
1687 if (value === "*") {
1688 cx.marked = "keyword";
1689 return cont(maybeFrom, expect(";"));
1690 }
1691 if (value === "default") {
1692 cx.marked = "keyword";
1693 return cont(expression, expect(";"));
1694 }
1695 if (type === "{") return cont(commasep(exportField, "}"), maybeFrom, expect(";"));
1696 return pass(statement);
1697 }
1698
1699 function exportField(type, value) {
1700 if (value === "as") {
1701 cx.marked = "keyword";
1702 return cont(expect("variable"));
1703 }
1704 if (type === "variable") return pass(expressionNoComma, exportField);
1705 }
1706
1707 function afterImport(type) {
1708 if (type === "string") return cont();
1709 return pass(importSpec, maybeMoreImports, maybeFrom);
1710 }
1711
1712 function importSpec(type, value) {
1713 if (type === "{") return contCommasep(importSpec, "}");
1714 if (type === "variable") register(value);
1715 if (value === "*") cx.marked = "keyword";
1716 return cont(maybeAs);
1717 }
1718
1719 function maybeMoreImports(type) {
1720 if (type === ",") return cont(importSpec, maybeMoreImports)
1721 }
1722
1723 function maybeAs(_type, value) {
1724 if (value === "as") {
1725 cx.marked = "keyword";
1726 return cont(importSpec);
1727 }
1728 }
1729
1730 function maybeFrom(_type, value) {
1731 if (value === "from") {
1732 cx.marked = "keyword";
1733 return cont(expression);
1734 }
1735 }
1736
1737 function arrayLiteral(type) {
1738 if (type === "]") return cont();
1739 return pass(commasep(expressionNoComma, "]"));
1740 }
1741
1742 function isContinuedStatement(state, textAfter) {
1743 return state.lastType === "operator" || state.lastType === "," ||
1744 isOperatorChar.test(textAfter.charAt(0)) ||
1745 /[,.]/.test(textAfter.charAt(0));
1746 }
1747
1748 // Interface
1749
1750 return {
1751 startState: function (basecolumn) {
1752 var state = {
1753 tokenize: tokenBase,
1754 lastType: "sof",
1755 cc: [],
1756 lexical: new TSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
1757 localVars: parserConfig.localVars,
1758 context: parserConfig.localVars && {vars: parserConfig.localVars},
1759 indented: basecolumn || 0
1760 };
1761 if (parserConfig.globalVars && typeof parserConfig.globalVars === "object")
1762 state.globalVars = parserConfig.globalVars;
1763 return state;
1764 },
1765
1766 token: function (stream, state) {
1767 if (stream.sol()) {
1768 if (!state.lexical.hasOwnProperty("align"))
1769 state.lexical.align = false;
1770 state.indented = stream.indentation();
1771 findFatArrow(stream, state);
1772 }
1773 if (state.tokenize != tokenComment && stream.eatSpace()) return null;
1774 var style = state.tokenize(stream, state);
1775 if (type === "comment") return style;
1776 state.lastType = type === "operator" && (content === "++" || content === "--") ? "incdec" : type;
1777 return parseTS(state, style, type, content, stream);
1778 },
1779
1780 indent: function (state, textAfter) {
1781 if (state.tokenize == tokenComment) return CodeMirror.Pass;
1782 if (state.tokenize != tokenBase) return 0;
1783 var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top
1784 // Kludge to prevent 'maybelse' from blocking lexical scope pops
1785 if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
1786 var c = state.cc[i];
1787 if (c == poplex) lexical = lexical.prev;
1788 else if (c != maybeelse) break;
1789 }
1790 while ((lexical.type === "stat" || lexical.type === "form") &&
1791 (firstChar === "}" || ((top = state.cc[state.cc.length - 1]) &&
1792 (top == maybeoperatorComma || top == maybeoperatorNoComma) &&
1793 !/^[,\.=+\-*:?[\(]/.test(textAfter))))
1794 lexical = lexical.prev;
1795 if (statementIndent && lexical.type === ")" && lexical.prev.type === "stat")
1796 lexical = lexical.prev;
1797 var type = lexical.type, closing = firstChar == type;
1798
1799 if (type === "vardef") return lexical.indented + (state.lastType === "operator" || state.lastType === "," ? lexical.info + 1 : 0);
1800 else if (type === "form" && firstChar === "{") return lexical.indented;
1801 else if (type === "form") return lexical.indented + indentUnit;
1802 else if (type === "stat")
1803 return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || indentUnit : 0);
1804 else if (lexical.info === "switch" && !closing && parserConfig.doubleIndentSwitch != false)
1805 return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
1806 else if (lexical.align) return lexical.column + (closing ? 0 : 1);
1807 else return lexical.indented + (closing ? 0 : indentUnit);
1808 },
1809
1810 electricInput: /^\s*(?:case .*?:|default:|\{|\})$/,
1811 blockCommentStart: "/*",
1812 blockCommentEnd: "*/",
1813 lineComment: "#",
1814 fold: "brace",
1815 closeBrackets: "()[]{}''\"\"``",
1816
1817 helperType: "typoscript",
1818
1819 expressionAllowed: expressionAllowed,
1820 skipExpression: function (state) {
1821 var top = state.cc[state.cc.length - 1];
1822 if (top == expression || top == expressionNoComma) state.cc.pop()
1823 }
1824 };
1825 });
1826 });