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