UNPKG

183 kBJavaScriptView Raw
1/**
2 * @author Toru Nagashima <https://github.com/mysticatea>
3 * See LICENSE file in root directory for full license.
4 */
5'use strict';
6
7Object.defineProperty(exports, '__esModule', { value: true });
8
9function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
10
11var path = require('path');
12var Evk = _interopDefault(require('eslint-visitor-keys'));
13var sortedLastIndex = _interopDefault(require('lodash/sortedLastIndex'));
14var assert = _interopDefault(require('assert'));
15var last = _interopDefault(require('lodash/last'));
16var findLastIndex = _interopDefault(require('lodash/findLastIndex'));
17var debugFactory = _interopDefault(require('debug'));
18var sortedIndexBy = _interopDefault(require('lodash/sortedIndexBy'));
19var sortedLastIndexBy = _interopDefault(require('lodash/sortedLastIndexBy'));
20var first = _interopDefault(require('lodash/first'));
21var escope = _interopDefault(require('eslint-scope'));
22var EventEmitter = _interopDefault(require('events'));
23var esquery = _interopDefault(require('esquery'));
24var union = _interopDefault(require('lodash/union'));
25var intersection = _interopDefault(require('lodash/intersection'));
26var memoize = _interopDefault(require('lodash/memoize'));
27
28function isAcornStyleParseError(x) {
29 return (typeof x.message === "string" &&
30 typeof x.pos === "number" &&
31 typeof x.loc === "object" &&
32 x.loc !== null &&
33 typeof x.loc.line === "number" &&
34 typeof x.loc.column === "number");
35}
36class ParseError extends SyntaxError {
37 static fromCode(code, offset, line, column) {
38 return new ParseError(code, code, offset, line, column);
39 }
40 static normalize(x) {
41 if (ParseError.isParseError(x)) {
42 return x;
43 }
44 if (isAcornStyleParseError(x)) {
45 return new ParseError(x.message, undefined, x.pos, x.loc.line, x.loc.column);
46 }
47 return null;
48 }
49 constructor(message, code, offset, line, column) {
50 super(message);
51 this.code = code;
52 this.index = offset;
53 this.lineNumber = line;
54 this.column = column;
55 }
56 static isParseError(x) {
57 return (x instanceof ParseError ||
58 (typeof x.message === "string" &&
59 typeof x.index === "number" &&
60 typeof x.lineNumber === "number" &&
61 typeof x.column === "number"));
62 }
63}
64
65const NS = Object.freeze({
66 HTML: "http://www.w3.org/1999/xhtml",
67 MathML: "http://www.w3.org/1998/Math/MathML",
68 SVG: "http://www.w3.org/2000/svg",
69 XLink: "http://www.w3.org/1999/xlink",
70 XML: "http://www.w3.org/XML/1998/namespace",
71 XMLNS: "http://www.w3.org/2000/xmlns/",
72});
73
74const KEYS = Evk.unionWith({
75 VAttribute: ["key", "value"],
76 VDirectiveKey: ["name", "argument", "modifiers"],
77 VDocumentFragment: ["children"],
78 VElement: ["startTag", "children", "endTag"],
79 VEndTag: [],
80 VExpressionContainer: ["expression"],
81 VFilter: ["callee", "arguments"],
82 VFilterSequenceExpression: ["expression", "filters"],
83 VForExpression: ["left", "right"],
84 VIdentifier: [],
85 VLiteral: [],
86 VOnExpression: ["body"],
87 VSlotScopeExpression: ["params"],
88 VStartTag: ["attributes"],
89 VText: [],
90});
91function fallbackKeysFilter(key) {
92 let value = null;
93 return (key !== "comments" &&
94 key !== "leadingComments" &&
95 key !== "loc" &&
96 key !== "parent" &&
97 key !== "range" &&
98 key !== "tokens" &&
99 key !== "trailingComments" &&
100 (value = this[key]) !== null &&
101 typeof value === "object" &&
102 (typeof value.type === "string" || Array.isArray(value)));
103}
104function getFallbackKeys(node) {
105 return Object.keys(node).filter(fallbackKeysFilter, node);
106}
107function isNode(x) {
108 return x !== null && typeof x === "object" && typeof x.type === "string";
109}
110function traverse(node, parent, visitor) {
111 let i = 0;
112 let j = 0;
113 visitor.enterNode(node, parent);
114 const keys = (visitor.visitorKeys || KEYS)[node.type] || getFallbackKeys(node);
115 for (i = 0; i < keys.length; ++i) {
116 const child = node[keys[i]];
117 if (Array.isArray(child)) {
118 for (j = 0; j < child.length; ++j) {
119 if (isNode(child[j])) {
120 traverse(child[j], node, visitor);
121 }
122 }
123 }
124 else if (isNode(child)) {
125 traverse(child, node, visitor);
126 }
127 }
128 visitor.leaveNode(node, parent);
129}
130function traverseNodes(node, visitor) {
131 traverse(node, null, visitor);
132}
133
134
135
136var index = /*#__PURE__*/Object.freeze({
137 __proto__: null,
138 ParseError: ParseError,
139 NS: NS,
140 traverseNodes: traverseNodes,
141 getFallbackKeys: getFallbackKeys
142});
143
144class LocationCalculator {
145 constructor(gapOffsets, ltOffsets, baseOffset) {
146 this.gapOffsets = gapOffsets;
147 this.ltOffsets = ltOffsets;
148 this.baseOffset = baseOffset || 0;
149 this.baseIndexOfGap =
150 this.baseOffset === 0
151 ? 0
152 : sortedLastIndex(gapOffsets, this.baseOffset);
153 }
154 getSubCalculatorAfter(offset) {
155 return new LocationCalculator(this.gapOffsets, this.ltOffsets, this.baseOffset + offset);
156 }
157 _getLocation(offset) {
158 const line = sortedLastIndex(this.ltOffsets, offset) + 1;
159 const column = offset - (line === 1 ? 0 : this.ltOffsets[line - 2]);
160 return { line, column };
161 }
162 _getGap(index) {
163 const offsets = this.gapOffsets;
164 let g0 = sortedLastIndex(offsets, index + this.baseOffset);
165 let pos = index + this.baseOffset + g0 - this.baseIndexOfGap;
166 while (g0 < offsets.length && offsets[g0] <= pos) {
167 g0 += 1;
168 pos += 1;
169 }
170 return g0 - this.baseIndexOfGap;
171 }
172 getLocation(index) {
173 return this._getLocation(this.baseOffset + index);
174 }
175 getOffsetWithGap(index) {
176 return this.baseOffset + index + this._getGap(index);
177 }
178 fixLocation(node) {
179 const range = node.range;
180 const loc = node.loc;
181 const gap0 = this._getGap(range[0]);
182 const gap1 = this._getGap(range[1]);
183 const d0 = this.baseOffset + Math.max(0, gap0);
184 const d1 = this.baseOffset + Math.max(0, gap1);
185 if (d0 !== 0) {
186 range[0] += d0;
187 if (node.start != null) {
188 node.start += d0;
189 }
190 loc.start = this._getLocation(range[0]);
191 }
192 if (d1 !== 0) {
193 range[1] += d1;
194 if (node.end != null) {
195 node.end += d0;
196 }
197 loc.end = this._getLocation(range[1]);
198 }
199 return node;
200 }
201 fixErrorLocation(error) {
202 const gap = this._getGap(error.index);
203 const diff = this.baseOffset + Math.max(0, gap);
204 error.index += diff;
205 const loc = this._getLocation(error.index);
206 error.lineNumber = loc.line;
207 error.column = loc.column;
208 }
209}
210
211const debug = debugFactory("vue-eslint-parser");
212
213function isUnique(reference, index, references) {
214 return (index === 0 || reference.identifier !== references[index - 1].identifier);
215}
216function hasDefinition(variable) {
217 return variable.defs.length >= 1;
218}
219function transformReference(reference) {
220 const ret = {
221 id: reference.identifier,
222 mode: reference.isReadOnly()
223 ? "r"
224 : reference.isWriteOnly()
225 ? "w"
226 : "rw",
227 variable: null,
228 };
229 Object.defineProperty(ret, "variable", { enumerable: false });
230 return ret;
231}
232function transformVariable(variable) {
233 const ret = {
234 id: variable.defs[0].name,
235 kind: variable.scope.type === "for" ? "v-for" : "scope",
236 references: [],
237 };
238 Object.defineProperty(ret, "references", { enumerable: false });
239 return ret;
240}
241function getForScope(scope) {
242 const child = scope.childScopes[0];
243 return child.block === scope.block ? child.childScopes[0] : child;
244}
245function analyze(ast, parserOptions) {
246 const ecmaVersion = parserOptions.ecmaVersion || 2017;
247 const ecmaFeatures = parserOptions.ecmaFeatures || {};
248 const sourceType = parserOptions.sourceType || "script";
249 const result = escope.analyze(ast, {
250 ignoreEval: true,
251 nodejsScope: false,
252 impliedStrict: ecmaFeatures.impliedStrict,
253 ecmaVersion,
254 sourceType,
255 fallback: getFallbackKeys,
256 });
257 return result.globalScope;
258}
259function analyzeExternalReferences(ast, parserOptions) {
260 const scope = analyze(ast, parserOptions);
261 return scope.through.filter(isUnique).map(transformReference);
262}
263function analyzeVariablesAndExternalReferences(ast, parserOptions) {
264 const scope = analyze(ast, parserOptions);
265 return {
266 variables: getForScope(scope)
267 .variables.filter(hasDefinition)
268 .map(transformVariable),
269 references: scope.through.filter(isUnique).map(transformReference),
270 };
271}
272
273const ALIAS_PARENS = /^(\s*)\(([\s\S]+)\)(\s*(?:in|of)\b[\s\S]+)$/u;
274const DUMMY_PARENT = {};
275const IS_FUNCTION_EXPRESSION = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/u;
276const IS_SIMPLE_PATH = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?'\]|\["[^"]*?"\]|\[\d+\]|\[[A-Za-z_$][\w$]*\])*$/u;
277function postprocess(result, locationCalculator) {
278 const traversed = new Set();
279 traverseNodes(result.ast, {
280 visitorKeys: result.visitorKeys,
281 enterNode(node, parent) {
282 if (!traversed.has(node)) {
283 traversed.add(node);
284 node.parent = parent;
285 if (!traversed.has(node.range)) {
286 traversed.add(node.range);
287 locationCalculator.fixLocation(node);
288 }
289 }
290 },
291 leaveNode() {
292 },
293 });
294 for (const token of result.ast.tokens || []) {
295 locationCalculator.fixLocation(token);
296 }
297 for (const comment of result.ast.comments || []) {
298 locationCalculator.fixLocation(comment);
299 }
300}
301function replaceAliasParens(code) {
302 const match = ALIAS_PARENS.exec(code);
303 if (match != null) {
304 return `${match[1]}[${match[2]}]${match[3]}`;
305 }
306 return code;
307}
308function normalizeLeft(left, replaced) {
309 if (left.type !== "VariableDeclaration") {
310 throw new Error("unreachable");
311 }
312 const id = left.declarations[0].id;
313 if (replaced) {
314 return id.elements;
315 }
316 return [id];
317}
318function getCommaTokenBeforeNode(tokens, node) {
319 let tokenIndex = sortedIndexBy(tokens, { range: node.range }, t => t.range[0]);
320 while (tokenIndex >= 0) {
321 const token = tokens[tokenIndex];
322 if (token.type === "Punctuator" && token.value === ",") {
323 return token;
324 }
325 tokenIndex -= 1;
326 }
327 return null;
328}
329function throwEmptyError(locationCalculator, expected) {
330 const loc = locationCalculator.getLocation(0);
331 const err = new ParseError(`Expected to be ${expected}, but got empty.`, undefined, 0, loc.line, loc.column);
332 locationCalculator.fixErrorLocation(err);
333 throw err;
334}
335function throwUnexpectedTokenError(name, token) {
336 const err = new ParseError(`Unexpected token '${name}'.`, undefined, token.range[0], token.loc.start.line, token.loc.start.column);
337 throw err;
338}
339function throwErrorAsAdjustingOutsideOfCode(err, code, locationCalculator) {
340 if (ParseError.isParseError(err)) {
341 const endOffset = locationCalculator.getOffsetWithGap(code.length);
342 if (err.index >= endOffset) {
343 err.message = "Unexpected end of expression.";
344 }
345 }
346 throw err;
347}
348function parseScriptFragment(code, locationCalculator, parserOptions) {
349 try {
350 const result = parseScript(code, parserOptions);
351 postprocess(result, locationCalculator);
352 return result;
353 }
354 catch (err) {
355 const perr = ParseError.normalize(err);
356 if (perr) {
357 locationCalculator.fixErrorLocation(perr);
358 throw perr;
359 }
360 throw err;
361 }
362}
363const validDivisionCharRE = /[\w).+\-_$\]]/u;
364function splitFilters(exp) {
365 const result = [];
366 let inSingle = false;
367 let inDouble = false;
368 let inTemplateString = false;
369 let inRegex = false;
370 let curly = 0;
371 let square = 0;
372 let paren = 0;
373 let lastFilterIndex = 0;
374 let c = 0;
375 let prev = 0;
376 for (let i = 0; i < exp.length; i++) {
377 prev = c;
378 c = exp.charCodeAt(i);
379 if (inSingle) {
380 if (c === 0x27 && prev !== 0x5c) {
381 inSingle = false;
382 }
383 }
384 else if (inDouble) {
385 if (c === 0x22 && prev !== 0x5c) {
386 inDouble = false;
387 }
388 }
389 else if (inTemplateString) {
390 if (c === 0x60 && prev !== 0x5c) {
391 inTemplateString = false;
392 }
393 }
394 else if (inRegex) {
395 if (c === 0x2f && prev !== 0x5c) {
396 inRegex = false;
397 }
398 }
399 else if (c === 0x7c &&
400 exp.charCodeAt(i + 1) !== 0x7c &&
401 exp.charCodeAt(i - 1) !== 0x7c &&
402 !curly &&
403 !square &&
404 !paren) {
405 result.push(exp.slice(lastFilterIndex, i));
406 lastFilterIndex = i + 1;
407 }
408 else {
409 switch (c) {
410 case 0x22:
411 inDouble = true;
412 break;
413 case 0x27:
414 inSingle = true;
415 break;
416 case 0x60:
417 inTemplateString = true;
418 break;
419 case 0x28:
420 paren++;
421 break;
422 case 0x29:
423 paren--;
424 break;
425 case 0x5b:
426 square++;
427 break;
428 case 0x5d:
429 square--;
430 break;
431 case 0x7b:
432 curly++;
433 break;
434 case 0x7d:
435 curly--;
436 break;
437 }
438 if (c === 0x2f) {
439 let j = i - 1;
440 let p;
441 for (; j >= 0; j--) {
442 p = exp.charAt(j);
443 if (p !== " ") {
444 break;
445 }
446 }
447 if (!p || !validDivisionCharRE.test(p)) {
448 inRegex = true;
449 }
450 }
451 }
452 }
453 result.push(exp.slice(lastFilterIndex));
454 return result;
455}
456function parseExpressionBody(code, locationCalculator, parserOptions, allowEmpty = false) {
457 debug('[script] parse expression: "0(%s)"', code);
458 try {
459 const ast = parseScriptFragment(`0(${code})`, locationCalculator.getSubCalculatorAfter(-2), parserOptions).ast;
460 const tokens = ast.tokens || [];
461 const comments = ast.comments || [];
462 const references = analyzeExternalReferences(ast, parserOptions);
463 const statement = ast.body[0];
464 const callExpression = statement.expression;
465 const expression = callExpression.arguments[0];
466 if (!allowEmpty && !expression) {
467 return throwEmptyError(locationCalculator, "an expression");
468 }
469 if (expression && expression.type === "SpreadElement") {
470 return throwUnexpectedTokenError("...", expression);
471 }
472 if (callExpression.arguments[1]) {
473 const node = callExpression.arguments[1];
474 return throwUnexpectedTokenError(",", getCommaTokenBeforeNode(tokens, node) || node);
475 }
476 tokens.shift();
477 tokens.shift();
478 tokens.pop();
479 return { expression, tokens, comments, references, variables: [] };
480 }
481 catch (err) {
482 return throwErrorAsAdjustingOutsideOfCode(err, code, locationCalculator);
483 }
484}
485function parseFilter(code, locationCalculator, parserOptions) {
486 debug('[script] parse filter: "%s"', code);
487 try {
488 const expression = {
489 type: "VFilter",
490 parent: null,
491 range: [0, 0],
492 loc: {},
493 callee: null,
494 arguments: [],
495 };
496 const tokens = [];
497 const comments = [];
498 const references = [];
499 const paren = code.indexOf("(");
500 const calleeCode = paren === -1 ? code : code.slice(0, paren);
501 const argsCode = paren === -1 ? null : code.slice(paren);
502 if (calleeCode.trim()) {
503 const spaces = /^\s*/u.exec(calleeCode)[0];
504 const { ast } = parseScriptFragment(`${spaces}"${calleeCode.trim()}"`, locationCalculator, parserOptions);
505 const statement = ast.body[0];
506 const callee = statement.expression;
507 if (callee.type !== "Literal") {
508 const { loc, range } = ast.tokens[0];
509 return throwUnexpectedTokenError('"', {
510 range: [range[1] - 1, range[1]],
511 loc: {
512 start: {
513 line: loc.end.line,
514 column: loc.end.column - 1,
515 },
516 end: loc.end,
517 },
518 });
519 }
520 expression.callee = {
521 type: "Identifier",
522 parent: expression,
523 range: [callee.range[0], callee.range[1] - 2],
524 loc: {
525 start: callee.loc.start,
526 end: locationCalculator.getLocation(callee.range[1] - callee.range[0] - 1),
527 },
528 name: String(callee.value),
529 };
530 tokens.push({
531 type: "Identifier",
532 value: calleeCode.trim(),
533 range: expression.callee.range,
534 loc: expression.callee.loc,
535 });
536 }
537 else {
538 return throwEmptyError(locationCalculator, "a filter name");
539 }
540 if (argsCode != null) {
541 const { ast } = parseScriptFragment(`0${argsCode}`, locationCalculator.getSubCalculatorAfter(paren - 1), parserOptions);
542 const statement = ast.body[0];
543 const callExpression = statement.expression;
544 ast.tokens.shift();
545 if (callExpression.type !== "CallExpression" ||
546 callExpression.callee.type !== "Literal") {
547 let nestCount = 1;
548 for (const token of ast.tokens.slice(1)) {
549 if (nestCount === 0) {
550 return throwUnexpectedTokenError(token.value, token);
551 }
552 if (token.type === "Punctuator" && token.value === "(") {
553 nestCount += 1;
554 }
555 if (token.type === "Punctuator" && token.value === ")") {
556 nestCount -= 1;
557 }
558 }
559 const token = last(ast.tokens);
560 return throwUnexpectedTokenError(token.value, token);
561 }
562 for (const argument of callExpression.arguments) {
563 argument.parent = expression;
564 expression.arguments.push(argument);
565 }
566 tokens.push(...ast.tokens);
567 comments.push(...ast.comments);
568 references.push(...analyzeExternalReferences(ast, parserOptions));
569 }
570 const firstToken = tokens[0];
571 const lastToken = last(tokens);
572 expression.range = [firstToken.range[0], lastToken.range[1]];
573 expression.loc = { start: firstToken.loc.start, end: lastToken.loc.end };
574 return { expression, tokens, comments, references, variables: [] };
575 }
576 catch (err) {
577 return throwErrorAsAdjustingOutsideOfCode(err, code, locationCalculator);
578 }
579}
580function parseScript(code, parserOptions) {
581 const parser = typeof parserOptions.parser === "string"
582 ? require(parserOptions.parser)
583 : require("espree");
584 const result = typeof parser.parseForESLint === "function"
585 ? parser.parseForESLint(code, parserOptions)
586 : parser.parse(code, parserOptions);
587 if (result.ast != null) {
588 return result;
589 }
590 return { ast: result };
591}
592function parseScriptElement(node, globalLocationCalculator, parserOptions) {
593 const text = node.children[0];
594 const offset = text != null && text.type === "VText"
595 ? text.range[0]
596 : node.startTag.range[1];
597 const code = text != null && text.type === "VText" ? text.value : "";
598 const locationCalculator = globalLocationCalculator.getSubCalculatorAfter(offset);
599 const result = parseScriptFragment(code, locationCalculator, parserOptions);
600 if (result.ast.tokens != null) {
601 const startTag = node.startTag;
602 const endTag = node.endTag;
603 if (startTag != null) {
604 result.ast.tokens.unshift({
605 type: "Punctuator",
606 range: startTag.range,
607 loc: startTag.loc,
608 value: "<script>",
609 });
610 }
611 if (endTag != null) {
612 result.ast.tokens.push({
613 type: "Punctuator",
614 range: endTag.range,
615 loc: endTag.loc,
616 value: "</script>",
617 });
618 }
619 }
620 return result;
621}
622function parseExpression(code, locationCalculator, parserOptions, { allowEmpty = false, allowFilters = false } = {}) {
623 debug('[script] parse expression: "%s"', code);
624 const [mainCode, ...filterCodes] = allowFilters
625 ? splitFilters(code)
626 : [code];
627 if (filterCodes.length === 0) {
628 return parseExpressionBody(code, locationCalculator, parserOptions, allowEmpty);
629 }
630 const retB = parseExpressionBody(mainCode, locationCalculator, parserOptions);
631 if (!retB.expression) {
632 return retB;
633 }
634 const ret = retB;
635 ret.expression = {
636 type: "VFilterSequenceExpression",
637 parent: null,
638 expression: retB.expression,
639 filters: [],
640 range: retB.expression.range.slice(0),
641 loc: Object.assign({}, retB.expression.loc),
642 };
643 ret.expression.expression.parent = ret.expression;
644 let prevLoc = mainCode.length;
645 for (const filterCode of filterCodes) {
646 ret.tokens.push(locationCalculator.fixLocation({
647 type: "Punctuator",
648 value: "|",
649 range: [prevLoc, prevLoc + 1],
650 loc: {},
651 }));
652 const retF = parseFilter(filterCode, locationCalculator.getSubCalculatorAfter(prevLoc + 1), parserOptions);
653 if (retF) {
654 if (retF.expression) {
655 ret.expression.filters.push(retF.expression);
656 retF.expression.parent = ret.expression;
657 }
658 ret.tokens.push(...retF.tokens);
659 ret.comments.push(...retF.comments);
660 ret.references.push(...retF.references);
661 }
662 prevLoc += 1 + filterCode.length;
663 }
664 const lastToken = last(ret.tokens);
665 ret.expression.range[1] = lastToken.range[1];
666 ret.expression.loc.end = lastToken.loc.end;
667 return ret;
668}
669function parseVForExpression(code, locationCalculator, parserOptions) {
670 const processedCode = replaceAliasParens(code);
671 debug('[script] parse v-for expression: "for(%s);"', processedCode);
672 if (code.trim() === "") {
673 throwEmptyError(locationCalculator, "'<alias> in <expression>'");
674 }
675 try {
676 const replaced = processedCode !== code;
677 const ast = parseScriptFragment(`for(let ${processedCode});`, locationCalculator.getSubCalculatorAfter(-8), parserOptions).ast;
678 const tokens = ast.tokens || [];
679 const comments = ast.comments || [];
680 const scope = analyzeVariablesAndExternalReferences(ast, parserOptions);
681 const references = scope.references;
682 const variables = scope.variables;
683 const statement = ast.body[0];
684 const left = normalizeLeft(statement.left, replaced);
685 const right = statement.right;
686 const firstToken = tokens[3] || statement.left;
687 const lastToken = tokens[tokens.length - 3] || statement.right;
688 const expression = {
689 type: "VForExpression",
690 range: [firstToken.range[0], lastToken.range[1]],
691 loc: { start: firstToken.loc.start, end: lastToken.loc.end },
692 parent: DUMMY_PARENT,
693 left,
694 right,
695 };
696 for (const l of left) {
697 if (l != null) {
698 l.parent = expression;
699 }
700 }
701 right.parent = expression;
702 tokens.shift();
703 tokens.shift();
704 tokens.shift();
705 tokens.pop();
706 tokens.pop();
707 if (replaced) {
708 const closeOffset = statement.left.range[1] - 1;
709 const open = tokens[0];
710 const close = tokens.find(t => t.range[0] === closeOffset);
711 if (open != null) {
712 open.value = "(";
713 }
714 if (close != null) {
715 close.value = ")";
716 }
717 }
718 return { expression, tokens, comments, references, variables };
719 }
720 catch (err) {
721 return throwErrorAsAdjustingOutsideOfCode(err, code, locationCalculator);
722 }
723}
724function parseVOnExpression(code, locationCalculator, parserOptions) {
725 if (IS_FUNCTION_EXPRESSION.test(code) || IS_SIMPLE_PATH.test(code)) {
726 return parseExpressionBody(code, locationCalculator, parserOptions);
727 }
728 return parseVOnExpressionBody(code, locationCalculator, parserOptions);
729}
730function parseVOnExpressionBody(code, locationCalculator, parserOptions) {
731 debug('[script] parse v-on expression: "void function($event){%s}"', code);
732 if (code.trim() === "") {
733 throwEmptyError(locationCalculator, "statements");
734 }
735 try {
736 const ast = parseScriptFragment(`void function($event){${code}}`, locationCalculator.getSubCalculatorAfter(-22), parserOptions).ast;
737 const references = analyzeExternalReferences(ast, parserOptions);
738 const outermostStatement = ast.body[0];
739 const functionDecl = outermostStatement.expression
740 .argument;
741 const block = functionDecl.body;
742 const body = block.body;
743 const firstStatement = first(body);
744 const lastStatement = last(body);
745 const expression = {
746 type: "VOnExpression",
747 range: [
748 firstStatement != null
749 ? firstStatement.range[0]
750 : block.range[0] + 1,
751 lastStatement != null
752 ? lastStatement.range[1]
753 : block.range[1] - 1,
754 ],
755 loc: {
756 start: firstStatement != null
757 ? firstStatement.loc.start
758 : locationCalculator.getLocation(1),
759 end: lastStatement != null
760 ? lastStatement.loc.end
761 : locationCalculator.getLocation(code.length + 1),
762 },
763 parent: DUMMY_PARENT,
764 body,
765 };
766 const tokens = ast.tokens || [];
767 const comments = ast.comments || [];
768 for (const b of body) {
769 b.parent = expression;
770 }
771 tokens.splice(0, 6);
772 tokens.pop();
773 return { expression, tokens, comments, references, variables: [] };
774 }
775 catch (err) {
776 return throwErrorAsAdjustingOutsideOfCode(err, code, locationCalculator);
777 }
778}
779function parseSlotScopeExpression(code, locationCalculator, parserOptions) {
780 debug('[script] parse slot-scope expression: "void function(%s) {}"', code);
781 if (code.trim() === "") {
782 throwEmptyError(locationCalculator, "an identifier or an array/object pattern");
783 }
784 try {
785 const ast = parseScriptFragment(`void function(${code}) {}`, locationCalculator.getSubCalculatorAfter(-14), parserOptions).ast;
786 const statement = ast.body[0];
787 const rawExpression = statement.expression;
788 const functionDecl = rawExpression.argument;
789 const params = functionDecl.params;
790 if (params.length === 0) {
791 return {
792 expression: null,
793 tokens: [],
794 comments: [],
795 references: [],
796 variables: [],
797 };
798 }
799 const tokens = ast.tokens || [];
800 const comments = ast.comments || [];
801 const scope = analyzeVariablesAndExternalReferences(ast, parserOptions);
802 const references = scope.references;
803 const variables = scope.variables;
804 const firstParam = first(params);
805 const lastParam = last(params);
806 const expression = {
807 type: "VSlotScopeExpression",
808 range: [firstParam.range[0], lastParam.range[1]],
809 loc: { start: firstParam.loc.start, end: lastParam.loc.end },
810 parent: DUMMY_PARENT,
811 params: functionDecl.params,
812 };
813 for (const param of params) {
814 param.parent = expression;
815 }
816 tokens.shift();
817 tokens.shift();
818 tokens.shift();
819 tokens.pop();
820 tokens.pop();
821 tokens.pop();
822 return { expression, tokens, comments, references, variables };
823 }
824 catch (err) {
825 return throwErrorAsAdjustingOutsideOfCode(err, code, locationCalculator);
826 }
827}
828
829const shorthandSign = /^[.:@#]/u;
830const shorthandNameMap = { ":": "bind", ".": "bind", "@": "on", "#": "slot" };
831const invalidDynamicArgumentNextChar = /^[\s\r\n=/>]$/u;
832function getOwnerDocument(leafNode) {
833 let node = leafNode;
834 while (node != null && node.type !== "VDocumentFragment") {
835 node = node.parent;
836 }
837 return node;
838}
839function createSimpleToken(type, start, end, value, globalLocationCalculator) {
840 return {
841 type,
842 range: [start, end],
843 loc: {
844 start: globalLocationCalculator.getLocation(start),
845 end: globalLocationCalculator.getLocation(end),
846 },
847 value,
848 };
849}
850function parseDirectiveKeyStatically(node, document) {
851 const { name: text, rawName: rawText, range: [offset], loc: { start: { column, line }, }, } = node;
852 const directiveKey = {
853 type: "VDirectiveKey",
854 range: node.range,
855 loc: node.loc,
856 parent: node.parent,
857 name: null,
858 argument: null,
859 modifiers: [],
860 };
861 let i = 0;
862 function createIdentifier(start, end, name) {
863 return {
864 type: "VIdentifier",
865 parent: directiveKey,
866 range: [offset + start, offset + end],
867 loc: {
868 start: { column: column + start, line },
869 end: { column: column + end, line },
870 },
871 name: name || text.slice(start, end),
872 rawName: rawText.slice(start, end),
873 };
874 }
875 if (shorthandSign.test(text)) {
876 const sign = text[0];
877 directiveKey.name = createIdentifier(0, 1, shorthandNameMap[sign]);
878 i = 1;
879 }
880 else {
881 const colon = text.indexOf(":");
882 if (colon !== -1) {
883 directiveKey.name = createIdentifier(0, colon);
884 i = colon + 1;
885 }
886 }
887 if (directiveKey.name != null && text[i] === "[") {
888 const len = text.slice(i).lastIndexOf("]");
889 if (len !== -1) {
890 directiveKey.argument = createIdentifier(i, i + len + 1);
891 i = i + len + 1 + (text[i + len + 1] === "." ? 1 : 0);
892 }
893 }
894 const modifiers = text
895 .slice(i)
896 .split(".")
897 .map(modifierName => {
898 const modifier = createIdentifier(i, i + modifierName.length);
899 if (modifierName === "" && i < text.length) {
900 insertError(document, new ParseError(`Unexpected token '${text[i]}'`, undefined, offset + i, line, column + i));
901 }
902 i += modifierName.length + 1;
903 return modifier;
904 });
905 if (directiveKey.name == null) {
906 directiveKey.name = modifiers.shift();
907 }
908 else if (directiveKey.argument == null && modifiers[0].name !== "") {
909 directiveKey.argument = modifiers.shift() || null;
910 }
911 directiveKey.modifiers = modifiers.filter(isNotEmptyModifier);
912 if (directiveKey.name.name === "v-") {
913 insertError(document, new ParseError(`Unexpected token '${text[directiveKey.name.range[1] - offset]}'`, undefined, directiveKey.name.range[1], directiveKey.name.loc.end.line, directiveKey.name.loc.end.column));
914 }
915 if (directiveKey.name.rawName === "." &&
916 !directiveKey.modifiers.some(isPropModifier)) {
917 const pos = (directiveKey.argument || directiveKey.name).range[1] - offset;
918 const propModifier = createIdentifier(pos, pos, "prop");
919 directiveKey.modifiers.unshift(propModifier);
920 }
921 return directiveKey;
922}
923function isPropModifier(node) {
924 return node.name === "prop";
925}
926function isNotEmptyModifier(node) {
927 return node.name !== "";
928}
929function parseDirectiveKeyTokens(node) {
930 const { name, argument, modifiers } = node;
931 const shorthand = name.range[1] - name.range[0] === 1;
932 const tokens = [];
933 if (shorthand) {
934 tokens.push({
935 type: "Punctuator",
936 range: name.range,
937 loc: name.loc,
938 value: name.rawName,
939 });
940 }
941 else {
942 tokens.push({
943 type: "HTMLIdentifier",
944 range: name.range,
945 loc: name.loc,
946 value: name.rawName,
947 });
948 if (argument) {
949 tokens.push({
950 type: "Punctuator",
951 range: [name.range[1], argument.range[0]],
952 loc: { start: name.loc.end, end: argument.loc.start },
953 value: ":",
954 });
955 }
956 }
957 if (argument) {
958 tokens.push({
959 type: "HTMLIdentifier",
960 range: argument.range,
961 loc: argument.loc,
962 value: argument.rawName,
963 });
964 }
965 let lastNode = argument || name;
966 for (const modifier of modifiers) {
967 if (modifier.rawName === "") {
968 continue;
969 }
970 tokens.push({
971 type: "Punctuator",
972 range: [lastNode.range[1], modifier.range[0]],
973 loc: { start: lastNode.loc.end, end: modifier.loc.start },
974 value: ".",
975 }, {
976 type: "HTMLIdentifier",
977 range: modifier.range,
978 loc: modifier.loc,
979 value: modifier.rawName,
980 });
981 lastNode = modifier;
982 }
983 return tokens;
984}
985function convertDynamicArgument(node, document, parserOptions, locationCalculator) {
986 const { argument } = node;
987 if (!(argument != null &&
988 argument.type === "VIdentifier" &&
989 argument.name.startsWith("[") &&
990 argument.name.endsWith("]"))) {
991 return;
992 }
993 const { rawName, range, loc } = argument;
994 try {
995 const { comments, expression, references, tokens } = parseExpression(rawName.slice(1, -1), locationCalculator.getSubCalculatorAfter(range[0] + 1), parserOptions);
996 node.argument = {
997 type: "VExpressionContainer",
998 range,
999 loc,
1000 parent: node,
1001 expression,
1002 references,
1003 };
1004 if (expression != null) {
1005 expression.parent = node.argument;
1006 }
1007 tokens.unshift(createSimpleToken("Punctuator", range[0], range[0] + 1, "[", locationCalculator));
1008 tokens.push(createSimpleToken("Punctuator", range[1] - 1, range[1], "]", locationCalculator));
1009 replaceTokens(document, node.argument, tokens);
1010 insertComments(document, comments);
1011 }
1012 catch (error) {
1013 debug("[template] Parse error: %s", error);
1014 if (ParseError.isParseError(error)) {
1015 node.argument = {
1016 type: "VExpressionContainer",
1017 range,
1018 loc,
1019 parent: node,
1020 expression: null,
1021 references: [],
1022 };
1023 insertError(document, error);
1024 }
1025 else {
1026 throw error;
1027 }
1028 }
1029}
1030function createDirectiveKey(node, document, parserOptions, locationCalculator) {
1031 const directiveKey = parseDirectiveKeyStatically(node, document);
1032 const tokens = parseDirectiveKeyTokens(directiveKey);
1033 replaceTokens(document, directiveKey, tokens);
1034 if (directiveKey.name.name.startsWith("v-")) {
1035 directiveKey.name.name = directiveKey.name.name.slice(2);
1036 }
1037 if (directiveKey.name.rawName.startsWith("v-")) {
1038 directiveKey.name.rawName = directiveKey.name.rawName.slice(2);
1039 }
1040 convertDynamicArgument(directiveKey, document, parserOptions, locationCalculator);
1041 return directiveKey;
1042}
1043function byRange0(x) {
1044 return x.range[0];
1045}
1046function byRange1(x) {
1047 return x.range[1];
1048}
1049function byIndex(x) {
1050 return x.index;
1051}
1052function replaceTokens(document, node, newTokens) {
1053 if (document == null) {
1054 return;
1055 }
1056 const index = sortedIndexBy(document.tokens, node, byRange0);
1057 const count = sortedLastIndexBy(document.tokens, node, byRange1) - index;
1058 document.tokens.splice(index, count, ...newTokens);
1059}
1060function insertComments(document, newComments) {
1061 if (document == null || newComments.length === 0) {
1062 return;
1063 }
1064 const index = sortedIndexBy(document.comments, newComments[0], byRange0);
1065 document.comments.splice(index, 0, ...newComments);
1066}
1067function insertError(document, error) {
1068 if (document == null) {
1069 return;
1070 }
1071 const index = sortedIndexBy(document.errors, error, byIndex);
1072 document.errors.splice(index, 0, error);
1073}
1074function parseAttributeValue(code, parserOptions, globalLocationCalculator, node, tagName, directiveKey) {
1075 const firstChar = code[node.range[0]];
1076 const quoted = firstChar === '"' || firstChar === "'";
1077 const locationCalculator = globalLocationCalculator.getSubCalculatorAfter(node.range[0] + (quoted ? 1 : 0));
1078 const directiveName = directiveKey.name.name;
1079 let result;
1080 if (quoted && node.value === "") {
1081 result = {
1082 expression: null,
1083 tokens: [],
1084 comments: [],
1085 variables: [],
1086 references: [],
1087 };
1088 }
1089 else if (directiveName === "for") {
1090 result = parseVForExpression(node.value, locationCalculator, parserOptions);
1091 }
1092 else if (directiveName === "on" && directiveKey.argument != null) {
1093 result = parseVOnExpression(node.value, locationCalculator, parserOptions);
1094 }
1095 else if (directiveName === "slot" ||
1096 directiveName === "slot-scope" ||
1097 (tagName === "template" && directiveName === "scope")) {
1098 result = parseSlotScopeExpression(node.value, locationCalculator, parserOptions);
1099 }
1100 else if (directiveName === "bind") {
1101 result = parseExpression(node.value, locationCalculator, parserOptions, { allowFilters: true });
1102 }
1103 else {
1104 result = parseExpression(node.value, locationCalculator, parserOptions);
1105 }
1106 if (quoted) {
1107 result.tokens.unshift(createSimpleToken("Punctuator", node.range[0], node.range[0] + 1, firstChar, globalLocationCalculator));
1108 result.tokens.push(createSimpleToken("Punctuator", node.range[1] - 1, node.range[1], firstChar, globalLocationCalculator));
1109 }
1110 return result;
1111}
1112function resolveReference(referene, element) {
1113 let node = element;
1114 while (node != null && node.type === "VElement") {
1115 for (const variable of node.variables) {
1116 if (variable.id.name === referene.id.name) {
1117 referene.variable = variable;
1118 variable.references.push(referene);
1119 return;
1120 }
1121 }
1122 node = node.parent;
1123 }
1124}
1125function convertToDirective(code, parserOptions, locationCalculator, node) {
1126 debug('[template] convert to directive: %s="%s" %j', node.key.name, node.value && node.value.value, node.range);
1127 const document = getOwnerDocument(node);
1128 const directive = node;
1129 directive.directive = true;
1130 directive.key = createDirectiveKey(node.key, document, parserOptions, locationCalculator);
1131 const { argument } = directive.key;
1132 if (argument &&
1133 argument.type === "VIdentifier" &&
1134 argument.name.startsWith("[")) {
1135 const nextChar = code[argument.range[1]];
1136 if (nextChar == null || invalidDynamicArgumentNextChar.test(nextChar)) {
1137 const char = nextChar == null ? "EOF" : JSON.stringify(nextChar).slice(1, -1);
1138 insertError(document, new ParseError(`Dynamic argument cannot contain the '${char}' character.`, undefined, argument.range[1], argument.loc.end.line, argument.loc.end.column));
1139 }
1140 }
1141 if (node.value == null) {
1142 return;
1143 }
1144 try {
1145 const ret = parseAttributeValue(code, parserOptions, locationCalculator, node.value, node.parent.parent.name, directive.key);
1146 directive.value = {
1147 type: "VExpressionContainer",
1148 range: node.value.range,
1149 loc: node.value.loc,
1150 parent: directive,
1151 expression: ret.expression,
1152 references: ret.references,
1153 };
1154 if (ret.expression != null) {
1155 ret.expression.parent = directive.value;
1156 }
1157 for (const variable of ret.variables) {
1158 node.parent.parent.variables.push(variable);
1159 }
1160 replaceTokens(document, node.value, ret.tokens);
1161 insertComments(document, ret.comments);
1162 }
1163 catch (err) {
1164 debug("[template] Parse error: %s", err);
1165 if (ParseError.isParseError(err)) {
1166 directive.value = {
1167 type: "VExpressionContainer",
1168 range: node.value.range,
1169 loc: node.value.loc,
1170 parent: directive,
1171 expression: null,
1172 references: [],
1173 };
1174 insertError(document, err);
1175 }
1176 else {
1177 throw err;
1178 }
1179 }
1180}
1181function processMustache(parserOptions, globalLocationCalculator, node, mustache) {
1182 const range = [
1183 mustache.startToken.range[1],
1184 mustache.endToken.range[0],
1185 ];
1186 debug("[template] convert mustache {{%s}} %j", mustache.value, range);
1187 const document = getOwnerDocument(node);
1188 try {
1189 const locationCalculator = globalLocationCalculator.getSubCalculatorAfter(range[0]);
1190 const ret = parseExpression(mustache.value, locationCalculator, parserOptions, { allowEmpty: true, allowFilters: true });
1191 node.expression = ret.expression || null;
1192 node.references = ret.references;
1193 if (ret.expression != null) {
1194 ret.expression.parent = node;
1195 }
1196 replaceTokens(document, { range }, ret.tokens);
1197 insertComments(document, ret.comments);
1198 }
1199 catch (err) {
1200 debug("[template] Parse error: %s", err);
1201 if (ParseError.isParseError(err)) {
1202 insertError(document, err);
1203 }
1204 else {
1205 throw err;
1206 }
1207 }
1208}
1209function resolveReferences(container) {
1210 let element = container.parent;
1211 while (element != null && element.type !== "VElement") {
1212 element = element.parent;
1213 }
1214 if (element != null) {
1215 for (const reference of container.references) {
1216 resolveReference(reference, element);
1217 }
1218 }
1219}
1220
1221const SVG_ATTRIBUTE_NAME_MAP = new Map([
1222 ["attributename", "attributeName"],
1223 ["attributetype", "attributeType"],
1224 ["basefrequency", "baseFrequency"],
1225 ["baseprofile", "baseProfile"],
1226 ["calcmode", "calcMode"],
1227 ["clippathunits", "clipPathUnits"],
1228 ["diffuseconstant", "diffuseConstant"],
1229 ["edgemode", "edgeMode"],
1230 ["filterunits", "filterUnits"],
1231 ["glyphref", "glyphRef"],
1232 ["gradienttransform", "gradientTransform"],
1233 ["gradientunits", "gradientUnits"],
1234 ["kernelmatrix", "kernelMatrix"],
1235 ["kernelunitlength", "kernelUnitLength"],
1236 ["keypoints", "keyPoints"],
1237 ["keysplines", "keySplines"],
1238 ["keytimes", "keyTimes"],
1239 ["lengthadjust", "lengthAdjust"],
1240 ["limitingconeangle", "limitingConeAngle"],
1241 ["markerheight", "markerHeight"],
1242 ["markerunits", "markerUnits"],
1243 ["markerwidth", "markerWidth"],
1244 ["maskcontentunits", "maskContentUnits"],
1245 ["maskunits", "maskUnits"],
1246 ["numoctaves", "numOctaves"],
1247 ["pathlength", "pathLength"],
1248 ["patterncontentunits", "patternContentUnits"],
1249 ["patterntransform", "patternTransform"],
1250 ["patternunits", "patternUnits"],
1251 ["pointsatx", "pointsAtX"],
1252 ["pointsaty", "pointsAtY"],
1253 ["pointsatz", "pointsAtZ"],
1254 ["preservealpha", "preserveAlpha"],
1255 ["preserveaspectratio", "preserveAspectRatio"],
1256 ["primitiveunits", "primitiveUnits"],
1257 ["refx", "refX"],
1258 ["refy", "refY"],
1259 ["repeatcount", "repeatCount"],
1260 ["repeatdur", "repeatDur"],
1261 ["requiredextensions", "requiredExtensions"],
1262 ["requiredfeatures", "requiredFeatures"],
1263 ["specularconstant", "specularConstant"],
1264 ["specularexponent", "specularExponent"],
1265 ["spreadmethod", "spreadMethod"],
1266 ["startoffset", "startOffset"],
1267 ["stddeviation", "stdDeviation"],
1268 ["stitchtiles", "stitchTiles"],
1269 ["surfacescale", "surfaceScale"],
1270 ["systemlanguage", "systemLanguage"],
1271 ["tablevalues", "tableValues"],
1272 ["targetx", "targetX"],
1273 ["targety", "targetY"],
1274 ["textlength", "textLength"],
1275 ["viewbox", "viewBox"],
1276 ["viewtarget", "viewTarget"],
1277 ["xchannelselector", "xChannelSelector"],
1278 ["ychannelselector", "yChannelSelector"],
1279 ["zoomandpan", "zoomAndPan"],
1280]);
1281const MATHML_ATTRIBUTE_NAME_MAP = new Map([
1282 ["definitionurl", "definitionUrl"]
1283]);
1284
1285const HTML_VOID_ELEMENT_TAGS = new Set([
1286 "area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta",
1287 "param", "source", "track", "wbr",
1288]);
1289const HTML_CAN_BE_LEFT_OPEN_TAGS = new Set([
1290 "colgroup", "li", "options", "p", "td", "tfoot", "th", "thead",
1291 "tr", "source",
1292]);
1293const HTML_NON_FHRASING_TAGS = new Set([
1294 "address", "article", "aside", "base", "blockquote", "body", "caption",
1295 "col", "colgroup", "dd", "details", "dialog", "div", "dl", "dt", "fieldset",
1296 "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5",
1297 "h6", "head", "header", "hgroup", "hr", "html", "legend", "li", "menuitem",
1298 "meta", "optgroup", "option", "param", "rp", "rt", "source", "style",
1299 "summary", "tbody", "td", "tfoot", "th", "thead", "title", "tr", "track",
1300]);
1301const HTML_RCDATA_TAGS = new Set([
1302 "title", "textarea",
1303]);
1304const HTML_RAWTEXT_TAGS = new Set([
1305 "style", "xmp", "iframe", "noembed", "noframes", "noscript", "script",
1306]);
1307const SVG_TAGS = new Set([
1308 "a", "altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor",
1309 "animateMotion", "animateTransform", "animation", "audio", "canvas",
1310 "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "discard",
1311 "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite",
1312 "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap",
1313 "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB",
1314 "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode",
1315 "feMorphology", "feOffset", "fePointLight", "feSpecularLighting",
1316 "feSpotLight", "feTile", "feTurbulence", "filter", "font", "font-face",
1317 "font-face-format", "font-face-name", "font-face-src", "font-face-uri",
1318 "foreignObject", "g", "glyph", "glyphRef", "handler", "hatch", "hatchpath",
1319 "hkern", "iframe", "image", "line", "linearGradient", "listener", "marker",
1320 "mask", "mesh", "meshgradient", "meshpatch", "meshrow", "metadata",
1321 "missing-glyph", "mpath", "path", "pattern", "polygon", "polyline",
1322 "prefetch", "radialGradient", "rect", "script", "set", "solidColor",
1323 "solidcolor", "stop", "style", "svg", "switch", "symbol", "tbreak", "text",
1324 "textArea", "textPath", "title", "tref", "tspan", "unknown", "use", "video",
1325 "view", "vkern",
1326]);
1327const SVG_ELEMENT_NAME_MAP = new Map();
1328for (const name of SVG_TAGS) {
1329 if (/[A-Z]/.test(name)) {
1330 SVG_ELEMENT_NAME_MAP.set(name.toLowerCase(), name);
1331 }
1332}
1333
1334const DUMMY_PARENT$1 = Object.freeze({});
1335function concat(text, token) {
1336 return text + token.value;
1337}
1338class IntermediateTokenizer {
1339 get text() {
1340 return this.tokenizer.text;
1341 }
1342 get errors() {
1343 return this.tokenizer.errors;
1344 }
1345 get state() {
1346 return this.tokenizer.state;
1347 }
1348 set state(value) {
1349 this.tokenizer.state = value;
1350 }
1351 get namespace() {
1352 return this.tokenizer.namespace;
1353 }
1354 set namespace(value) {
1355 this.tokenizer.namespace = value;
1356 }
1357 get expressionEnabled() {
1358 return this.tokenizer.expressionEnabled;
1359 }
1360 set expressionEnabled(value) {
1361 this.tokenizer.expressionEnabled = value;
1362 }
1363 constructor(tokenizer) {
1364 this.tokenizer = tokenizer;
1365 this.currentToken = null;
1366 this.attribute = null;
1367 this.attributeNames = new Set();
1368 this.expressionStartToken = null;
1369 this.expressionTokens = [];
1370 this.tokens = [];
1371 this.comments = [];
1372 }
1373 nextToken() {
1374 let token = null;
1375 let result = null;
1376 while (result == null && (token = this.tokenizer.nextToken()) != null) {
1377 result = this[token.type](token);
1378 }
1379 if (result == null && token == null && this.currentToken != null) {
1380 result = this.commit();
1381 }
1382 return result;
1383 }
1384 commit() {
1385 assert(this.currentToken != null || this.expressionStartToken != null);
1386 let token = this.currentToken;
1387 this.currentToken = null;
1388 this.attribute = null;
1389 if (this.expressionStartToken != null) {
1390 const start = this.expressionStartToken;
1391 const end = last(this.expressionTokens) || start;
1392 const value = this.expressionTokens.reduce(concat, start.value);
1393 this.expressionStartToken = null;
1394 this.expressionTokens = [];
1395 if (token == null) {
1396 token = {
1397 type: "Text",
1398 range: [start.range[0], end.range[1]],
1399 loc: { start: start.loc.start, end: end.loc.end },
1400 value,
1401 };
1402 }
1403 else if (token.type === "Text") {
1404 token.range[1] = end.range[1];
1405 token.loc.end = end.loc.end;
1406 token.value += value;
1407 }
1408 else {
1409 throw new Error("unreachable");
1410 }
1411 }
1412 return token;
1413 }
1414 reportParseError(token, code) {
1415 const error = ParseError.fromCode(code, token.range[0], token.loc.start.line, token.loc.start.column);
1416 this.errors.push(error);
1417 debug("[html] syntax error:", error.message);
1418 }
1419 processComment(token) {
1420 this.comments.push(token);
1421 if (this.currentToken != null && this.currentToken.type === "Text") {
1422 return this.commit();
1423 }
1424 return null;
1425 }
1426 processText(token) {
1427 this.tokens.push(token);
1428 let result = null;
1429 if (this.expressionStartToken != null) {
1430 const lastToken = last(this.expressionTokens) || this.expressionStartToken;
1431 if (lastToken.range[1] === token.range[0]) {
1432 this.expressionTokens.push(token);
1433 return null;
1434 }
1435 result = this.commit();
1436 }
1437 else if (this.currentToken != null) {
1438 if (this.currentToken.type === "Text" &&
1439 this.currentToken.range[1] === token.range[0]) {
1440 this.currentToken.value += token.value;
1441 this.currentToken.range[1] = token.range[1];
1442 this.currentToken.loc.end = token.loc.end;
1443 return null;
1444 }
1445 result = this.commit();
1446 }
1447 assert(this.currentToken == null);
1448 this.currentToken = {
1449 type: "Text",
1450 range: [token.range[0], token.range[1]],
1451 loc: { start: token.loc.start, end: token.loc.end },
1452 value: token.value,
1453 };
1454 return result;
1455 }
1456 HTMLAssociation(token) {
1457 this.tokens.push(token);
1458 if (this.attribute != null) {
1459 this.attribute.range[1] = token.range[1];
1460 this.attribute.loc.end = token.loc.end;
1461 if (this.currentToken == null ||
1462 this.currentToken.type !== "StartTag") {
1463 throw new Error("unreachable");
1464 }
1465 this.currentToken.range[1] = token.range[1];
1466 this.currentToken.loc.end = token.loc.end;
1467 }
1468 return null;
1469 }
1470 HTMLBogusComment(token) {
1471 return this.processComment(token);
1472 }
1473 HTMLCDataText(token) {
1474 return this.processText(token);
1475 }
1476 HTMLComment(token) {
1477 return this.processComment(token);
1478 }
1479 HTMLEndTagOpen(token) {
1480 this.tokens.push(token);
1481 let result = null;
1482 if (this.currentToken != null || this.expressionStartToken != null) {
1483 result = this.commit();
1484 }
1485 this.currentToken = {
1486 type: "EndTag",
1487 range: [token.range[0], token.range[1]],
1488 loc: { start: token.loc.start, end: token.loc.end },
1489 name: token.value,
1490 };
1491 return result;
1492 }
1493 HTMLIdentifier(token) {
1494 this.tokens.push(token);
1495 if (this.currentToken == null ||
1496 this.currentToken.type === "Text" ||
1497 this.currentToken.type === "Mustache") {
1498 throw new Error("unreachable");
1499 }
1500 if (this.currentToken.type === "EndTag") {
1501 this.reportParseError(token, "end-tag-with-attributes");
1502 return null;
1503 }
1504 if (this.attributeNames.has(token.value)) {
1505 this.reportParseError(token, "duplicate-attribute");
1506 }
1507 this.attributeNames.add(token.value);
1508 this.attribute = {
1509 type: "VAttribute",
1510 range: [token.range[0], token.range[1]],
1511 loc: { start: token.loc.start, end: token.loc.end },
1512 parent: DUMMY_PARENT$1,
1513 directive: false,
1514 key: {
1515 type: "VIdentifier",
1516 range: [token.range[0], token.range[1]],
1517 loc: { start: token.loc.start, end: token.loc.end },
1518 parent: DUMMY_PARENT$1,
1519 name: token.value,
1520 rawName: this.text.slice(token.range[0], token.range[1]),
1521 },
1522 value: null,
1523 };
1524 this.attribute.key.parent = this.attribute;
1525 this.currentToken.range[1] = token.range[1];
1526 this.currentToken.loc.end = token.loc.end;
1527 this.currentToken.attributes.push(this.attribute);
1528 return null;
1529 }
1530 HTMLLiteral(token) {
1531 this.tokens.push(token);
1532 if (this.attribute != null) {
1533 this.attribute.range[1] = token.range[1];
1534 this.attribute.loc.end = token.loc.end;
1535 this.attribute.value = {
1536 type: "VLiteral",
1537 range: [token.range[0], token.range[1]],
1538 loc: { start: token.loc.start, end: token.loc.end },
1539 parent: this.attribute,
1540 value: token.value,
1541 };
1542 if (this.currentToken == null ||
1543 this.currentToken.type !== "StartTag") {
1544 throw new Error("unreachable");
1545 }
1546 this.currentToken.range[1] = token.range[1];
1547 this.currentToken.loc.end = token.loc.end;
1548 }
1549 return null;
1550 }
1551 HTMLRCDataText(token) {
1552 return this.processText(token);
1553 }
1554 HTMLRawText(token) {
1555 return this.processText(token);
1556 }
1557 HTMLSelfClosingTagClose(token) {
1558 this.tokens.push(token);
1559 if (this.currentToken == null || this.currentToken.type === "Text") {
1560 throw new Error("unreachable");
1561 }
1562 if (this.currentToken.type === "StartTag") {
1563 this.currentToken.selfClosing = true;
1564 }
1565 else {
1566 this.reportParseError(token, "end-tag-with-trailing-solidus");
1567 }
1568 this.currentToken.range[1] = token.range[1];
1569 this.currentToken.loc.end = token.loc.end;
1570 return this.commit();
1571 }
1572 HTMLTagClose(token) {
1573 this.tokens.push(token);
1574 if (this.currentToken == null || this.currentToken.type === "Text") {
1575 throw new Error("unreachable");
1576 }
1577 this.currentToken.range[1] = token.range[1];
1578 this.currentToken.loc.end = token.loc.end;
1579 return this.commit();
1580 }
1581 HTMLTagOpen(token) {
1582 this.tokens.push(token);
1583 let result = null;
1584 if (this.currentToken != null || this.expressionStartToken != null) {
1585 result = this.commit();
1586 }
1587 this.currentToken = {
1588 type: "StartTag",
1589 range: [token.range[0], token.range[1]],
1590 loc: { start: token.loc.start, end: token.loc.end },
1591 name: token.value,
1592 rawName: this.text.slice(token.range[0] + 1, token.range[1]),
1593 selfClosing: false,
1594 attributes: [],
1595 };
1596 this.attribute = null;
1597 this.attributeNames.clear();
1598 return result;
1599 }
1600 HTMLText(token) {
1601 return this.processText(token);
1602 }
1603 HTMLWhitespace(token) {
1604 return this.processText(token);
1605 }
1606 VExpressionStart(token) {
1607 if (this.expressionStartToken != null) {
1608 return this.processText(token);
1609 }
1610 const separated = this.currentToken != null &&
1611 this.currentToken.range[1] !== token.range[0];
1612 const result = separated ? this.commit() : null;
1613 this.tokens.push(token);
1614 this.expressionStartToken = token;
1615 return result;
1616 }
1617 VExpressionEnd(token) {
1618 if (this.expressionStartToken == null) {
1619 return this.processText(token);
1620 }
1621 const start = this.expressionStartToken;
1622 const end = last(this.expressionTokens) || start;
1623 if (token.range[0] === start.range[1]) {
1624 this.tokens.pop();
1625 this.expressionStartToken = null;
1626 const result = this.processText(start);
1627 this.processText(token);
1628 return result;
1629 }
1630 if (end.range[1] !== token.range[0]) {
1631 const result = this.commit();
1632 this.processText(token);
1633 return result;
1634 }
1635 const value = this.expressionTokens.reduce(concat, "");
1636 this.tokens.push(token);
1637 this.expressionStartToken = null;
1638 this.expressionTokens = [];
1639 const result = this.currentToken != null ? this.commit() : null;
1640 this.currentToken = {
1641 type: "Mustache",
1642 range: [start.range[0], token.range[1]],
1643 loc: { start: start.loc.start, end: token.loc.end },
1644 value,
1645 startToken: start,
1646 endToken: token,
1647 };
1648 return result || this.commit();
1649 }
1650}
1651
1652const DIRECTIVE_NAME = /^(?:v-|[.:@#]).*[^.:@#]$/u;
1653const DT_DD = /^d[dt]$/u;
1654const DUMMY_PARENT$2 = Object.freeze({});
1655function isMathMLIntegrationPoint(element) {
1656 if (element.namespace === NS.MathML) {
1657 const name = element.name;
1658 return (name === "mi" ||
1659 name === "mo" ||
1660 name === "mn" ||
1661 name === "ms" ||
1662 name === "mtext");
1663 }
1664 return false;
1665}
1666function isHTMLIntegrationPoint(element) {
1667 if (element.namespace === NS.MathML) {
1668 return (element.name === "annotation-xml" &&
1669 element.startTag.attributes.some(a => a.directive === false &&
1670 a.key.name === "encoding" &&
1671 a.value != null &&
1672 (a.value.value === "text/html" ||
1673 a.value.value === "application/xhtml+xml")));
1674 }
1675 if (element.namespace === NS.SVG) {
1676 const name = element.name;
1677 return name === "foreignObject" || name === "desc" || name === "title";
1678 }
1679 return false;
1680}
1681function adjustElementName(name, namespace) {
1682 if (namespace === NS.SVG) {
1683 return SVG_ELEMENT_NAME_MAP.get(name) || name;
1684 }
1685 return name;
1686}
1687function adjustAttributeName(name, namespace) {
1688 if (namespace === NS.SVG) {
1689 return SVG_ATTRIBUTE_NAME_MAP.get(name) || name;
1690 }
1691 if (namespace === NS.MathML) {
1692 return MATHML_ATTRIBUTE_NAME_MAP.get(name) || name;
1693 }
1694 return name;
1695}
1696function propagateEndLocation(node) {
1697 const lastChild = (node.type === "VElement" ? node.endTag : null) || last(node.children);
1698 if (lastChild != null) {
1699 node.range[1] = lastChild.range[1];
1700 node.loc.end = lastChild.loc.end;
1701 }
1702}
1703class Parser {
1704 get text() {
1705 return this.tokenizer.text;
1706 }
1707 get tokens() {
1708 return this.tokenizer.tokens;
1709 }
1710 get comments() {
1711 return this.tokenizer.comments;
1712 }
1713 get errors() {
1714 return this.tokenizer.errors;
1715 }
1716 get namespace() {
1717 return this.tokenizer.namespace;
1718 }
1719 set namespace(value) {
1720 this.tokenizer.namespace = value;
1721 }
1722 get expressionEnabled() {
1723 return this.tokenizer.expressionEnabled;
1724 }
1725 set expressionEnabled(value) {
1726 this.tokenizer.expressionEnabled = value;
1727 }
1728 get currentNode() {
1729 return last(this.elementStack) || this.document;
1730 }
1731 get isInVPreElement() {
1732 return this.vPreElement != null;
1733 }
1734 constructor(tokenizer, parserOptions) {
1735 this.tokenizer = new IntermediateTokenizer(tokenizer);
1736 this.locationCalculator = new LocationCalculator(tokenizer.gaps, tokenizer.lineTerminators);
1737 this.parserOptions = parserOptions;
1738 this.document = {
1739 type: "VDocumentFragment",
1740 range: [0, 0],
1741 loc: {
1742 start: { line: 1, column: 0 },
1743 end: { line: 1, column: 0 },
1744 },
1745 parent: null,
1746 children: [],
1747 tokens: this.tokens,
1748 comments: this.comments,
1749 errors: this.errors,
1750 };
1751 this.elementStack = [];
1752 this.vPreElement = null;
1753 }
1754 parse() {
1755 let token = null;
1756 while ((token = this.tokenizer.nextToken()) != null) {
1757 this[token.type](token);
1758 }
1759 this.popElementStackUntil(0);
1760 propagateEndLocation(this.document);
1761 return this.document;
1762 }
1763 reportParseError(token, code) {
1764 const error = ParseError.fromCode(code, token.range[0], token.loc.start.line, token.loc.start.column);
1765 this.errors.push(error);
1766 debug("[html] syntax error:", error.message);
1767 }
1768 popElementStack() {
1769 assert(this.elementStack.length >= 1);
1770 const element = this.elementStack.pop();
1771 propagateEndLocation(element);
1772 const current = this.currentNode;
1773 this.namespace =
1774 current.type === "VElement" ? current.namespace : NS.HTML;
1775 if (this.vPreElement === element) {
1776 this.vPreElement = null;
1777 this.expressionEnabled = true;
1778 }
1779 if (this.elementStack.length === 0) {
1780 this.expressionEnabled = false;
1781 }
1782 }
1783 popElementStackUntil(index) {
1784 while (this.elementStack.length > index) {
1785 this.popElementStack();
1786 }
1787 }
1788 detectNamespace(token) {
1789 const name = token.name;
1790 let ns = this.namespace;
1791 if (ns === NS.MathML || ns === NS.SVG) {
1792 const element = this.currentNode;
1793 if (element.type === "VElement") {
1794 if (element.namespace === NS.MathML &&
1795 element.name === "annotation-xml" &&
1796 name === "svg") {
1797 return NS.SVG;
1798 }
1799 if (isHTMLIntegrationPoint(element) ||
1800 (isMathMLIntegrationPoint(element) &&
1801 name !== "mglyph" &&
1802 name !== "malignmark")) {
1803 ns = NS.HTML;
1804 }
1805 }
1806 }
1807 if (ns === NS.HTML) {
1808 if (name === "svg") {
1809 return NS.SVG;
1810 }
1811 if (name === "math") {
1812 return NS.MathML;
1813 }
1814 }
1815 if (name === "template") {
1816 const xmlns = token.attributes.find(a => a.key.name === "xmlns");
1817 const value = xmlns && xmlns.value && xmlns.value.value;
1818 if (value === NS.HTML || value === NS.MathML || value === NS.SVG) {
1819 return value;
1820 }
1821 }
1822 return ns;
1823 }
1824 closeCurrentElementIfNecessary(name) {
1825 const element = this.currentNode;
1826 if (element.type !== "VElement") {
1827 return;
1828 }
1829 if (element.name === "p" && HTML_NON_FHRASING_TAGS.has(name)) {
1830 this.popElementStack();
1831 }
1832 if (element.name === name && HTML_CAN_BE_LEFT_OPEN_TAGS.has(name)) {
1833 this.popElementStack();
1834 }
1835 if (DT_DD.test(element.name) && DT_DD.test(name)) {
1836 this.popElementStack();
1837 }
1838 }
1839 processAttribute(node, namespace) {
1840 const tagName = node.parent.parent.name;
1841 const attrName = node.key.name;
1842 if ((this.expressionEnabled ||
1843 (attrName === "v-pre" && !this.isInVPreElement)) &&
1844 (DIRECTIVE_NAME.test(attrName) ||
1845 attrName === "slot-scope" ||
1846 (tagName === "template" && attrName === "scope"))) {
1847 convertToDirective(this.text, this.parserOptions, this.locationCalculator, node);
1848 return;
1849 }
1850 const key = (node.key.name = adjustAttributeName(node.key.name, namespace));
1851 const value = node.value && node.value.value;
1852 if (key === "xmlns" && value !== namespace) {
1853 this.reportParseError(node, "x-invalid-namespace");
1854 }
1855 else if (key === "xmlns:xlink" && value !== NS.XLink) {
1856 this.reportParseError(node, "x-invalid-namespace");
1857 }
1858 }
1859 StartTag(token) {
1860 debug("[html] StartTag %j", token);
1861 this.closeCurrentElementIfNecessary(token.name);
1862 const parent = this.currentNode;
1863 const namespace = this.detectNamespace(token);
1864 const element = {
1865 type: "VElement",
1866 range: [token.range[0], token.range[1]],
1867 loc: { start: token.loc.start, end: token.loc.end },
1868 parent,
1869 name: adjustElementName(token.name, namespace),
1870 rawName: token.rawName,
1871 namespace,
1872 startTag: {
1873 type: "VStartTag",
1874 range: token.range,
1875 loc: token.loc,
1876 parent: DUMMY_PARENT$2,
1877 selfClosing: token.selfClosing,
1878 attributes: token.attributes,
1879 },
1880 children: [],
1881 endTag: null,
1882 variables: [],
1883 };
1884 const hasVPre = !this.isInVPreElement &&
1885 token.attributes.some(a => a.key.name === "v-pre");
1886 if (hasVPre) {
1887 this.expressionEnabled = false;
1888 }
1889 parent.children.push(element);
1890 element.startTag.parent = element;
1891 for (const attribute of token.attributes) {
1892 attribute.parent = element.startTag;
1893 this.processAttribute(attribute, namespace);
1894 }
1895 for (const attribute of element.startTag.attributes) {
1896 if (attribute.directive) {
1897 if (attribute.key.argument != null &&
1898 attribute.key.argument.type === "VExpressionContainer") {
1899 resolveReferences(attribute.key.argument);
1900 }
1901 if (attribute.value != null) {
1902 resolveReferences(attribute.value);
1903 }
1904 }
1905 }
1906 const isVoid = namespace === NS.HTML && HTML_VOID_ELEMENT_TAGS.has(element.name);
1907 if (token.selfClosing && !isVoid && namespace === NS.HTML) {
1908 this.reportParseError(token, "non-void-html-element-start-tag-with-trailing-solidus");
1909 }
1910 if (token.selfClosing || isVoid) {
1911 this.expressionEnabled = !this.isInVPreElement;
1912 return;
1913 }
1914 this.elementStack.push(element);
1915 if (hasVPre) {
1916 assert(this.vPreElement === null);
1917 this.vPreElement = element;
1918 }
1919 this.namespace = namespace;
1920 if (namespace === NS.HTML) {
1921 if (element.name === "template" &&
1922 element.parent.type === "VDocumentFragment") {
1923 const langAttr = element.startTag.attributes.find(a => !a.directive && a.key.name === "lang");
1924 const lang = (langAttr && langAttr.value && langAttr.value.value) ||
1925 "html";
1926 if (lang !== "html") {
1927 this.tokenizer.state = "RAWTEXT";
1928 }
1929 this.expressionEnabled = true;
1930 }
1931 if (HTML_RCDATA_TAGS.has(element.name)) {
1932 this.tokenizer.state = "RCDATA";
1933 }
1934 if (HTML_RAWTEXT_TAGS.has(element.name)) {
1935 this.tokenizer.state = "RAWTEXT";
1936 }
1937 }
1938 }
1939 EndTag(token) {
1940 debug("[html] EndTag %j", token);
1941 const i = findLastIndex(this.elementStack, el => el.name.toLowerCase() === token.name);
1942 if (i === -1) {
1943 this.reportParseError(token, "x-invalid-end-tag");
1944 return;
1945 }
1946 const element = this.elementStack[i];
1947 element.endTag = {
1948 type: "VEndTag",
1949 range: token.range,
1950 loc: token.loc,
1951 parent: element,
1952 };
1953 this.popElementStackUntil(i);
1954 }
1955 Text(token) {
1956 debug("[html] Text %j", token);
1957 const parent = this.currentNode;
1958 parent.children.push({
1959 type: "VText",
1960 range: token.range,
1961 loc: token.loc,
1962 parent,
1963 value: token.value,
1964 });
1965 }
1966 Mustache(token) {
1967 debug("[html] Mustache %j", token);
1968 const parent = this.currentNode;
1969 const container = {
1970 type: "VExpressionContainer",
1971 range: token.range,
1972 loc: token.loc,
1973 parent,
1974 expression: null,
1975 references: [],
1976 };
1977 processMustache(this.parserOptions, this.locationCalculator, container, token);
1978 parent.children.push(container);
1979 resolveReferences(container);
1980 }
1981}
1982
1983const alternativeCR = new Map([[128, 8364], [130, 8218], [131, 402], [132, 8222], [133, 8230], [134, 8224], [135, 8225], [136, 710], [137, 8240], [138, 352], [139, 8249], [140, 338], [142, 381], [145, 8216], [146, 8217], [147, 8220], [148, 8221], [149, 8226], [150, 8211], [151, 8212], [152, 732], [153, 8482], [154, 353], [155, 8250], [156, 339], [158, 382], [159, 376]]);
1984
1985const entitySets = [{ "length": 32, "entities": { "CounterClockwiseContourIntegral;": [8755] } }, { "length": 25, "entities": { "ClockwiseContourIntegral;": [8754], "DoubleLongLeftRightArrow;": [10234] } }, { "length": 24, "entities": { "NotNestedGreaterGreater;": [10914, 824] } }, { "length": 23, "entities": { "DiacriticalDoubleAcute;": [733], "NotSquareSupersetEqual;": [8931] } }, { "length": 22, "entities": { "CloseCurlyDoubleQuote;": [8221], "DoubleContourIntegral;": [8751], "FilledVerySmallSquare;": [9642], "NegativeVeryThinSpace;": [8203], "NotPrecedesSlantEqual;": [8928], "NotRightTriangleEqual;": [8941], "NotSucceedsSlantEqual;": [8929] } }, { "length": 21, "entities": { "CapitalDifferentialD;": [8517], "DoubleLeftRightArrow;": [8660], "DoubleLongRightArrow;": [10233], "EmptyVerySmallSquare;": [9643], "NestedGreaterGreater;": [8811], "NotDoubleVerticalBar;": [8742], "NotGreaterSlantEqual;": [10878, 824], "NotLeftTriangleEqual;": [8940], "NotSquareSubsetEqual;": [8930], "OpenCurlyDoubleQuote;": [8220], "ReverseUpEquilibrium;": [10607] } }, { "length": 20, "entities": { "DoubleLongLeftArrow;": [10232], "DownLeftRightVector;": [10576], "LeftArrowRightArrow;": [8646], "NegativeMediumSpace;": [8203], "NotGreaterFullEqual;": [8807, 824], "NotRightTriangleBar;": [10704, 824], "RightArrowLeftArrow;": [8644], "SquareSupersetEqual;": [8850], "leftrightsquigarrow;": [8621] } }, { "length": 19, "entities": { "DownRightTeeVector;": [10591], "DownRightVectorBar;": [10583], "LongLeftRightArrow;": [10231], "Longleftrightarrow;": [10234], "NegativeThickSpace;": [8203], "NotLeftTriangleBar;": [10703, 824], "PrecedesSlantEqual;": [8828], "ReverseEquilibrium;": [8651], "RightDoubleBracket;": [10215], "RightDownTeeVector;": [10589], "RightDownVectorBar;": [10581], "RightTriangleEqual;": [8885], "SquareIntersection;": [8851], "SucceedsSlantEqual;": [8829], "blacktriangleright;": [9656], "longleftrightarrow;": [10231] } }, { "length": 18, "entities": { "DoubleUpDownArrow;": [8661], "DoubleVerticalBar;": [8741], "DownLeftTeeVector;": [10590], "DownLeftVectorBar;": [10582], "FilledSmallSquare;": [9724], "GreaterSlantEqual;": [10878], "LeftDoubleBracket;": [10214], "LeftDownTeeVector;": [10593], "LeftDownVectorBar;": [10585], "LeftTriangleEqual;": [8884], "NegativeThinSpace;": [8203], "NotGreaterGreater;": [8811, 824], "NotLessSlantEqual;": [10877, 824], "NotNestedLessLess;": [10913, 824], "NotReverseElement;": [8716], "NotSquareSuperset;": [8848, 824], "NotTildeFullEqual;": [8775], "RightAngleBracket;": [10217], "RightUpDownVector;": [10575], "SquareSubsetEqual;": [8849], "VerticalSeparator;": [10072], "blacktriangledown;": [9662], "blacktriangleleft;": [9666], "leftrightharpoons;": [8651], "rightleftharpoons;": [8652], "twoheadrightarrow;": [8608] } }, { "length": 17, "entities": { "DiacriticalAcute;": [180], "DiacriticalGrave;": [96], "DiacriticalTilde;": [732], "DoubleRightArrow;": [8658], "DownArrowUpArrow;": [8693], "EmptySmallSquare;": [9723], "GreaterEqualLess;": [8923], "GreaterFullEqual;": [8807], "LeftAngleBracket;": [10216], "LeftUpDownVector;": [10577], "LessEqualGreater;": [8922], "NonBreakingSpace;": [160], "NotPrecedesEqual;": [10927, 824], "NotRightTriangle;": [8939], "NotSucceedsEqual;": [10928, 824], "NotSucceedsTilde;": [8831, 824], "NotSupersetEqual;": [8841], "RightTriangleBar;": [10704], "RightUpTeeVector;": [10588], "RightUpVectorBar;": [10580], "UnderParenthesis;": [9181], "UpArrowDownArrow;": [8645], "circlearrowright;": [8635], "downharpoonright;": [8642], "ntrianglerighteq;": [8941], "rightharpoondown;": [8641], "rightrightarrows;": [8649], "twoheadleftarrow;": [8606], "vartriangleright;": [8883] } }, { "length": 16, "entities": { "CloseCurlyQuote;": [8217], "ContourIntegral;": [8750], "DoubleDownArrow;": [8659], "DoubleLeftArrow;": [8656], "DownRightVector;": [8641], "LeftRightVector;": [10574], "LeftTriangleBar;": [10703], "LeftUpTeeVector;": [10592], "LeftUpVectorBar;": [10584], "LowerRightArrow;": [8600], "NotGreaterEqual;": [8817], "NotGreaterTilde;": [8821], "NotHumpDownHump;": [8782, 824], "NotLeftTriangle;": [8938], "NotSquareSubset;": [8847, 824], "OverParenthesis;": [9180], "RightDownVector;": [8642], "ShortRightArrow;": [8594], "UpperRightArrow;": [8599], "bigtriangledown;": [9661], "circlearrowleft;": [8634], "curvearrowright;": [8631], "downharpoonleft;": [8643], "leftharpoondown;": [8637], "leftrightarrows;": [8646], "nLeftrightarrow;": [8654], "nleftrightarrow;": [8622], "ntrianglelefteq;": [8940], "rightleftarrows;": [8644], "rightsquigarrow;": [8605], "rightthreetimes;": [8908], "straightepsilon;": [1013], "trianglerighteq;": [8885], "vartriangleleft;": [8882] } }, { "length": 15, "entities": { "DiacriticalDot;": [729], "DoubleRightTee;": [8872], "DownLeftVector;": [8637], "GreaterGreater;": [10914], "HorizontalLine;": [9472], "InvisibleComma;": [8291], "InvisibleTimes;": [8290], "LeftDownVector;": [8643], "LeftRightArrow;": [8596], "Leftrightarrow;": [8660], "LessSlantEqual;": [10877], "LongRightArrow;": [10230], "Longrightarrow;": [10233], "LowerLeftArrow;": [8601], "NestedLessLess;": [8810], "NotGreaterLess;": [8825], "NotLessGreater;": [8824], "NotSubsetEqual;": [8840], "NotVerticalBar;": [8740], "OpenCurlyQuote;": [8216], "ReverseElement;": [8715], "RightTeeVector;": [10587], "RightVectorBar;": [10579], "ShortDownArrow;": [8595], "ShortLeftArrow;": [8592], "SquareSuperset;": [8848], "TildeFullEqual;": [8773], "UpperLeftArrow;": [8598], "ZeroWidthSpace;": [8203], "curvearrowleft;": [8630], "doublebarwedge;": [8966], "downdownarrows;": [8650], "hookrightarrow;": [8618], "leftleftarrows;": [8647], "leftrightarrow;": [8596], "leftthreetimes;": [8907], "longrightarrow;": [10230], "looparrowright;": [8620], "nshortparallel;": [8742], "ntriangleright;": [8939], "rightarrowtail;": [8611], "rightharpoonup;": [8640], "trianglelefteq;": [8884], "upharpoonright;": [8638] } }, { "length": 14, "entities": { "ApplyFunction;": [8289], "DifferentialD;": [8518], "DoubleLeftTee;": [10980], "DoubleUpArrow;": [8657], "LeftTeeVector;": [10586], "LeftVectorBar;": [10578], "LessFullEqual;": [8806], "LongLeftArrow;": [10229], "Longleftarrow;": [10232], "NotEqualTilde;": [8770, 824], "NotTildeEqual;": [8772], "NotTildeTilde;": [8777], "Poincareplane;": [8460], "PrecedesEqual;": [10927], "PrecedesTilde;": [8830], "RightArrowBar;": [8677], "RightTeeArrow;": [8614], "RightTriangle;": [8883], "RightUpVector;": [8638], "SucceedsEqual;": [10928], "SucceedsTilde;": [8831], "SupersetEqual;": [8839], "UpEquilibrium;": [10606], "VerticalTilde;": [8768], "VeryThinSpace;": [8202], "bigtriangleup;": [9651], "blacktriangle;": [9652], "divideontimes;": [8903], "fallingdotseq;": [8786], "hookleftarrow;": [8617], "leftarrowtail;": [8610], "leftharpoonup;": [8636], "longleftarrow;": [10229], "looparrowleft;": [8619], "measuredangle;": [8737], "ntriangleleft;": [8938], "shortparallel;": [8741], "smallsetminus;": [8726], "triangleright;": [9657], "upharpoonleft;": [8639], "varsubsetneqq;": [10955, 65024], "varsupsetneqq;": [10956, 65024] } }, { "length": 13, "entities": { "DownArrowBar;": [10515], "DownTeeArrow;": [8615], "ExponentialE;": [8519], "GreaterEqual;": [8805], "GreaterTilde;": [8819], "HilbertSpace;": [8459], "HumpDownHump;": [8782], "Intersection;": [8898], "LeftArrowBar;": [8676], "LeftTeeArrow;": [8612], "LeftTriangle;": [8882], "LeftUpVector;": [8639], "NotCongruent;": [8802], "NotHumpEqual;": [8783, 824], "NotLessEqual;": [8816], "NotLessTilde;": [8820], "Proportional;": [8733], "RightCeiling;": [8969], "RoundImplies;": [10608], "ShortUpArrow;": [8593], "SquareSubset;": [8847], "UnderBracket;": [9141], "VerticalLine;": [124], "blacklozenge;": [10731], "exponentiale;": [8519], "risingdotseq;": [8787], "triangledown;": [9663], "triangleleft;": [9667], "varsubsetneq;": [8842, 65024], "varsupsetneq;": [8843, 65024] } }, { "length": 12, "entities": { "CircleMinus;": [8854], "CircleTimes;": [8855], "Equilibrium;": [8652], "GreaterLess;": [8823], "LeftCeiling;": [8968], "LessGreater;": [8822], "MediumSpace;": [8287], "NotLessLess;": [8810, 824], "NotPrecedes;": [8832], "NotSucceeds;": [8833], "NotSuperset;": [8835, 8402], "OverBracket;": [9140], "RightVector;": [8640], "Rrightarrow;": [8667], "RuleDelayed;": [10740], "SmallCircle;": [8728], "SquareUnion;": [8852], "SubsetEqual;": [8838], "UpDownArrow;": [8597], "Updownarrow;": [8661], "VerticalBar;": [8739], "backepsilon;": [1014], "blacksquare;": [9642], "circledcirc;": [8858], "circleddash;": [8861], "curlyeqprec;": [8926], "curlyeqsucc;": [8927], "diamondsuit;": [9830], "eqslantless;": [10901], "expectation;": [8496], "nRightarrow;": [8655], "nrightarrow;": [8603], "preccurlyeq;": [8828], "precnapprox;": [10937], "quaternions;": [8461], "straightphi;": [981], "succcurlyeq;": [8829], "succnapprox;": [10938], "thickapprox;": [8776], "updownarrow;": [8597] } }, { "length": 11, "entities": { "Bernoullis;": [8492], "CirclePlus;": [8853], "EqualTilde;": [8770], "Fouriertrf;": [8497], "ImaginaryI;": [8520], "Laplacetrf;": [8466], "LeftVector;": [8636], "Lleftarrow;": [8666], "NotElement;": [8713], "NotGreater;": [8815], "Proportion;": [8759], "RightArrow;": [8594], "RightFloor;": [8971], "Rightarrow;": [8658], "ThickSpace;": [8287, 8202], "TildeEqual;": [8771], "TildeTilde;": [8776], "UnderBrace;": [9183], "UpArrowBar;": [10514], "UpTeeArrow;": [8613], "circledast;": [8859], "complement;": [8705], "curlywedge;": [8911], "eqslantgtr;": [10902], "gtreqqless;": [10892], "lessapprox;": [10885], "lesseqqgtr;": [10891], "lmoustache;": [9136], "longmapsto;": [10236], "mapstodown;": [8615], "mapstoleft;": [8612], "nLeftarrow;": [8653], "nleftarrow;": [8602], "nsubseteqq;": [10949, 824], "nsupseteqq;": [10950, 824], "precapprox;": [10935], "rightarrow;": [8594], "rmoustache;": [9137], "sqsubseteq;": [8849], "sqsupseteq;": [8850], "subsetneqq;": [10955], "succapprox;": [10936], "supsetneqq;": [10956], "upuparrows;": [8648], "varepsilon;": [1013], "varnothing;": [8709] } }, { "length": 10, "entities": { "Backslash;": [8726], "CenterDot;": [183], "CircleDot;": [8857], "Congruent;": [8801], "Coproduct;": [8720], "DoubleDot;": [168], "DownArrow;": [8595], "DownBreve;": [785], "Downarrow;": [8659], "HumpEqual;": [8783], "LeftArrow;": [8592], "LeftFloor;": [8970], "Leftarrow;": [8656], "LessTilde;": [8818], "Mellintrf;": [8499], "MinusPlus;": [8723], "NotCupCap;": [8813], "NotExists;": [8708], "NotSubset;": [8834, 8402], "OverBrace;": [9182], "PlusMinus;": [177], "Therefore;": [8756], "ThinSpace;": [8201], "TripleDot;": [8411], "UnionPlus;": [8846], "backprime;": [8245], "backsimeq;": [8909], "bigotimes;": [10754], "centerdot;": [183], "checkmark;": [10003], "complexes;": [8450], "dotsquare;": [8865], "downarrow;": [8595], "gtrapprox;": [10886], "gtreqless;": [8923], "gvertneqq;": [8809, 65024], "heartsuit;": [9829], "leftarrow;": [8592], "lesseqgtr;": [8922], "lvertneqq;": [8808, 65024], "ngeqslant;": [10878, 824], "nleqslant;": [10877, 824], "nparallel;": [8742], "nshortmid;": [8740], "nsubseteq;": [8840], "nsupseteq;": [8841], "pitchfork;": [8916], "rationals;": [8474], "spadesuit;": [9824], "subseteqq;": [10949], "subsetneq;": [8842], "supseteqq;": [10950], "supsetneq;": [8843], "therefore;": [8756], "triangleq;": [8796], "varpropto;": [8733] } }, { "length": 9, "entities": { "DDotrahd;": [10513], "DotEqual;": [8784], "Integral;": [8747], "LessLess;": [10913], "NotEqual;": [8800], "NotTilde;": [8769], "PartialD;": [8706], "Precedes;": [8826], "RightTee;": [8866], "Succeeds;": [8827], "SuchThat;": [8715], "Superset;": [8835], "Uarrocir;": [10569], "UnderBar;": [95], "andslope;": [10840], "angmsdaa;": [10664], "angmsdab;": [10665], "angmsdac;": [10666], "angmsdad;": [10667], "angmsdae;": [10668], "angmsdaf;": [10669], "angmsdag;": [10670], "angmsdah;": [10671], "angrtvbd;": [10653], "approxeq;": [8778], "awconint;": [8755], "backcong;": [8780], "barwedge;": [8965], "bbrktbrk;": [9142], "bigoplus;": [10753], "bigsqcup;": [10758], "biguplus;": [10756], "bigwedge;": [8896], "boxminus;": [8863], "boxtimes;": [8864], "bsolhsub;": [10184], "capbrcup;": [10825], "circledR;": [174], "circledS;": [9416], "cirfnint;": [10768], "clubsuit;": [9827], "cupbrcap;": [10824], "curlyvee;": [8910], "cwconint;": [8754], "doteqdot;": [8785], "dotminus;": [8760], "drbkarow;": [10512], "dzigrarr;": [10239], "elinters;": [9191], "emptyset;": [8709], "eqvparsl;": [10725], "fpartint;": [10765], "geqslant;": [10878], "gesdotol;": [10884], "gnapprox;": [10890], "hksearow;": [10533], "hkswarow;": [10534], "imagline;": [8464], "imagpart;": [8465], "infintie;": [10717], "integers;": [8484], "intercal;": [8890], "intlarhk;": [10775], "laemptyv;": [10676], "ldrushar;": [10571], "leqslant;": [10877], "lesdotor;": [10883], "llcorner;": [8990], "lnapprox;": [10889], "lrcorner;": [8991], "lurdshar;": [10570], "mapstoup;": [8613], "multimap;": [8888], "naturals;": [8469], "ncongdot;": [10861, 824], "notindot;": [8949, 824], "otimesas;": [10806], "parallel;": [8741], "plusacir;": [10787], "pointint;": [10773], "precneqq;": [10933], "precnsim;": [8936], "profalar;": [9006], "profline;": [8978], "profsurf;": [8979], "raemptyv;": [10675], "realpart;": [8476], "rppolint;": [10770], "rtriltri;": [10702], "scpolint;": [10771], "setminus;": [8726], "shortmid;": [8739], "smeparsl;": [10724], "sqsubset;": [8847], "sqsupset;": [8848], "subseteq;": [8838], "succneqq;": [10934], "succnsim;": [8937], "supseteq;": [8839], "thetasym;": [977], "thicksim;": [8764], "timesbar;": [10801], "triangle;": [9653], "triminus;": [10810], "trpezium;": [9186], "ulcorner;": [8988], "urcorner;": [8989], "varkappa;": [1008], "varsigma;": [962], "vartheta;": [977] } }, { "length": 8, "entities": { "Because;": [8757], "Cayleys;": [8493], "Cconint;": [8752], "Cedilla;": [184], "Diamond;": [8900], "DownTee;": [8868], "Element;": [8712], "Epsilon;": [917], "Implies;": [8658], "LeftTee;": [8867], "NewLine;": [10], "NoBreak;": [8288], "NotLess;": [8814], "Omicron;": [927], "OverBar;": [8254], "Product;": [8719], "UpArrow;": [8593], "Uparrow;": [8657], "Upsilon;": [933], "alefsym;": [8501], "angrtvb;": [8894], "angzarr;": [9084], "asympeq;": [8781], "backsim;": [8765], "because;": [8757], "bemptyv;": [10672], "between;": [8812], "bigcirc;": [9711], "bigodot;": [10752], "bigstar;": [9733], "bnequiv;": [8801, 8421], "boxplus;": [8862], "ccupssm;": [10832], "cemptyv;": [10674], "cirscir;": [10690], "coloneq;": [8788], "congdot;": [10861], "cudarrl;": [10552], "cudarrr;": [10549], "cularrp;": [10557], "curarrm;": [10556], "dbkarow;": [10511], "ddagger;": [8225], "ddotseq;": [10871], "demptyv;": [10673], "diamond;": [8900], "digamma;": [989], "dotplus;": [8724], "dwangle;": [10662], "epsilon;": [949], "eqcolon;": [8789], "equivDD;": [10872], "gesdoto;": [10882], "gtquest;": [10876], "gtrless;": [8823], "harrcir;": [10568], "intprod;": [10812], "isindot;": [8949], "larrbfs;": [10527], "larrsim;": [10611], "lbrksld;": [10639], "lbrkslu;": [10637], "ldrdhar;": [10599], "lesdoto;": [10881], "lessdot;": [8918], "lessgtr;": [8822], "lesssim;": [8818], "lotimes;": [10804], "lozenge;": [9674], "ltquest;": [10875], "luruhar;": [10598], "maltese;": [10016], "minusdu;": [10794], "napprox;": [8777], "natural;": [9838], "nearrow;": [8599], "nexists;": [8708], "notinva;": [8713], "notinvb;": [8951], "notinvc;": [8950], "notniva;": [8716], "notnivb;": [8958], "notnivc;": [8957], "npolint;": [10772], "npreceq;": [10927, 824], "nsqsube;": [8930], "nsqsupe;": [8931], "nsubset;": [8834, 8402], "nsucceq;": [10928, 824], "nsupset;": [8835, 8402], "nvinfin;": [10718], "nvltrie;": [8884, 8402], "nvrtrie;": [8885, 8402], "nwarrow;": [8598], "olcross;": [10683], "omicron;": [959], "orderof;": [8500], "orslope;": [10839], "pertenk;": [8241], "planckh;": [8462], "pluscir;": [10786], "plussim;": [10790], "plustwo;": [10791], "precsim;": [8830], "quatint;": [10774], "questeq;": [8799], "rarrbfs;": [10528], "rarrsim;": [10612], "rbrksld;": [10638], "rbrkslu;": [10640], "rdldhar;": [10601], "realine;": [8475], "rotimes;": [10805], "ruluhar;": [10600], "searrow;": [8600], "simplus;": [10788], "simrarr;": [10610], "subedot;": [10947], "submult;": [10945], "subplus;": [10943], "subrarr;": [10617], "succsim;": [8831], "supdsub;": [10968], "supedot;": [10948], "suphsol;": [10185], "suphsub;": [10967], "suplarr;": [10619], "supmult;": [10946], "supplus;": [10944], "swarrow;": [8601], "topfork;": [10970], "triplus;": [10809], "tritime;": [10811], "uparrow;": [8593], "upsilon;": [965], "uwangle;": [10663], "vzigzag;": [10650], "zigrarr;": [8669] } }, { "length": 7, "entities": { "Aacute;": [193], "Abreve;": [258], "Agrave;": [192], "Assign;": [8788], "Atilde;": [195], "Barwed;": [8966], "Bumpeq;": [8782], "Cacute;": [262], "Ccaron;": [268], "Ccedil;": [199], "Colone;": [10868], "Conint;": [8751], "CupCap;": [8781], "Dagger;": [8225], "Dcaron;": [270], "DotDot;": [8412], "Dstrok;": [272], "Eacute;": [201], "Ecaron;": [282], "Egrave;": [200], "Exists;": [8707], "ForAll;": [8704], "Gammad;": [988], "Gbreve;": [286], "Gcedil;": [290], "HARDcy;": [1066], "Hstrok;": [294], "Iacute;": [205], "Igrave;": [204], "Itilde;": [296], "Jsercy;": [1032], "Kcedil;": [310], "Lacute;": [313], "Lambda;": [923], "Lcaron;": [317], "Lcedil;": [315], "Lmidot;": [319], "Lstrok;": [321], "Nacute;": [323], "Ncaron;": [327], "Ncedil;": [325], "Ntilde;": [209], "Oacute;": [211], "Odblac;": [336], "Ograve;": [210], "Oslash;": [216], "Otilde;": [213], "Otimes;": [10807], "Racute;": [340], "Rarrtl;": [10518], "Rcaron;": [344], "Rcedil;": [342], "SHCHcy;": [1065], "SOFTcy;": [1068], "Sacute;": [346], "Scaron;": [352], "Scedil;": [350], "Square;": [9633], "Subset;": [8912], "Supset;": [8913], "Tcaron;": [356], "Tcedil;": [354], "Tstrok;": [358], "Uacute;": [218], "Ubreve;": [364], "Udblac;": [368], "Ugrave;": [217], "Utilde;": [360], "Vdashl;": [10982], "Verbar;": [8214], "Vvdash;": [8874], "Yacute;": [221], "Zacute;": [377], "Zcaron;": [381], "aacute;": [225], "abreve;": [259], "agrave;": [224], "andand;": [10837], "angmsd;": [8737], "angsph;": [8738], "apacir;": [10863], "approx;": [8776], "atilde;": [227], "barvee;": [8893], "barwed;": [8965], "becaus;": [8757], "bernou;": [8492], "bigcap;": [8898], "bigcup;": [8899], "bigvee;": [8897], "bkarow;": [10509], "bottom;": [8869], "bowtie;": [8904], "boxbox;": [10697], "bprime;": [8245], "brvbar;": [166], "bullet;": [8226], "bumpeq;": [8783], "cacute;": [263], "capand;": [10820], "capcap;": [10827], "capcup;": [10823], "capdot;": [10816], "ccaron;": [269], "ccedil;": [231], "circeq;": [8791], "cirmid;": [10991], "colone;": [8788], "commat;": [64], "compfn;": [8728], "conint;": [8750], "coprod;": [8720], "copysr;": [8471], "cularr;": [8630], "cupcap;": [10822], "cupcup;": [10826], "cupdot;": [8845], "curarr;": [8631], "curren;": [164], "cylcty;": [9005], "dagger;": [8224], "daleth;": [8504], "dcaron;": [271], "dfisht;": [10623], "divide;": [247], "divonx;": [8903], "dlcorn;": [8990], "dlcrop;": [8973], "dollar;": [36], "drcorn;": [8991], "drcrop;": [8972], "dstrok;": [273], "eacute;": [233], "easter;": [10862], "ecaron;": [283], "ecolon;": [8789], "egrave;": [232], "egsdot;": [10904], "elsdot;": [10903], "emptyv;": [8709], "emsp13;": [8196], "emsp14;": [8197], "eparsl;": [10723], "eqcirc;": [8790], "equals;": [61], "equest;": [8799], "female;": [9792], "ffilig;": [64259], "ffllig;": [64260], "forall;": [8704], "frac12;": [189], "frac13;": [8531], "frac14;": [188], "frac15;": [8533], "frac16;": [8537], "frac18;": [8539], "frac23;": [8532], "frac25;": [8534], "frac34;": [190], "frac35;": [8535], "frac38;": [8540], "frac45;": [8536], "frac56;": [8538], "frac58;": [8541], "frac78;": [8542], "gacute;": [501], "gammad;": [989], "gbreve;": [287], "gesdot;": [10880], "gesles;": [10900], "gtlPar;": [10645], "gtrarr;": [10616], "gtrdot;": [8919], "gtrsim;": [8819], "hairsp;": [8202], "hamilt;": [8459], "hardcy;": [1098], "hearts;": [9829], "hellip;": [8230], "hercon;": [8889], "homtht;": [8763], "horbar;": [8213], "hslash;": [8463], "hstrok;": [295], "hybull;": [8259], "hyphen;": [8208], "iacute;": [237], "igrave;": [236], "iiiint;": [10764], "iinfin;": [10716], "incare;": [8453], "inodot;": [305], "intcal;": [8890], "iquest;": [191], "isinsv;": [8947], "itilde;": [297], "jsercy;": [1112], "kappav;": [1008], "kcedil;": [311], "kgreen;": [312], "lAtail;": [10523], "lacute;": [314], "lagran;": [8466], "lambda;": [955], "langle;": [10216], "larrfs;": [10525], "larrhk;": [8617], "larrlp;": [8619], "larrpl;": [10553], "larrtl;": [8610], "latail;": [10521], "lbrace;": [123], "lbrack;": [91], "lcaron;": [318], "lcedil;": [316], "ldquor;": [8222], "lesdot;": [10879], "lesges;": [10899], "lfisht;": [10620], "lfloor;": [8970], "lharul;": [10602], "llhard;": [10603], "lmidot;": [320], "lmoust;": [9136], "loplus;": [10797], "lowast;": [8727], "lowbar;": [95], "lparlt;": [10643], "lrhard;": [10605], "lsaquo;": [8249], "lsquor;": [8218], "lstrok;": [322], "lthree;": [8907], "ltimes;": [8905], "ltlarr;": [10614], "ltrPar;": [10646], "mapsto;": [8614], "marker;": [9646], "mcomma;": [10793], "midast;": [42], "midcir;": [10992], "middot;": [183], "minusb;": [8863], "minusd;": [8760], "mnplus;": [8723], "models;": [8871], "mstpos;": [8766], "nVDash;": [8879], "nVdash;": [8878], "nacute;": [324], "nbumpe;": [8783, 824], "ncaron;": [328], "ncedil;": [326], "nearhk;": [10532], "nequiv;": [8802], "nesear;": [10536], "nexist;": [8708], "nltrie;": [8940], "notinE;": [8953, 824], "nparsl;": [11005, 8421], "nprcue;": [8928], "nrarrc;": [10547, 824], "nrarrw;": [8605, 824], "nrtrie;": [8941], "nsccue;": [8929], "nsimeq;": [8772], "ntilde;": [241], "numero;": [8470], "nvDash;": [8877], "nvHarr;": [10500], "nvdash;": [8876], "nvlArr;": [10498], "nvrArr;": [10499], "nwarhk;": [10531], "nwnear;": [10535], "oacute;": [243], "odblac;": [337], "odsold;": [10684], "ograve;": [242], "ominus;": [8854], "origof;": [8886], "oslash;": [248], "otilde;": [245], "otimes;": [8855], "parsim;": [10995], "percnt;": [37], "period;": [46], "permil;": [8240], "phmmat;": [8499], "planck;": [8463], "plankv;": [8463], "plusdo;": [8724], "plusdu;": [10789], "plusmn;": [177], "preceq;": [10927], "primes;": [8473], "prnsim;": [8936], "propto;": [8733], "prurel;": [8880], "puncsp;": [8200], "qprime;": [8279], "rAtail;": [10524], "racute;": [341], "rangle;": [10217], "rarrap;": [10613], "rarrfs;": [10526], "rarrhk;": [8618], "rarrlp;": [8620], "rarrpl;": [10565], "rarrtl;": [8611], "ratail;": [10522], "rbrace;": [125], "rbrack;": [93], "rcaron;": [345], "rcedil;": [343], "rdquor;": [8221], "rfisht;": [10621], "rfloor;": [8971], "rharul;": [10604], "rmoust;": [9137], "roplus;": [10798], "rpargt;": [10644], "rsaquo;": [8250], "rsquor;": [8217], "rthree;": [8908], "rtimes;": [8906], "sacute;": [347], "scaron;": [353], "scedil;": [351], "scnsim;": [8937], "searhk;": [10533], "seswar;": [10537], "sfrown;": [8994], "shchcy;": [1097], "sigmaf;": [962], "sigmav;": [962], "simdot;": [10858], "smashp;": [10803], "softcy;": [1100], "solbar;": [9023], "spades;": [9824], "sqcaps;": [8851, 65024], "sqcups;": [8852, 65024], "sqsube;": [8849], "sqsupe;": [8850], "square;": [9633], "squarf;": [9642], "ssetmn;": [8726], "ssmile;": [8995], "sstarf;": [8902], "subdot;": [10941], "subset;": [8834], "subsim;": [10951], "subsub;": [10965], "subsup;": [10963], "succeq;": [10928], "supdot;": [10942], "supset;": [8835], "supsim;": [10952], "supsub;": [10964], "supsup;": [10966], "swarhk;": [10534], "swnwar;": [10538], "target;": [8982], "tcaron;": [357], "tcedil;": [355], "telrec;": [8981], "there4;": [8756], "thetav;": [977], "thinsp;": [8201], "thksim;": [8764], "timesb;": [8864], "timesd;": [10800], "topbot;": [9014], "topcir;": [10993], "tprime;": [8244], "tridot;": [9708], "tstrok;": [359], "uacute;": [250], "ubreve;": [365], "udblac;": [369], "ufisht;": [10622], "ugrave;": [249], "ulcorn;": [8988], "ulcrop;": [8975], "urcorn;": [8989], "urcrop;": [8974], "utilde;": [361], "vangrt;": [10652], "varphi;": [981], "varrho;": [1009], "veebar;": [8891], "vellip;": [8942], "verbar;": [124], "vsubnE;": [10955, 65024], "vsubne;": [8842, 65024], "vsupnE;": [10956, 65024], "vsupne;": [8843, 65024], "wedbar;": [10847], "wedgeq;": [8793], "weierp;": [8472], "wreath;": [8768], "xoplus;": [10753], "xotime;": [10754], "xsqcup;": [10758], "xuplus;": [10756], "xwedge;": [8896], "yacute;": [253], "zacute;": [378], "zcaron;": [382], "zeetrf;": [8488] } }, { "length": 6, "entities": { "AElig;": [198], "Aacute": [193], "Acirc;": [194], "Agrave": [192], "Alpha;": [913], "Amacr;": [256], "Aogon;": [260], "Aring;": [197], "Atilde": [195], "Breve;": [728], "Ccedil": [199], "Ccirc;": [264], "Colon;": [8759], "Cross;": [10799], "Dashv;": [10980], "Delta;": [916], "Eacute": [201], "Ecirc;": [202], "Egrave": [200], "Emacr;": [274], "Eogon;": [280], "Equal;": [10869], "Gamma;": [915], "Gcirc;": [284], "Hacek;": [711], "Hcirc;": [292], "IJlig;": [306], "Iacute": [205], "Icirc;": [206], "Igrave": [204], "Imacr;": [298], "Iogon;": [302], "Iukcy;": [1030], "Jcirc;": [308], "Jukcy;": [1028], "Kappa;": [922], "Ntilde": [209], "OElig;": [338], "Oacute": [211], "Ocirc;": [212], "Ograve": [210], "Omacr;": [332], "Omega;": [937], "Oslash": [216], "Otilde": [213], "Prime;": [8243], "RBarr;": [10512], "Scirc;": [348], "Sigma;": [931], "THORN;": [222], "TRADE;": [8482], "TSHcy;": [1035], "Theta;": [920], "Tilde;": [8764], "Uacute": [218], "Ubrcy;": [1038], "Ucirc;": [219], "Ugrave": [217], "Umacr;": [362], "Union;": [8899], "Uogon;": [370], "UpTee;": [8869], "Uring;": [366], "VDash;": [8875], "Vdash;": [8873], "Wcirc;": [372], "Wedge;": [8896], "Yacute": [221], "Ycirc;": [374], "aacute": [225], "acirc;": [226], "acute;": [180], "aelig;": [230], "agrave": [224], "aleph;": [8501], "alpha;": [945], "amacr;": [257], "amalg;": [10815], "angle;": [8736], "angrt;": [8735], "angst;": [197], "aogon;": [261], "aring;": [229], "asymp;": [8776], "atilde": [227], "awint;": [10769], "bcong;": [8780], "bdquo;": [8222], "bepsi;": [1014], "blank;": [9251], "blk12;": [9618], "blk14;": [9617], "blk34;": [9619], "block;": [9608], "boxDL;": [9559], "boxDR;": [9556], "boxDl;": [9558], "boxDr;": [9555], "boxHD;": [9574], "boxHU;": [9577], "boxHd;": [9572], "boxHu;": [9575], "boxUL;": [9565], "boxUR;": [9562], "boxUl;": [9564], "boxUr;": [9561], "boxVH;": [9580], "boxVL;": [9571], "boxVR;": [9568], "boxVh;": [9579], "boxVl;": [9570], "boxVr;": [9567], "boxdL;": [9557], "boxdR;": [9554], "boxdl;": [9488], "boxdr;": [9484], "boxhD;": [9573], "boxhU;": [9576], "boxhd;": [9516], "boxhu;": [9524], "boxuL;": [9563], "boxuR;": [9560], "boxul;": [9496], "boxur;": [9492], "boxvH;": [9578], "boxvL;": [9569], "boxvR;": [9566], "boxvh;": [9532], "boxvl;": [9508], "boxvr;": [9500], "breve;": [728], "brvbar": [166], "bsemi;": [8271], "bsime;": [8909], "bsolb;": [10693], "bumpE;": [10926], "bumpe;": [8783], "caret;": [8257], "caron;": [711], "ccaps;": [10829], "ccedil": [231], "ccirc;": [265], "ccups;": [10828], "cedil;": [184], "check;": [10003], "clubs;": [9827], "colon;": [58], "comma;": [44], "crarr;": [8629], "cross;": [10007], "csube;": [10961], "csupe;": [10962], "ctdot;": [8943], "cuepr;": [8926], "cuesc;": [8927], "cupor;": [10821], "curren": [164], "cuvee;": [8910], "cuwed;": [8911], "cwint;": [8753], "dashv;": [8867], "dblac;": [733], "ddarr;": [8650], "delta;": [948], "dharl;": [8643], "dharr;": [8642], "diams;": [9830], "disin;": [8946], "divide": [247], "doteq;": [8784], "dtdot;": [8945], "dtrif;": [9662], "duarr;": [8693], "duhar;": [10607], "eDDot;": [10871], "eacute": [233], "ecirc;": [234], "efDot;": [8786], "egrave": [232], "emacr;": [275], "empty;": [8709], "eogon;": [281], "eplus;": [10865], "epsiv;": [1013], "eqsim;": [8770], "equiv;": [8801], "erDot;": [8787], "erarr;": [10609], "esdot;": [8784], "exist;": [8707], "fflig;": [64256], "filig;": [64257], "fjlig;": [102, 106], "fllig;": [64258], "fltns;": [9649], "forkv;": [10969], "frac12": [189], "frac14": [188], "frac34": [190], "frasl;": [8260], "frown;": [8994], "gamma;": [947], "gcirc;": [285], "gescc;": [10921], "gimel;": [8503], "gneqq;": [8809], "gnsim;": [8935], "grave;": [96], "gsime;": [10894], "gsiml;": [10896], "gtcir;": [10874], "gtdot;": [8919], "harrw;": [8621], "hcirc;": [293], "hoarr;": [8703], "iacute": [237], "icirc;": [238], "iexcl;": [161], "igrave": [236], "iiint;": [8749], "iiota;": [8489], "ijlig;": [307], "imacr;": [299], "image;": [8465], "imath;": [305], "imped;": [437], "infin;": [8734], "iogon;": [303], "iprod;": [10812], "iquest": [191], "isinE;": [8953], "isins;": [8948], "isinv;": [8712], "iukcy;": [1110], "jcirc;": [309], "jmath;": [567], "jukcy;": [1108], "kappa;": [954], "lAarr;": [8666], "lBarr;": [10510], "langd;": [10641], "laquo;": [171], "larrb;": [8676], "lates;": [10925, 65024], "lbarr;": [10508], "lbbrk;": [10098], "lbrke;": [10635], "lceil;": [8968], "ldquo;": [8220], "lescc;": [10920], "lhard;": [8637], "lharu;": [8636], "lhblk;": [9604], "llarr;": [8647], "lltri;": [9722], "lneqq;": [8808], "lnsim;": [8934], "loang;": [10220], "loarr;": [8701], "lobrk;": [10214], "lopar;": [10629], "lrarr;": [8646], "lrhar;": [8651], "lrtri;": [8895], "lsime;": [10893], "lsimg;": [10895], "lsquo;": [8216], "ltcir;": [10873], "ltdot;": [8918], "ltrie;": [8884], "ltrif;": [9666], "mDDot;": [8762], "mdash;": [8212], "micro;": [181], "middot": [183], "minus;": [8722], "mumap;": [8888], "nabla;": [8711], "napid;": [8779, 824], "napos;": [329], "natur;": [9838], "nbump;": [8782, 824], "ncong;": [8775], "ndash;": [8211], "neArr;": [8663], "nearr;": [8599], "nedot;": [8784, 824], "nesim;": [8770, 824], "ngeqq;": [8807, 824], "ngsim;": [8821], "nhArr;": [8654], "nharr;": [8622], "nhpar;": [10994], "nlArr;": [8653], "nlarr;": [8602], "nleqq;": [8806, 824], "nless;": [8814], "nlsim;": [8820], "nltri;": [8938], "notin;": [8713], "notni;": [8716], "npart;": [8706, 824], "nprec;": [8832], "nrArr;": [8655], "nrarr;": [8603], "nrtri;": [8939], "nsime;": [8772], "nsmid;": [8740], "nspar;": [8742], "nsubE;": [10949, 824], "nsube;": [8840], "nsucc;": [8833], "nsupE;": [10950, 824], "nsupe;": [8841], "ntilde": [241], "numsp;": [8199], "nvsim;": [8764, 8402], "nwArr;": [8662], "nwarr;": [8598], "oacute": [243], "ocirc;": [244], "odash;": [8861], "oelig;": [339], "ofcir;": [10687], "ograve": [242], "ohbar;": [10677], "olarr;": [8634], "olcir;": [10686], "oline;": [8254], "omacr;": [333], "omega;": [969], "operp;": [10681], "oplus;": [8853], "orarr;": [8635], "order;": [8500], "oslash": [248], "otilde": [245], "ovbar;": [9021], "parsl;": [11005], "phone;": [9742], "plusb;": [8862], "pluse;": [10866], "plusmn": [177], "pound;": [163], "prcue;": [8828], "prime;": [8242], "prnap;": [10937], "prsim;": [8830], "quest;": [63], "rAarr;": [8667], "rBarr;": [10511], "radic;": [8730], "rangd;": [10642], "range;": [10661], "raquo;": [187], "rarrb;": [8677], "rarrc;": [10547], "rarrw;": [8605], "ratio;": [8758], "rbarr;": [10509], "rbbrk;": [10099], "rbrke;": [10636], "rceil;": [8969], "rdquo;": [8221], "reals;": [8477], "rhard;": [8641], "rharu;": [8640], "rlarr;": [8644], "rlhar;": [8652], "rnmid;": [10990], "roang;": [10221], "roarr;": [8702], "robrk;": [10215], "ropar;": [10630], "rrarr;": [8649], "rsquo;": [8217], "rtrie;": [8885], "rtrif;": [9656], "sbquo;": [8218], "sccue;": [8829], "scirc;": [349], "scnap;": [10938], "scsim;": [8831], "sdotb;": [8865], "sdote;": [10854], "seArr;": [8664], "searr;": [8600], "setmn;": [8726], "sharp;": [9839], "sigma;": [963], "simeq;": [8771], "simgE;": [10912], "simlE;": [10911], "simne;": [8774], "slarr;": [8592], "smile;": [8995], "smtes;": [10924, 65024], "sqcap;": [8851], "sqcup;": [8852], "sqsub;": [8847], "sqsup;": [8848], "srarr;": [8594], "starf;": [9733], "strns;": [175], "subnE;": [10955], "subne;": [8842], "supnE;": [10956], "supne;": [8843], "swArr;": [8665], "swarr;": [8601], "szlig;": [223], "theta;": [952], "thkap;": [8776], "thorn;": [254], "tilde;": [732], "times;": [215], "trade;": [8482], "trisb;": [10701], "tshcy;": [1115], "twixt;": [8812], "uacute": [250], "ubrcy;": [1118], "ucirc;": [251], "udarr;": [8645], "udhar;": [10606], "ugrave": [249], "uharl;": [8639], "uharr;": [8638], "uhblk;": [9600], "ultri;": [9720], "umacr;": [363], "uogon;": [371], "uplus;": [8846], "upsih;": [978], "uring;": [367], "urtri;": [9721], "utdot;": [8944], "utrif;": [9652], "uuarr;": [8648], "vBarv;": [10985], "vDash;": [8872], "varpi;": [982], "vdash;": [8866], "veeeq;": [8794], "vltri;": [8882], "vnsub;": [8834, 8402], "vnsup;": [8835, 8402], "vprop;": [8733], "vrtri;": [8883], "wcirc;": [373], "wedge;": [8743], "xcirc;": [9711], "xdtri;": [9661], "xhArr;": [10234], "xharr;": [10231], "xlArr;": [10232], "xlarr;": [10229], "xodot;": [10752], "xrArr;": [10233], "xrarr;": [10230], "xutri;": [9651], "yacute": [253], "ycirc;": [375] } }, { "length": 5, "entities": { "AElig": [198], "Acirc": [194], "Aopf;": [120120], "Aring": [197], "Ascr;": [119964], "Auml;": [196], "Barv;": [10983], "Beta;": [914], "Bopf;": [120121], "Bscr;": [8492], "CHcy;": [1063], "COPY;": [169], "Cdot;": [266], "Copf;": [8450], "Cscr;": [119966], "DJcy;": [1026], "DScy;": [1029], "DZcy;": [1039], "Darr;": [8609], "Dopf;": [120123], "Dscr;": [119967], "Ecirc": [202], "Edot;": [278], "Eopf;": [120124], "Escr;": [8496], "Esim;": [10867], "Euml;": [203], "Fopf;": [120125], "Fscr;": [8497], "GJcy;": [1027], "Gdot;": [288], "Gopf;": [120126], "Gscr;": [119970], "Hopf;": [8461], "Hscr;": [8459], "IEcy;": [1045], "IOcy;": [1025], "Icirc": [206], "Idot;": [304], "Iopf;": [120128], "Iota;": [921], "Iscr;": [8464], "Iuml;": [207], "Jopf;": [120129], "Jscr;": [119973], "KHcy;": [1061], "KJcy;": [1036], "Kopf;": [120130], "Kscr;": [119974], "LJcy;": [1033], "Lang;": [10218], "Larr;": [8606], "Lopf;": [120131], "Lscr;": [8466], "Mopf;": [120132], "Mscr;": [8499], "NJcy;": [1034], "Nopf;": [8469], "Nscr;": [119977], "Ocirc": [212], "Oopf;": [120134], "Oscr;": [119978], "Ouml;": [214], "Popf;": [8473], "Pscr;": [119979], "QUOT;": [34], "Qopf;": [8474], "Qscr;": [119980], "Rang;": [10219], "Rarr;": [8608], "Ropf;": [8477], "Rscr;": [8475], "SHcy;": [1064], "Sopf;": [120138], "Sqrt;": [8730], "Sscr;": [119982], "Star;": [8902], "THORN": [222], "TScy;": [1062], "Topf;": [120139], "Tscr;": [119983], "Uarr;": [8607], "Ucirc": [219], "Uopf;": [120140], "Upsi;": [978], "Uscr;": [119984], "Uuml;": [220], "Vbar;": [10987], "Vert;": [8214], "Vopf;": [120141], "Vscr;": [119985], "Wopf;": [120142], "Wscr;": [119986], "Xopf;": [120143], "Xscr;": [119987], "YAcy;": [1071], "YIcy;": [1031], "YUcy;": [1070], "Yopf;": [120144], "Yscr;": [119988], "Yuml;": [376], "ZHcy;": [1046], "Zdot;": [379], "Zeta;": [918], "Zopf;": [8484], "Zscr;": [119989], "acirc": [226], "acute": [180], "aelig": [230], "andd;": [10844], "andv;": [10842], "ange;": [10660], "aopf;": [120146], "apid;": [8779], "apos;": [39], "aring": [229], "ascr;": [119990], "auml;": [228], "bNot;": [10989], "bbrk;": [9141], "beta;": [946], "beth;": [8502], "bnot;": [8976], "bopf;": [120147], "boxH;": [9552], "boxV;": [9553], "boxh;": [9472], "boxv;": [9474], "bscr;": [119991], "bsim;": [8765], "bsol;": [92], "bull;": [8226], "bump;": [8782], "caps;": [8745, 65024], "cdot;": [267], "cedil": [184], "cent;": [162], "chcy;": [1095], "cirE;": [10691], "circ;": [710], "cire;": [8791], "comp;": [8705], "cong;": [8773], "copf;": [120148], "copy;": [169], "cscr;": [119992], "csub;": [10959], "csup;": [10960], "cups;": [8746, 65024], "dArr;": [8659], "dHar;": [10597], "darr;": [8595], "dash;": [8208], "diam;": [8900], "djcy;": [1106], "dopf;": [120149], "dscr;": [119993], "dscy;": [1109], "dsol;": [10742], "dtri;": [9663], "dzcy;": [1119], "eDot;": [8785], "ecir;": [8790], "ecirc": [234], "edot;": [279], "emsp;": [8195], "ensp;": [8194], "eopf;": [120150], "epar;": [8917], "epsi;": [949], "escr;": [8495], "esim;": [8770], "euml;": [235], "euro;": [8364], "excl;": [33], "flat;": [9837], "fnof;": [402], "fopf;": [120151], "fork;": [8916], "fscr;": [119995], "gdot;": [289], "geqq;": [8807], "gesl;": [8923, 65024], "gjcy;": [1107], "gnap;": [10890], "gneq;": [10888], "gopf;": [120152], "gscr;": [8458], "gsim;": [8819], "gtcc;": [10919], "gvnE;": [8809, 65024], "hArr;": [8660], "half;": [189], "harr;": [8596], "hbar;": [8463], "hopf;": [120153], "hscr;": [119997], "icirc": [238], "iecy;": [1077], "iexcl": [161], "imof;": [8887], "iocy;": [1105], "iopf;": [120154], "iota;": [953], "iscr;": [119998], "isin;": [8712], "iuml;": [239], "jopf;": [120155], "jscr;": [119999], "khcy;": [1093], "kjcy;": [1116], "kopf;": [120156], "kscr;": [120000], "lArr;": [8656], "lHar;": [10594], "lang;": [10216], "laquo": [171], "larr;": [8592], "late;": [10925], "lcub;": [123], "ldca;": [10550], "ldsh;": [8626], "leqq;": [8806], "lesg;": [8922, 65024], "ljcy;": [1113], "lnap;": [10889], "lneq;": [10887], "lopf;": [120157], "lozf;": [10731], "lpar;": [40], "lscr;": [120001], "lsim;": [8818], "lsqb;": [91], "ltcc;": [10918], "ltri;": [9667], "lvnE;": [8808, 65024], "macr;": [175], "male;": [9794], "malt;": [10016], "micro": [181], "mlcp;": [10971], "mldr;": [8230], "mopf;": [120158], "mscr;": [120002], "nGtv;": [8811, 824], "nLtv;": [8810, 824], "nang;": [8736, 8402], "napE;": [10864, 824], "nbsp;": [160], "ncap;": [10819], "ncup;": [10818], "ngeq;": [8817], "nges;": [10878, 824], "ngtr;": [8815], "nisd;": [8954], "njcy;": [1114], "nldr;": [8229], "nleq;": [8816], "nles;": [10877, 824], "nmid;": [8740], "nopf;": [120159], "npar;": [8742], "npre;": [10927, 824], "nsce;": [10928, 824], "nscr;": [120003], "nsim;": [8769], "nsub;": [8836], "nsup;": [8837], "ntgl;": [8825], "ntlg;": [8824], "nvap;": [8781, 8402], "nvge;": [8805, 8402], "nvgt;": [62, 8402], "nvle;": [8804, 8402], "nvlt;": [60, 8402], "oast;": [8859], "ocir;": [8858], "ocirc": [244], "odiv;": [10808], "odot;": [8857], "ogon;": [731], "oint;": [8750], "omid;": [10678], "oopf;": [120160], "opar;": [10679], "ordf;": [170], "ordm;": [186], "oror;": [10838], "oscr;": [8500], "osol;": [8856], "ouml;": [246], "para;": [182], "part;": [8706], "perp;": [8869], "phiv;": [981], "plus;": [43], "popf;": [120161], "pound": [163], "prap;": [10935], "prec;": [8826], "prnE;": [10933], "prod;": [8719], "prop;": [8733], "pscr;": [120005], "qint;": [10764], "qopf;": [120162], "qscr;": [120006], "quot;": [34], "rArr;": [8658], "rHar;": [10596], "race;": [8765, 817], "rang;": [10217], "raquo": [187], "rarr;": [8594], "rcub;": [125], "rdca;": [10551], "rdsh;": [8627], "real;": [8476], "rect;": [9645], "rhov;": [1009], "ring;": [730], "ropf;": [120163], "rpar;": [41], "rscr;": [120007], "rsqb;": [93], "rtri;": [9657], "scap;": [10936], "scnE;": [10934], "sdot;": [8901], "sect;": [167], "semi;": [59], "sext;": [10038], "shcy;": [1096], "sime;": [8771], "simg;": [10910], "siml;": [10909], "smid;": [8739], "smte;": [10924], "solb;": [10692], "sopf;": [120164], "spar;": [8741], "squf;": [9642], "sscr;": [120008], "star;": [9734], "subE;": [10949], "sube;": [8838], "succ;": [8827], "sung;": [9834], "sup1;": [185], "sup2;": [178], "sup3;": [179], "supE;": [10950], "supe;": [8839], "szlig": [223], "tbrk;": [9140], "tdot;": [8411], "thorn": [254], "times": [215], "tint;": [8749], "toea;": [10536], "topf;": [120165], "tosa;": [10537], "trie;": [8796], "tscr;": [120009], "tscy;": [1094], "uArr;": [8657], "uHar;": [10595], "uarr;": [8593], "ucirc": [251], "uopf;": [120166], "upsi;": [965], "uscr;": [120010], "utri;": [9653], "uuml;": [252], "vArr;": [8661], "vBar;": [10984], "varr;": [8597], "vert;": [124], "vopf;": [120167], "vscr;": [120011], "wopf;": [120168], "wscr;": [120012], "xcap;": [8898], "xcup;": [8899], "xmap;": [10236], "xnis;": [8955], "xopf;": [120169], "xscr;": [120013], "xvee;": [8897], "yacy;": [1103], "yicy;": [1111], "yopf;": [120170], "yscr;": [120014], "yucy;": [1102], "yuml;": [255], "zdot;": [380], "zeta;": [950], "zhcy;": [1078], "zopf;": [120171], "zscr;": [120015], "zwnj;": [8204] } }, { "length": 4, "entities": { "AMP;": [38], "Acy;": [1040], "Afr;": [120068], "And;": [10835], "Auml": [196], "Bcy;": [1041], "Bfr;": [120069], "COPY": [169], "Cap;": [8914], "Cfr;": [8493], "Chi;": [935], "Cup;": [8915], "Dcy;": [1044], "Del;": [8711], "Dfr;": [120071], "Dot;": [168], "ENG;": [330], "ETH;": [208], "Ecy;": [1069], "Efr;": [120072], "Eta;": [919], "Euml": [203], "Fcy;": [1060], "Ffr;": [120073], "Gcy;": [1043], "Gfr;": [120074], "Hat;": [94], "Hfr;": [8460], "Icy;": [1048], "Ifr;": [8465], "Int;": [8748], "Iuml": [207], "Jcy;": [1049], "Jfr;": [120077], "Kcy;": [1050], "Kfr;": [120078], "Lcy;": [1051], "Lfr;": [120079], "Lsh;": [8624], "Map;": [10501], "Mcy;": [1052], "Mfr;": [120080], "Ncy;": [1053], "Nfr;": [120081], "Not;": [10988], "Ocy;": [1054], "Ofr;": [120082], "Ouml": [214], "Pcy;": [1055], "Pfr;": [120083], "Phi;": [934], "Psi;": [936], "QUOT": [34], "Qfr;": [120084], "REG;": [174], "Rcy;": [1056], "Rfr;": [8476], "Rho;": [929], "Rsh;": [8625], "Scy;": [1057], "Sfr;": [120086], "Sub;": [8912], "Sum;": [8721], "Sup;": [8913], "Tab;": [9], "Tau;": [932], "Tcy;": [1058], "Tfr;": [120087], "Ucy;": [1059], "Ufr;": [120088], "Uuml": [220], "Vcy;": [1042], "Vee;": [8897], "Vfr;": [120089], "Wfr;": [120090], "Xfr;": [120091], "Ycy;": [1067], "Yfr;": [120092], "Zcy;": [1047], "Zfr;": [8488], "acE;": [8766, 819], "acd;": [8767], "acy;": [1072], "afr;": [120094], "amp;": [38], "and;": [8743], "ang;": [8736], "apE;": [10864], "ape;": [8778], "ast;": [42], "auml": [228], "bcy;": [1073], "bfr;": [120095], "bne;": [61, 8421], "bot;": [8869], "cap;": [8745], "cent": [162], "cfr;": [120096], "chi;": [967], "cir;": [9675], "copy": [169], "cup;": [8746], "dcy;": [1076], "deg;": [176], "dfr;": [120097], "die;": [168], "div;": [247], "dot;": [729], "ecy;": [1101], "efr;": [120098], "egs;": [10902], "ell;": [8467], "els;": [10901], "eng;": [331], "eta;": [951], "eth;": [240], "euml": [235], "fcy;": [1092], "ffr;": [120099], "gEl;": [10892], "gap;": [10886], "gcy;": [1075], "gel;": [8923], "geq;": [8805], "ges;": [10878], "gfr;": [120100], "ggg;": [8921], "glE;": [10898], "gla;": [10917], "glj;": [10916], "gnE;": [8809], "gne;": [10888], "hfr;": [120101], "icy;": [1080], "iff;": [8660], "ifr;": [120102], "int;": [8747], "iuml": [239], "jcy;": [1081], "jfr;": [120103], "kcy;": [1082], "kfr;": [120104], "lEg;": [10891], "lap;": [10885], "lat;": [10923], "lcy;": [1083], "leg;": [8922], "leq;": [8804], "les;": [10877], "lfr;": [120105], "lgE;": [10897], "lnE;": [8808], "lne;": [10887], "loz;": [9674], "lrm;": [8206], "lsh;": [8624], "macr": [175], "map;": [8614], "mcy;": [1084], "mfr;": [120106], "mho;": [8487], "mid;": [8739], "nGg;": [8921, 824], "nGt;": [8811, 8402], "nLl;": [8920, 824], "nLt;": [8810, 8402], "nap;": [8777], "nbsp": [160], "ncy;": [1085], "nfr;": [120107], "ngE;": [8807, 824], "nge;": [8817], "ngt;": [8815], "nis;": [8956], "niv;": [8715], "nlE;": [8806, 824], "nle;": [8816], "nlt;": [8814], "not;": [172], "npr;": [8832], "nsc;": [8833], "num;": [35], "ocy;": [1086], "ofr;": [120108], "ogt;": [10689], "ohm;": [937], "olt;": [10688], "ord;": [10845], "ordf": [170], "ordm": [186], "orv;": [10843], "ouml": [246], "par;": [8741], "para": [182], "pcy;": [1087], "pfr;": [120109], "phi;": [966], "piv;": [982], "prE;": [10931], "pre;": [10927], "psi;": [968], "qfr;": [120110], "quot": [34], "rcy;": [1088], "reg;": [174], "rfr;": [120111], "rho;": [961], "rlm;": [8207], "rsh;": [8625], "scE;": [10932], "sce;": [10928], "scy;": [1089], "sect": [167], "sfr;": [120112], "shy;": [173], "sim;": [8764], "smt;": [10922], "sol;": [47], "squ;": [9633], "sub;": [8834], "sum;": [8721], "sup1": [185], "sup2": [178], "sup3": [179], "sup;": [8835], "tau;": [964], "tcy;": [1090], "tfr;": [120113], "top;": [8868], "ucy;": [1091], "ufr;": [120114], "uml;": [168], "uuml": [252], "vcy;": [1074], "vee;": [8744], "vfr;": [120115], "wfr;": [120116], "xfr;": [120117], "ycy;": [1099], "yen;": [165], "yfr;": [120118], "yuml": [255], "zcy;": [1079], "zfr;": [120119], "zwj;": [8205] } }, { "length": 3, "entities": { "AMP": [38], "DD;": [8517], "ETH": [208], "GT;": [62], "Gg;": [8921], "Gt;": [8811], "Im;": [8465], "LT;": [60], "Ll;": [8920], "Lt;": [8810], "Mu;": [924], "Nu;": [925], "Or;": [10836], "Pi;": [928], "Pr;": [10939], "REG": [174], "Re;": [8476], "Sc;": [10940], "Xi;": [926], "ac;": [8766], "af;": [8289], "amp": [38], "ap;": [8776], "dd;": [8518], "deg": [176], "ee;": [8519], "eg;": [10906], "el;": [10905], "eth": [240], "gE;": [8807], "ge;": [8805], "gg;": [8811], "gl;": [8823], "gt;": [62], "ic;": [8291], "ii;": [8520], "in;": [8712], "it;": [8290], "lE;": [8806], "le;": [8804], "lg;": [8822], "ll;": [8810], "lt;": [60], "mp;": [8723], "mu;": [956], "ne;": [8800], "ni;": [8715], "not": [172], "nu;": [957], "oS;": [9416], "or;": [8744], "pi;": [960], "pm;": [177], "pr;": [8826], "reg": [174], "rx;": [8478], "sc;": [8827], "shy": [173], "uml": [168], "wp;": [8472], "wr;": [8768], "xi;": [958], "yen": [165] } }, { "length": 2, "entities": { "GT": [62], "LT": [60], "gt": [62], "lt": [60] } }];
1986
1987const EOF = -1;
1988const NULL = 0x00;
1989const TABULATION = 0x09;
1990const CARRIAGE_RETURN = 0x0D;
1991const LINE_FEED = 0x0A;
1992const FORM_FEED = 0x0C;
1993const SPACE = 0x20;
1994const EXCLAMATION_MARK = 0x21;
1995const QUOTATION_MARK = 0x22;
1996const NUMBER_SIGN = 0x23;
1997const AMPERSAND = 0x26;
1998const APOSTROPHE = 0x27;
1999const HYPHEN_MINUS = 0x2D;
2000const SOLIDUS = 0x2F;
2001const DIGIT_0 = 0x30;
2002const DIGIT_9 = 0x39;
2003const SEMICOLON = 0x3B;
2004const LESS_THAN_SIGN = 0x3C;
2005const EQUALS_SIGN = 0x3D;
2006const GREATER_THAN_SIGN = 0x3E;
2007const QUESTION_MARK = 0x3F;
2008const LATIN_CAPITAL_A = 0x41;
2009const LATIN_CAPITAL_D = 0x44;
2010const LATIN_CAPITAL_F = 0x46;
2011const LATIN_CAPITAL_X = 0x58;
2012const LATIN_CAPITAL_Z = 0x5A;
2013const LEFT_SQUARE_BRACKET = 0x5B;
2014const RIGHT_SQUARE_BRACKET = 0x5D;
2015const GRAVE_ACCENT = 0x60;
2016const LATIN_SMALL_A = 0x61;
2017const LATIN_SMALL_F = 0x66;
2018const LATIN_SMALL_X = 0x78;
2019const LATIN_SMALL_Z = 0x7A;
2020const LEFT_CURLY_BRACKET = 0x7B;
2021const RIGHT_CURLY_BRACKET = 0x7D;
2022const NULL_REPLACEMENT = 0xFFFD;
2023function isWhitespace(cp) {
2024 return cp === TABULATION || cp === LINE_FEED || cp === FORM_FEED || cp === CARRIAGE_RETURN || cp === SPACE;
2025}
2026function isUpperLetter(cp) {
2027 return cp >= LATIN_CAPITAL_A && cp <= LATIN_CAPITAL_Z;
2028}
2029function isLowerLetter(cp) {
2030 return cp >= LATIN_SMALL_A && cp <= LATIN_SMALL_Z;
2031}
2032function isLetter(cp) {
2033 return isLowerLetter(cp) || isUpperLetter(cp);
2034}
2035function isDigit(cp) {
2036 return cp >= DIGIT_0 && cp <= DIGIT_9;
2037}
2038function isUpperHexDigit(cp) {
2039 return cp >= LATIN_CAPITAL_A && cp <= LATIN_CAPITAL_F;
2040}
2041function isLowerHexDigit(cp) {
2042 return cp >= LATIN_SMALL_A && cp <= LATIN_SMALL_F;
2043}
2044function isHexDigit(cp) {
2045 return isDigit(cp) || isUpperHexDigit(cp) || isLowerHexDigit(cp);
2046}
2047function isControl(cp) {
2048 return (cp >= 0 && cp <= 0x1F) || (cp >= 0x7F && cp <= 0x9F);
2049}
2050function isSurrogate(cp) {
2051 return cp >= 0xD800 && cp <= 0xDFFF;
2052}
2053function isSurrogatePair(cp) {
2054 return cp >= 0xDC00 && cp <= 0xDFFF;
2055}
2056function isNonCharacter(cp) {
2057 return ((cp >= 0xFDD0 && cp <= 0xFDEF) ||
2058 ((cp & 0xFFFE) === 0xFFFE && cp <= 0x10FFFF));
2059}
2060function toLowerCodePoint(cp) {
2061 return cp + 0x0020;
2062}
2063
2064class Tokenizer {
2065 constructor(text) {
2066 debug("[html] the source code length: %d", text.length);
2067 this.text = text;
2068 this.gaps = [];
2069 this.lineTerminators = [];
2070 this.lastCodePoint = NULL;
2071 this.offset = -1;
2072 this.column = -1;
2073 this.line = 1;
2074 this.state = "DATA";
2075 this.returnState = "DATA";
2076 this.reconsuming = false;
2077 this.buffer = [];
2078 this.crStartOffset = -1;
2079 this.crCode = 0;
2080 this.errors = [];
2081 this.committedToken = null;
2082 this.provisionalToken = null;
2083 this.currentToken = null;
2084 this.lastTagOpenToken = null;
2085 this.tokenStartOffset = -1;
2086 this.tokenStartColumn = -1;
2087 this.tokenStartLine = 1;
2088 this.namespace = NS.HTML;
2089 this.expressionEnabled = false;
2090 }
2091 nextToken() {
2092 let cp = this.lastCodePoint;
2093 while (this.committedToken == null &&
2094 (cp !== EOF || this.reconsuming)) {
2095 if (this.provisionalToken != null && !this.isProvisionalState()) {
2096 this.commitProvisionalToken();
2097 if (this.committedToken != null) {
2098 break;
2099 }
2100 }
2101 if (this.reconsuming) {
2102 this.reconsuming = false;
2103 cp = this.lastCodePoint;
2104 }
2105 else {
2106 cp = this.consumeNextCodePoint();
2107 }
2108 debug("[html] parse", cp, this.state);
2109 this.state = this[this.state](cp);
2110 }
2111 {
2112 const token = this.consumeCommittedToken();
2113 if (token != null) {
2114 return token;
2115 }
2116 }
2117 assert(cp === EOF);
2118 if (this.currentToken != null) {
2119 this.endToken();
2120 const token = this.consumeCommittedToken();
2121 if (token != null) {
2122 return token;
2123 }
2124 }
2125 return this.currentToken;
2126 }
2127 consumeCommittedToken() {
2128 const token = this.committedToken;
2129 this.committedToken = null;
2130 return token;
2131 }
2132 consumeNextCodePoint() {
2133 if (this.offset >= this.text.length) {
2134 this.lastCodePoint = EOF;
2135 return EOF;
2136 }
2137 this.offset += this.lastCodePoint >= 0x10000 ? 2 : 1;
2138 if (this.offset >= this.text.length) {
2139 this.advanceLocation();
2140 this.lastCodePoint = EOF;
2141 return EOF;
2142 }
2143 const cp = this.text.codePointAt(this.offset);
2144 if (isSurrogate(this.text.charCodeAt(this.offset)) &&
2145 !isSurrogatePair(this.text.charCodeAt(this.offset + 1))) {
2146 this.reportParseError("surrogate-in-input-stream");
2147 }
2148 if (isNonCharacter(cp)) {
2149 this.reportParseError("noncharacter-in-input-stream");
2150 }
2151 if (isControl(cp) && !isWhitespace(cp) && cp !== NULL) {
2152 this.reportParseError("control-character-in-input-stream");
2153 }
2154 if (this.lastCodePoint === CARRIAGE_RETURN && cp === LINE_FEED) {
2155 this.lastCodePoint = LINE_FEED;
2156 this.gaps.push(this.offset);
2157 return this.consumeNextCodePoint();
2158 }
2159 this.advanceLocation();
2160 this.lastCodePoint = cp;
2161 if (cp === CARRIAGE_RETURN) {
2162 return LINE_FEED;
2163 }
2164 return cp;
2165 }
2166 advanceLocation() {
2167 if (this.lastCodePoint === LINE_FEED) {
2168 this.lineTerminators.push(this.offset);
2169 this.line += 1;
2170 this.column = 0;
2171 }
2172 else {
2173 this.column += this.lastCodePoint >= 0x10000 ? 2 : 1;
2174 }
2175 }
2176 reconsumeAs(state) {
2177 this.reconsuming = true;
2178 return state;
2179 }
2180 reportParseError(code) {
2181 const error = ParseError.fromCode(code, this.offset, this.line, this.column);
2182 this.errors.push(error);
2183 debug("[html] syntax error:", error.message);
2184 }
2185 setStartTokenMark() {
2186 this.tokenStartOffset = this.offset;
2187 this.tokenStartLine = this.line;
2188 this.tokenStartColumn = this.column;
2189 }
2190 clearStartTokenMark() {
2191 this.tokenStartOffset = -1;
2192 }
2193 startToken(type) {
2194 if (this.tokenStartOffset === -1) {
2195 this.setStartTokenMark();
2196 }
2197 const offset = this.tokenStartOffset;
2198 const line = this.tokenStartLine;
2199 const column = this.tokenStartColumn;
2200 if (this.currentToken != null) {
2201 this.endToken();
2202 }
2203 this.tokenStartOffset = -1;
2204 const token = (this.currentToken = {
2205 type,
2206 range: [offset, -1],
2207 loc: {
2208 start: { line, column },
2209 end: { line: -1, column: -1 },
2210 },
2211 value: "",
2212 });
2213 debug("[html] start token: %d %s", offset, token.type);
2214 return this.currentToken;
2215 }
2216 endToken() {
2217 if (this.currentToken == null) {
2218 throw new Error("Invalid state");
2219 }
2220 if (this.tokenStartOffset === -1) {
2221 this.setStartTokenMark();
2222 }
2223 const token = this.currentToken;
2224 const offset = this.tokenStartOffset;
2225 const line = this.tokenStartLine;
2226 const column = this.tokenStartColumn;
2227 const provisional = this.isProvisionalState();
2228 this.currentToken = null;
2229 this.tokenStartOffset = -1;
2230 token.range[1] = offset;
2231 token.loc.end.line = line;
2232 token.loc.end.column = column;
2233 if (token.range[0] === offset && !provisional) {
2234 debug("[html] abandon token: %j %s %j", token.range, token.type, token.value);
2235 return null;
2236 }
2237 if (provisional) {
2238 if (this.provisionalToken != null) {
2239 this.commitProvisionalToken();
2240 }
2241 this.provisionalToken = token;
2242 debug("[html] provisional-commit token: %j %s %j", token.range, token.type, token.value);
2243 }
2244 else {
2245 this.commitToken(token);
2246 }
2247 return token;
2248 }
2249 commitToken(token) {
2250 assert(this.committedToken == null, "Invalid state: the commited token existed already.");
2251 debug("[html] commit token: %j %j %s %j", token.range, token.loc, token.type, token.value);
2252 this.committedToken = token;
2253 if (token.type === "HTMLTagOpen") {
2254 this.lastTagOpenToken = token;
2255 }
2256 }
2257 isProvisionalState() {
2258 return (this.state.startsWith("RCDATA_") ||
2259 this.state.startsWith("RAWTEXT_"));
2260 }
2261 commitProvisionalToken() {
2262 assert(this.provisionalToken != null, "Invalid state: the provisional token was not found.");
2263 const token = this.provisionalToken;
2264 this.provisionalToken = null;
2265 if (token.range[0] < token.range[1]) {
2266 this.commitToken(token);
2267 }
2268 }
2269 rollbackProvisionalToken() {
2270 assert(this.currentToken != null);
2271 assert(this.provisionalToken != null);
2272 const token = this.currentToken;
2273 debug("[html] rollback token: %d %s", token.range[0], token.type);
2274 this.currentToken = this.provisionalToken;
2275 this.provisionalToken = null;
2276 }
2277 appendTokenValue(cp, expected) {
2278 const token = this.currentToken;
2279 if (token == null || (expected != null && token.type !== expected)) {
2280 const msg1 = expected ? `"${expected}" type` : "any token";
2281 const msg2 = token ? `"${token.type}" type` : "no token";
2282 throw new Error(`Tokenizer: Invalid state. Expected ${msg1}, but got ${msg2}.`);
2283 }
2284 token.value += String.fromCodePoint(cp);
2285 }
2286 isAppropriateEndTagOpen() {
2287 return (this.currentToken != null &&
2288 this.lastTagOpenToken != null &&
2289 this.currentToken.type === "HTMLEndTagOpen" &&
2290 this.currentToken.value === this.lastTagOpenToken.value);
2291 }
2292 DATA(cp) {
2293 this.clearStartTokenMark();
2294 while (true) {
2295 const type = isWhitespace(cp) ? "HTMLWhitespace" : "HTMLText";
2296 if (this.currentToken != null && this.currentToken.type !== type) {
2297 this.endToken();
2298 return this.reconsumeAs(this.state);
2299 }
2300 if (this.currentToken == null) {
2301 this.startToken(type);
2302 }
2303 if (cp === AMPERSAND) {
2304 this.returnState = "DATA";
2305 return "CHARACTER_REFERENCE";
2306 }
2307 if (cp === LESS_THAN_SIGN) {
2308 this.setStartTokenMark();
2309 return "TAG_OPEN";
2310 }
2311 if (cp === LEFT_CURLY_BRACKET && this.expressionEnabled) {
2312 this.setStartTokenMark();
2313 this.returnState = "DATA";
2314 return "V_EXPRESSION_START";
2315 }
2316 if (cp === RIGHT_CURLY_BRACKET && this.expressionEnabled) {
2317 this.setStartTokenMark();
2318 this.returnState = "DATA";
2319 return "V_EXPRESSION_END";
2320 }
2321 if (cp === EOF) {
2322 return "DATA";
2323 }
2324 if (cp === NULL) {
2325 this.reportParseError("unexpected-null-character");
2326 }
2327 this.appendTokenValue(cp, type);
2328 cp = this.consumeNextCodePoint();
2329 }
2330 }
2331 RCDATA(cp) {
2332 this.clearStartTokenMark();
2333 while (true) {
2334 const type = isWhitespace(cp) ? "HTMLWhitespace" : "HTMLRCDataText";
2335 if (this.currentToken != null && this.currentToken.type !== type) {
2336 this.endToken();
2337 return this.reconsumeAs(this.state);
2338 }
2339 if (this.currentToken == null) {
2340 this.startToken(type);
2341 }
2342 if (cp === AMPERSAND) {
2343 this.returnState = "RCDATA";
2344 return "CHARACTER_REFERENCE";
2345 }
2346 if (cp === LESS_THAN_SIGN) {
2347 this.setStartTokenMark();
2348 return "RCDATA_LESS_THAN_SIGN";
2349 }
2350 if (cp === LEFT_CURLY_BRACKET && this.expressionEnabled) {
2351 this.setStartTokenMark();
2352 this.returnState = "RCDATA";
2353 return "V_EXPRESSION_START";
2354 }
2355 if (cp === RIGHT_CURLY_BRACKET && this.expressionEnabled) {
2356 this.setStartTokenMark();
2357 this.returnState = "RCDATA";
2358 return "V_EXPRESSION_END";
2359 }
2360 if (cp === EOF) {
2361 return "DATA";
2362 }
2363 if (cp === NULL) {
2364 this.reportParseError("unexpected-null-character");
2365 cp = NULL_REPLACEMENT;
2366 }
2367 this.appendTokenValue(cp, type);
2368 cp = this.consumeNextCodePoint();
2369 }
2370 }
2371 RAWTEXT(cp) {
2372 this.clearStartTokenMark();
2373 while (true) {
2374 const type = isWhitespace(cp) ? "HTMLWhitespace" : "HTMLRawText";
2375 if (this.currentToken != null && this.currentToken.type !== type) {
2376 this.endToken();
2377 return this.reconsumeAs(this.state);
2378 }
2379 if (this.currentToken == null) {
2380 this.startToken(type);
2381 }
2382 if (cp === LESS_THAN_SIGN) {
2383 this.setStartTokenMark();
2384 return "RAWTEXT_LESS_THAN_SIGN";
2385 }
2386 if (cp === LEFT_CURLY_BRACKET && this.expressionEnabled) {
2387 this.setStartTokenMark();
2388 this.returnState = "RAWTEXT";
2389 return "V_EXPRESSION_START";
2390 }
2391 if (cp === RIGHT_CURLY_BRACKET && this.expressionEnabled) {
2392 this.setStartTokenMark();
2393 this.returnState = "RAWTEXT";
2394 return "V_EXPRESSION_END";
2395 }
2396 if (cp === EOF) {
2397 return "DATA";
2398 }
2399 if (cp === NULL) {
2400 this.reportParseError("unexpected-null-character");
2401 cp = NULL_REPLACEMENT;
2402 }
2403 this.appendTokenValue(cp, type);
2404 cp = this.consumeNextCodePoint();
2405 }
2406 }
2407 TAG_OPEN(cp) {
2408 if (cp === EXCLAMATION_MARK) {
2409 return "MARKUP_DECLARATION_OPEN";
2410 }
2411 if (cp === SOLIDUS) {
2412 return "END_TAG_OPEN";
2413 }
2414 if (isLetter(cp)) {
2415 this.startToken("HTMLTagOpen");
2416 return this.reconsumeAs("TAG_NAME");
2417 }
2418 if (cp === QUESTION_MARK) {
2419 this.reportParseError("unexpected-question-mark-instead-of-tag-name");
2420 this.startToken("HTMLBogusComment");
2421 return this.reconsumeAs("BOGUS_COMMENT");
2422 }
2423 if (cp === EOF) {
2424 this.clearStartTokenMark();
2425 this.reportParseError("eof-before-tag-name");
2426 this.appendTokenValue(LESS_THAN_SIGN, "HTMLText");
2427 return "DATA";
2428 }
2429 this.reportParseError("invalid-first-character-of-tag-name");
2430 this.appendTokenValue(LESS_THAN_SIGN, "HTMLText");
2431 return this.reconsumeAs("DATA");
2432 }
2433 END_TAG_OPEN(cp) {
2434 if (isLetter(cp)) {
2435 this.startToken("HTMLEndTagOpen");
2436 return this.reconsumeAs("TAG_NAME");
2437 }
2438 if (cp === GREATER_THAN_SIGN) {
2439 this.endToken();
2440 this.reportParseError("missing-end-tag-name");
2441 return "DATA";
2442 }
2443 if (cp === EOF) {
2444 this.clearStartTokenMark();
2445 this.reportParseError("eof-before-tag-name");
2446 this.appendTokenValue(LESS_THAN_SIGN, "HTMLText");
2447 this.appendTokenValue(SOLIDUS, "HTMLText");
2448 return "DATA";
2449 }
2450 this.reportParseError("invalid-first-character-of-tag-name");
2451 this.startToken("HTMLBogusComment");
2452 return this.reconsumeAs("BOGUS_COMMENT");
2453 }
2454 TAG_NAME(cp) {
2455 while (true) {
2456 if (isWhitespace(cp)) {
2457 this.endToken();
2458 return "BEFORE_ATTRIBUTE_NAME";
2459 }
2460 if (cp === SOLIDUS) {
2461 this.endToken();
2462 this.setStartTokenMark();
2463 return "SELF_CLOSING_START_TAG";
2464 }
2465 if (cp === GREATER_THAN_SIGN) {
2466 this.startToken("HTMLTagClose");
2467 return "DATA";
2468 }
2469 if (cp === EOF) {
2470 this.reportParseError("eof-in-tag");
2471 return "DATA";
2472 }
2473 if (cp === NULL) {
2474 this.reportParseError("unexpected-null-character");
2475 cp = NULL_REPLACEMENT;
2476 }
2477 this.appendTokenValue(isUpperLetter(cp) ? toLowerCodePoint(cp) : cp, null);
2478 cp = this.consumeNextCodePoint();
2479 }
2480 }
2481 RCDATA_LESS_THAN_SIGN(cp) {
2482 if (cp === SOLIDUS) {
2483 this.buffer = [];
2484 return "RCDATA_END_TAG_OPEN";
2485 }
2486 this.appendTokenValue(LESS_THAN_SIGN, "HTMLRCDataText");
2487 return this.reconsumeAs("RCDATA");
2488 }
2489 RCDATA_END_TAG_OPEN(cp) {
2490 if (isLetter(cp)) {
2491 this.startToken("HTMLEndTagOpen");
2492 return this.reconsumeAs("RCDATA_END_TAG_NAME");
2493 }
2494 this.appendTokenValue(LESS_THAN_SIGN, "HTMLRCDataText");
2495 this.appendTokenValue(SOLIDUS, "HTMLRCDataText");
2496 return this.reconsumeAs("RCDATA");
2497 }
2498 RCDATA_END_TAG_NAME(cp) {
2499 while (true) {
2500 if (isWhitespace(cp) && this.isAppropriateEndTagOpen()) {
2501 this.endToken();
2502 return "BEFORE_ATTRIBUTE_NAME";
2503 }
2504 if (cp === SOLIDUS && this.isAppropriateEndTagOpen()) {
2505 this.endToken();
2506 this.setStartTokenMark();
2507 return "SELF_CLOSING_START_TAG";
2508 }
2509 if (cp === GREATER_THAN_SIGN && this.isAppropriateEndTagOpen()) {
2510 this.startToken("HTMLTagClose");
2511 return "DATA";
2512 }
2513 if (!isLetter(cp)) {
2514 this.rollbackProvisionalToken();
2515 this.appendTokenValue(LESS_THAN_SIGN, "HTMLRCDataText");
2516 this.appendTokenValue(SOLIDUS, "HTMLRCDataText");
2517 for (const cp1 of this.buffer) {
2518 this.appendTokenValue(cp1, "HTMLRCDataText");
2519 }
2520 return this.reconsumeAs("RCDATA");
2521 }
2522 this.appendTokenValue(isUpperLetter(cp) ? toLowerCodePoint(cp) : cp, "HTMLEndTagOpen");
2523 this.buffer.push(cp);
2524 cp = this.consumeNextCodePoint();
2525 }
2526 }
2527 RAWTEXT_LESS_THAN_SIGN(cp) {
2528 if (cp === SOLIDUS) {
2529 this.buffer = [];
2530 return "RAWTEXT_END_TAG_OPEN";
2531 }
2532 this.appendTokenValue(LESS_THAN_SIGN, "HTMLRawText");
2533 return this.reconsumeAs("RAWTEXT");
2534 }
2535 RAWTEXT_END_TAG_OPEN(cp) {
2536 if (isLetter(cp)) {
2537 this.startToken("HTMLEndTagOpen");
2538 return this.reconsumeAs("RAWTEXT_END_TAG_NAME");
2539 }
2540 this.appendTokenValue(LESS_THAN_SIGN, "HTMLRawText");
2541 this.appendTokenValue(SOLIDUS, "HTMLRawText");
2542 return this.reconsumeAs("RAWTEXT");
2543 }
2544 RAWTEXT_END_TAG_NAME(cp) {
2545 while (true) {
2546 if (cp === SOLIDUS && this.isAppropriateEndTagOpen()) {
2547 this.endToken();
2548 this.setStartTokenMark();
2549 return "SELF_CLOSING_START_TAG";
2550 }
2551 if (cp === GREATER_THAN_SIGN && this.isAppropriateEndTagOpen()) {
2552 this.startToken("HTMLTagClose");
2553 return "DATA";
2554 }
2555 if (isWhitespace(cp) && this.isAppropriateEndTagOpen()) {
2556 this.endToken();
2557 return "BEFORE_ATTRIBUTE_NAME";
2558 }
2559 if (!isLetter(cp)) {
2560 this.rollbackProvisionalToken();
2561 this.appendTokenValue(LESS_THAN_SIGN, "HTMLRawText");
2562 this.appendTokenValue(SOLIDUS, "HTMLRawText");
2563 for (const cp1 of this.buffer) {
2564 this.appendTokenValue(cp1, "HTMLRawText");
2565 }
2566 return this.reconsumeAs("RAWTEXT");
2567 }
2568 this.appendTokenValue(isUpperLetter(cp) ? toLowerCodePoint(cp) : cp, "HTMLEndTagOpen");
2569 this.buffer.push(cp);
2570 cp = this.consumeNextCodePoint();
2571 }
2572 }
2573 BEFORE_ATTRIBUTE_NAME(cp) {
2574 while (isWhitespace(cp)) {
2575 cp = this.consumeNextCodePoint();
2576 }
2577 if (cp === SOLIDUS || cp === GREATER_THAN_SIGN || cp === EOF) {
2578 return this.reconsumeAs("AFTER_ATTRIBUTE_NAME");
2579 }
2580 if (cp === EQUALS_SIGN) {
2581 this.reportParseError("unexpected-equals-sign-before-attribute-name");
2582 this.startToken("HTMLIdentifier");
2583 this.appendTokenValue(cp, "HTMLIdentifier");
2584 return "ATTRIBUTE_NAME";
2585 }
2586 this.startToken("HTMLIdentifier");
2587 return this.reconsumeAs("ATTRIBUTE_NAME");
2588 }
2589 ATTRIBUTE_NAME(cp) {
2590 while (true) {
2591 if (isWhitespace(cp) ||
2592 cp === SOLIDUS ||
2593 cp === GREATER_THAN_SIGN ||
2594 cp === EOF) {
2595 this.endToken();
2596 return this.reconsumeAs("AFTER_ATTRIBUTE_NAME");
2597 }
2598 if (cp === EQUALS_SIGN) {
2599 this.startToken("HTMLAssociation");
2600 return "BEFORE_ATTRIBUTE_VALUE";
2601 }
2602 if (cp === NULL) {
2603 this.reportParseError("unexpected-null-character");
2604 cp = NULL_REPLACEMENT;
2605 }
2606 if (cp === QUOTATION_MARK ||
2607 cp === APOSTROPHE ||
2608 cp === LESS_THAN_SIGN) {
2609 this.reportParseError("unexpected-character-in-attribute-name");
2610 }
2611 this.appendTokenValue(isUpperLetter(cp) ? toLowerCodePoint(cp) : cp, "HTMLIdentifier");
2612 cp = this.consumeNextCodePoint();
2613 }
2614 }
2615 AFTER_ATTRIBUTE_NAME(cp) {
2616 while (isWhitespace(cp)) {
2617 cp = this.consumeNextCodePoint();
2618 }
2619 if (cp === SOLIDUS) {
2620 this.setStartTokenMark();
2621 return "SELF_CLOSING_START_TAG";
2622 }
2623 if (cp === EQUALS_SIGN) {
2624 this.startToken("HTMLAssociation");
2625 return "BEFORE_ATTRIBUTE_VALUE";
2626 }
2627 if (cp === GREATER_THAN_SIGN) {
2628 this.startToken("HTMLTagClose");
2629 return "DATA";
2630 }
2631 if (cp === EOF) {
2632 this.reportParseError("eof-in-tag");
2633 return "DATA";
2634 }
2635 this.startToken("HTMLIdentifier");
2636 return this.reconsumeAs("ATTRIBUTE_NAME");
2637 }
2638 BEFORE_ATTRIBUTE_VALUE(cp) {
2639 this.endToken();
2640 while (isWhitespace(cp)) {
2641 cp = this.consumeNextCodePoint();
2642 }
2643 if (cp === GREATER_THAN_SIGN) {
2644 this.reportParseError("missing-attribute-value");
2645 this.startToken("HTMLTagClose");
2646 return "DATA";
2647 }
2648 this.startToken("HTMLLiteral");
2649 if (cp === QUOTATION_MARK) {
2650 return "ATTRIBUTE_VALUE_DOUBLE_QUOTED";
2651 }
2652 if (cp === APOSTROPHE) {
2653 return "ATTRIBUTE_VALUE_SINGLE_QUOTED";
2654 }
2655 return this.reconsumeAs("ATTRIBUTE_VALUE_UNQUOTED");
2656 }
2657 ATTRIBUTE_VALUE_DOUBLE_QUOTED(cp) {
2658 while (true) {
2659 if (cp === QUOTATION_MARK) {
2660 return "AFTER_ATTRIBUTE_VALUE_QUOTED";
2661 }
2662 if (cp === AMPERSAND) {
2663 this.returnState = "ATTRIBUTE_VALUE_DOUBLE_QUOTED";
2664 return "CHARACTER_REFERENCE";
2665 }
2666 if (cp === NULL) {
2667 this.reportParseError("unexpected-null-character");
2668 cp = NULL_REPLACEMENT;
2669 }
2670 if (cp === EOF) {
2671 this.reportParseError("eof-in-tag");
2672 return "DATA";
2673 }
2674 this.appendTokenValue(cp, "HTMLLiteral");
2675 cp = this.consumeNextCodePoint();
2676 }
2677 }
2678 ATTRIBUTE_VALUE_SINGLE_QUOTED(cp) {
2679 while (true) {
2680 if (cp === APOSTROPHE) {
2681 return "AFTER_ATTRIBUTE_VALUE_QUOTED";
2682 }
2683 if (cp === AMPERSAND) {
2684 this.returnState = "ATTRIBUTE_VALUE_SINGLE_QUOTED";
2685 return "CHARACTER_REFERENCE";
2686 }
2687 if (cp === NULL) {
2688 this.reportParseError("unexpected-null-character");
2689 cp = NULL_REPLACEMENT;
2690 }
2691 if (cp === EOF) {
2692 this.reportParseError("eof-in-tag");
2693 return "DATA";
2694 }
2695 this.appendTokenValue(cp, "HTMLLiteral");
2696 cp = this.consumeNextCodePoint();
2697 }
2698 }
2699 ATTRIBUTE_VALUE_UNQUOTED(cp) {
2700 while (true) {
2701 if (isWhitespace(cp)) {
2702 this.endToken();
2703 return "BEFORE_ATTRIBUTE_NAME";
2704 }
2705 if (cp === AMPERSAND) {
2706 this.returnState = "ATTRIBUTE_VALUE_UNQUOTED";
2707 return "CHARACTER_REFERENCE";
2708 }
2709 if (cp === GREATER_THAN_SIGN) {
2710 this.startToken("HTMLTagClose");
2711 return "DATA";
2712 }
2713 if (cp === NULL) {
2714 this.reportParseError("unexpected-null-character");
2715 cp = NULL_REPLACEMENT;
2716 }
2717 if (cp === QUOTATION_MARK ||
2718 cp === APOSTROPHE ||
2719 cp === LESS_THAN_SIGN ||
2720 cp === EQUALS_SIGN ||
2721 cp === GRAVE_ACCENT) {
2722 this.reportParseError("unexpected-character-in-unquoted-attribute-value");
2723 }
2724 if (cp === EOF) {
2725 this.reportParseError("eof-in-tag");
2726 return "DATA";
2727 }
2728 this.appendTokenValue(cp, "HTMLLiteral");
2729 cp = this.consumeNextCodePoint();
2730 }
2731 }
2732 AFTER_ATTRIBUTE_VALUE_QUOTED(cp) {
2733 this.endToken();
2734 if (isWhitespace(cp)) {
2735 return "BEFORE_ATTRIBUTE_NAME";
2736 }
2737 if (cp === SOLIDUS) {
2738 this.setStartTokenMark();
2739 return "SELF_CLOSING_START_TAG";
2740 }
2741 if (cp === GREATER_THAN_SIGN) {
2742 this.startToken("HTMLTagClose");
2743 return "DATA";
2744 }
2745 if (cp === EOF) {
2746 this.reportParseError("eof-in-tag");
2747 return "DATA";
2748 }
2749 this.reportParseError("missing-whitespace-between-attributes");
2750 return this.reconsumeAs("BEFORE_ATTRIBUTE_NAME");
2751 }
2752 SELF_CLOSING_START_TAG(cp) {
2753 if (cp === GREATER_THAN_SIGN) {
2754 this.startToken("HTMLSelfClosingTagClose");
2755 return "DATA";
2756 }
2757 if (cp === EOF) {
2758 this.reportParseError("eof-in-tag");
2759 return "DATA";
2760 }
2761 this.reportParseError("unexpected-solidus-in-tag");
2762 this.clearStartTokenMark();
2763 return this.reconsumeAs("BEFORE_ATTRIBUTE_NAME");
2764 }
2765 BOGUS_COMMENT(cp) {
2766 while (true) {
2767 if (cp === GREATER_THAN_SIGN) {
2768 return "DATA";
2769 }
2770 if (cp === EOF) {
2771 return "DATA";
2772 }
2773 if (cp === NULL) {
2774 cp = NULL_REPLACEMENT;
2775 }
2776 this.appendTokenValue(cp, null);
2777 cp = this.consumeNextCodePoint();
2778 }
2779 }
2780 MARKUP_DECLARATION_OPEN(cp) {
2781 if (cp === HYPHEN_MINUS && this.text[this.offset + 1] === "-") {
2782 this.offset += 1;
2783 this.column += 1;
2784 this.startToken("HTMLComment");
2785 return "COMMENT_START";
2786 }
2787 if (cp === LATIN_CAPITAL_D &&
2788 this.text.slice(this.offset + 1, this.offset + 7) === "OCTYPE") {
2789 this.startToken("HTMLBogusComment");
2790 this.appendTokenValue(cp, "HTMLBogusComment");
2791 return "BOGUS_COMMENT";
2792 }
2793 if (cp === LEFT_SQUARE_BRACKET &&
2794 this.text.slice(this.offset + 1, this.offset + 7) === "CDATA[") {
2795 this.offset += 6;
2796 this.column += 6;
2797 if (this.namespace === NS.HTML) {
2798 this.reportParseError("cdata-in-html-content");
2799 this.startToken("HTMLBogusComment").value = "[CDATA[";
2800 return "BOGUS_COMMENT";
2801 }
2802 this.startToken("HTMLCDataText");
2803 return "CDATA_SECTION";
2804 }
2805 this.reportParseError("incorrectly-opened-comment");
2806 this.startToken("HTMLBogusComment");
2807 return this.reconsumeAs("BOGUS_COMMENT");
2808 }
2809 COMMENT_START(cp) {
2810 if (cp === HYPHEN_MINUS) {
2811 return "COMMENT_START_DASH";
2812 }
2813 if (cp === GREATER_THAN_SIGN) {
2814 this.reportParseError("abrupt-closing-of-empty-comment");
2815 return "DATA";
2816 }
2817 return this.reconsumeAs("COMMENT");
2818 }
2819 COMMENT_START_DASH(cp) {
2820 if (cp === HYPHEN_MINUS) {
2821 return "COMMENT_END";
2822 }
2823 if (cp === GREATER_THAN_SIGN) {
2824 this.reportParseError("abrupt-closing-of-empty-comment");
2825 return "DATA";
2826 }
2827 if (cp === EOF) {
2828 this.reportParseError("eof-in-comment");
2829 return "DATA";
2830 }
2831 this.appendTokenValue(HYPHEN_MINUS, "HTMLComment");
2832 return this.reconsumeAs("COMMENT");
2833 }
2834 COMMENT(cp) {
2835 while (true) {
2836 if (cp === LESS_THAN_SIGN) {
2837 this.appendTokenValue(LESS_THAN_SIGN, "HTMLComment");
2838 return "COMMENT_LESS_THAN_SIGN";
2839 }
2840 if (cp === HYPHEN_MINUS) {
2841 return "COMMENT_END_DASH";
2842 }
2843 if (cp === NULL) {
2844 this.reportParseError("unexpected-null-character");
2845 cp = NULL_REPLACEMENT;
2846 }
2847 if (cp === EOF) {
2848 this.reportParseError("eof-in-comment");
2849 return "DATA";
2850 }
2851 this.appendTokenValue(cp, "HTMLComment");
2852 cp = this.consumeNextCodePoint();
2853 }
2854 }
2855 COMMENT_LESS_THAN_SIGN(cp) {
2856 while (true) {
2857 if (cp === EXCLAMATION_MARK) {
2858 this.appendTokenValue(cp, "HTMLComment");
2859 return "COMMENT_LESS_THAN_SIGN_BANG";
2860 }
2861 if (cp !== LESS_THAN_SIGN) {
2862 return this.reconsumeAs("COMMENT");
2863 }
2864 this.appendTokenValue(cp, "HTMLComment");
2865 cp = this.consumeNextCodePoint();
2866 }
2867 }
2868 COMMENT_LESS_THAN_SIGN_BANG(cp) {
2869 if (cp === HYPHEN_MINUS) {
2870 return "COMMENT_LESS_THAN_SIGN_BANG_DASH";
2871 }
2872 return this.reconsumeAs("COMMENT");
2873 }
2874 COMMENT_LESS_THAN_SIGN_BANG_DASH(cp) {
2875 if (cp === HYPHEN_MINUS) {
2876 return "COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH";
2877 }
2878 return this.reconsumeAs("COMMENT_END_DASH");
2879 }
2880 COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH(cp) {
2881 if (cp !== GREATER_THAN_SIGN && cp !== EOF) {
2882 this.reportParseError("nested-comment");
2883 }
2884 return this.reconsumeAs("COMMENT_END");
2885 }
2886 COMMENT_END_DASH(cp) {
2887 if (cp === HYPHEN_MINUS) {
2888 return "COMMENT_END";
2889 }
2890 if (cp === EOF) {
2891 this.reportParseError("eof-in-comment");
2892 return "DATA";
2893 }
2894 this.appendTokenValue(HYPHEN_MINUS, "HTMLComment");
2895 return this.reconsumeAs("COMMENT");
2896 }
2897 COMMENT_END(cp) {
2898 while (true) {
2899 if (cp === GREATER_THAN_SIGN) {
2900 return "DATA";
2901 }
2902 if (cp === EXCLAMATION_MARK) {
2903 return "COMMENT_END_BANG";
2904 }
2905 if (cp === EOF) {
2906 this.reportParseError("eof-in-comment");
2907 return "DATA";
2908 }
2909 this.appendTokenValue(HYPHEN_MINUS, "HTMLComment");
2910 if (cp !== HYPHEN_MINUS) {
2911 return this.reconsumeAs("COMMENT");
2912 }
2913 cp = this.consumeNextCodePoint();
2914 }
2915 }
2916 COMMENT_END_BANG(cp) {
2917 if (cp === HYPHEN_MINUS) {
2918 this.appendTokenValue(HYPHEN_MINUS, "HTMLComment");
2919 this.appendTokenValue(EXCLAMATION_MARK, "HTMLComment");
2920 return "COMMENT_END_DASH";
2921 }
2922 if (cp === GREATER_THAN_SIGN) {
2923 this.reportParseError("incorrectly-closed-comment");
2924 return "DATA";
2925 }
2926 if (cp === EOF) {
2927 this.reportParseError("eof-in-comment");
2928 return "DATA";
2929 }
2930 this.appendTokenValue(HYPHEN_MINUS, "HTMLComment");
2931 this.appendTokenValue(EXCLAMATION_MARK, "HTMLComment");
2932 return this.reconsumeAs("COMMENT");
2933 }
2934 CDATA_SECTION(cp) {
2935 while (true) {
2936 if (cp === RIGHT_SQUARE_BRACKET) {
2937 return "CDATA_SECTION_BRACKET";
2938 }
2939 if (cp === EOF) {
2940 this.reportParseError("eof-in-cdata");
2941 return "DATA";
2942 }
2943 this.appendTokenValue(cp, "HTMLCDataText");
2944 cp = this.consumeNextCodePoint();
2945 }
2946 }
2947 CDATA_SECTION_BRACKET(cp) {
2948 if (cp === RIGHT_SQUARE_BRACKET) {
2949 return "CDATA_SECTION_END";
2950 }
2951 this.appendTokenValue(RIGHT_SQUARE_BRACKET, "HTMLCDataText");
2952 return this.reconsumeAs("CDATA_SECTION");
2953 }
2954 CDATA_SECTION_END(cp) {
2955 while (true) {
2956 if (cp === GREATER_THAN_SIGN) {
2957 return "DATA";
2958 }
2959 if (cp !== RIGHT_SQUARE_BRACKET) {
2960 this.appendTokenValue(RIGHT_SQUARE_BRACKET, "HTMLCDataText");
2961 this.appendTokenValue(RIGHT_SQUARE_BRACKET, "HTMLCDataText");
2962 return this.reconsumeAs("CDATA_SECTION");
2963 }
2964 this.appendTokenValue(RIGHT_SQUARE_BRACKET, "HTMLCDataText");
2965 cp = this.consumeNextCodePoint();
2966 }
2967 }
2968 CHARACTER_REFERENCE(cp) {
2969 this.crStartOffset = this.offset - 1;
2970 this.buffer = [AMPERSAND];
2971 if (isWhitespace(cp) || cp === LESS_THAN_SIGN || cp === EOF) {
2972 return this.reconsumeAs("CHARACTER_REFERENCE_END");
2973 }
2974 if (cp === NUMBER_SIGN) {
2975 this.buffer.push(cp);
2976 return "NUMERIC_CHARACTER_REFERENCE";
2977 }
2978 return this.reconsumeAs("NAMED_CHARACTER_REFERENCE");
2979 }
2980 NAMED_CHARACTER_REFERENCE(cp) {
2981 for (const entitySet of entitySets) {
2982 const length = entitySet.length;
2983 const entities = entitySet.entities;
2984 const text = this.text.slice(this.offset, this.offset + length);
2985 const codepoints = entities[text];
2986 if (codepoints == null) {
2987 continue;
2988 }
2989 const semi = text.endsWith(";");
2990 const next = this.text.codePointAt(this.offset + 1);
2991 this.offset += length - 1;
2992 this.column += length - 1;
2993 if (this.returnState.startsWith("ATTR") &&
2994 !semi &&
2995 next != null &&
2996 (next === EQUALS_SIGN || isLetter(next) || isDigit(next))) {
2997 for (const cp1 of text) {
2998 this.buffer.push(cp1.codePointAt(0));
2999 }
3000 }
3001 else {
3002 if (!semi) {
3003 this.reportParseError("missing-semicolon-after-character-reference");
3004 }
3005 this.buffer = codepoints;
3006 }
3007 return "CHARACTER_REFERENCE_END";
3008 }
3009 for (const cp0 of this.buffer) {
3010 this.appendTokenValue(cp0, null);
3011 }
3012 this.appendTokenValue(cp, null);
3013 return "AMBIGUOUS_AMPERSAND";
3014 }
3015 AMBIGUOUS_AMPERSAND(cp) {
3016 while (isDigit(cp) || isLetter(cp)) {
3017 this.appendTokenValue(cp, null);
3018 cp = this.consumeNextCodePoint();
3019 }
3020 if (cp === SEMICOLON) {
3021 this.reportParseError("unknown-named-character-reference");
3022 }
3023 return this.reconsumeAs(this.returnState);
3024 }
3025 NUMERIC_CHARACTER_REFERENCE(cp) {
3026 this.crCode = 0;
3027 if (cp === LATIN_SMALL_X || cp === LATIN_CAPITAL_X) {
3028 this.buffer.push(cp);
3029 return "HEXADEMICAL_CHARACTER_REFERENCE_START";
3030 }
3031 return this.reconsumeAs("DECIMAL_CHARACTER_REFERENCE_START");
3032 }
3033 HEXADEMICAL_CHARACTER_REFERENCE_START(cp) {
3034 if (isHexDigit(cp)) {
3035 return this.reconsumeAs("HEXADEMICAL_CHARACTER_REFERENCE");
3036 }
3037 this.reportParseError("absence-of-digits-in-numeric-character-reference");
3038 return this.reconsumeAs("CHARACTER_REFERENCE_END");
3039 }
3040 DECIMAL_CHARACTER_REFERENCE_START(cp) {
3041 if (isDigit(cp)) {
3042 return this.reconsumeAs("DECIMAL_CHARACTER_REFERENCE");
3043 }
3044 this.reportParseError("absence-of-digits-in-numeric-character-reference");
3045 return this.reconsumeAs("CHARACTER_REFERENCE_END");
3046 }
3047 HEXADEMICAL_CHARACTER_REFERENCE(cp) {
3048 while (true) {
3049 if (isDigit(cp)) {
3050 this.crCode = 16 * this.crCode + (cp - 0x30);
3051 }
3052 else if (isUpperHexDigit(cp)) {
3053 this.crCode = 16 * this.crCode + (cp - 0x37);
3054 }
3055 else if (isLowerHexDigit(cp)) {
3056 this.crCode = 16 * this.crCode + (cp - 0x57);
3057 }
3058 else {
3059 if (cp === SEMICOLON) {
3060 return "NUMERIC_CHARACTER_REFERENCE_END";
3061 }
3062 this.reportParseError("missing-semicolon-after-character-reference");
3063 return this.reconsumeAs("NUMERIC_CHARACTER_REFERENCE_END");
3064 }
3065 cp = this.consumeNextCodePoint();
3066 }
3067 }
3068 DECIMAL_CHARACTER_REFERENCE(cp) {
3069 while (true) {
3070 if (isDigit(cp)) {
3071 this.crCode = 10 * this.crCode + (cp - 0x30);
3072 }
3073 else {
3074 if (cp === SEMICOLON) {
3075 return "NUMERIC_CHARACTER_REFERENCE_END";
3076 }
3077 this.reportParseError("missing-semicolon-after-character-reference");
3078 return this.reconsumeAs("NUMERIC_CHARACTER_REFERENCE_END");
3079 }
3080 cp = this.consumeNextCodePoint();
3081 }
3082 }
3083 NUMERIC_CHARACTER_REFERENCE_END(_cp) {
3084 let code = this.crCode;
3085 if (code === 0) {
3086 this.reportParseError("null-character-reference");
3087 code = NULL_REPLACEMENT;
3088 }
3089 else if (code > 0x10ffff) {
3090 this.reportParseError("character-reference-outside-unicode-range");
3091 code = NULL_REPLACEMENT;
3092 }
3093 else if (isSurrogate(code)) {
3094 this.reportParseError("surrogate-character-reference");
3095 code = NULL_REPLACEMENT;
3096 }
3097 else if (isNonCharacter(code)) {
3098 this.reportParseError("noncharacter-character-reference");
3099 }
3100 else if (code === 0x0d || (isControl(code) && !isWhitespace(code))) {
3101 this.reportParseError("control-character-reference");
3102 code = alternativeCR.get(code) || code;
3103 }
3104 this.buffer = [code];
3105 return this.reconsumeAs("CHARACTER_REFERENCE_END");
3106 }
3107 CHARACTER_REFERENCE_END(_cp) {
3108 assert(this.currentToken != null);
3109 const token = this.currentToken;
3110 const len0 = token.value.length;
3111 for (const cp1 of this.buffer) {
3112 this.appendTokenValue(cp1, null);
3113 }
3114 const newLength = token.value.length - len0;
3115 for (let i = this.crStartOffset + newLength; i < this.offset; ++i) {
3116 this.gaps.push(i);
3117 }
3118 return this.reconsumeAs(this.returnState);
3119 }
3120 V_EXPRESSION_START(cp) {
3121 if (cp === LEFT_CURLY_BRACKET) {
3122 this.startToken("VExpressionStart");
3123 this.appendTokenValue(LEFT_CURLY_BRACKET, null);
3124 this.appendTokenValue(LEFT_CURLY_BRACKET, null);
3125 return this.returnState;
3126 }
3127 this.appendTokenValue(LEFT_CURLY_BRACKET, null);
3128 return this.reconsumeAs(this.returnState);
3129 }
3130 V_EXPRESSION_END(cp) {
3131 if (cp === RIGHT_CURLY_BRACKET) {
3132 this.startToken("VExpressionEnd");
3133 this.appendTokenValue(RIGHT_CURLY_BRACKET, null);
3134 this.appendTokenValue(RIGHT_CURLY_BRACKET, null);
3135 return this.returnState;
3136 }
3137 this.appendTokenValue(RIGHT_CURLY_BRACKET, null);
3138 return this.reconsumeAs(this.returnState);
3139 }
3140}
3141
3142function getPossibleTypes(parsedSelector) {
3143 switch (parsedSelector.type) {
3144 case "identifier":
3145 return [parsedSelector.value];
3146 case "matches": {
3147 const typesForComponents = parsedSelector.selectors.map(getPossibleTypes);
3148 if (typesForComponents.every(Boolean)) {
3149 return union(...typesForComponents);
3150 }
3151 return null;
3152 }
3153 case "compound": {
3154 const typesForComponents = parsedSelector.selectors.map(getPossibleTypes).filter(Boolean);
3155 if (!typesForComponents.length) {
3156 return null;
3157 }
3158 return intersection(...typesForComponents);
3159 }
3160 case "child":
3161 case "descendant":
3162 case "sibling":
3163 case "adjacent":
3164 return getPossibleTypes(parsedSelector.right);
3165 default:
3166 return null;
3167 }
3168}
3169function countClassAttributes(parsedSelector) {
3170 switch (parsedSelector.type) {
3171 case "child":
3172 case "descendant":
3173 case "sibling":
3174 case "adjacent":
3175 return countClassAttributes(parsedSelector.left) + countClassAttributes(parsedSelector.right);
3176 case "compound":
3177 case "not":
3178 case "matches":
3179 return parsedSelector.selectors.reduce((sum, childSelector) => sum + countClassAttributes(childSelector), 0);
3180 case "attribute":
3181 case "field":
3182 case "nth-child":
3183 case "nth-last-child":
3184 return 1;
3185 default:
3186 return 0;
3187 }
3188}
3189function countIdentifiers(parsedSelector) {
3190 switch (parsedSelector.type) {
3191 case "child":
3192 case "descendant":
3193 case "sibling":
3194 case "adjacent":
3195 return countIdentifiers(parsedSelector.left) + countIdentifiers(parsedSelector.right);
3196 case "compound":
3197 case "not":
3198 case "matches":
3199 return parsedSelector.selectors.reduce((sum, childSelector) => sum + countIdentifiers(childSelector), 0);
3200 case "identifier":
3201 return 1;
3202 default:
3203 return 0;
3204 }
3205}
3206function compareSpecificity(selectorA, selectorB) {
3207 return selectorA.attributeCount - selectorB.attributeCount ||
3208 selectorA.identifierCount - selectorB.identifierCount ||
3209 (selectorA.rawSelector <= selectorB.rawSelector ? -1 : 1);
3210}
3211function tryParseSelector(rawSelector) {
3212 try {
3213 return esquery.parse(rawSelector.replace(/:exit$/, ""));
3214 }
3215 catch (err) {
3216 if (typeof err.offset === "number") {
3217 throw new Error(`Syntax error in selector "${rawSelector}" at position ${err.offset}: ${err.message}`);
3218 }
3219 throw err;
3220 }
3221}
3222const parseSelector = memoize(rawSelector => {
3223 const parsedSelector = tryParseSelector(rawSelector);
3224 return {
3225 rawSelector,
3226 isExit: rawSelector.endsWith(":exit"),
3227 parsedSelector,
3228 listenerTypes: getPossibleTypes(parsedSelector),
3229 attributeCount: countClassAttributes(parsedSelector),
3230 identifierCount: countIdentifiers(parsedSelector),
3231 };
3232});
3233class NodeEventGenerator {
3234 constructor(emitter) {
3235 this.emitter = emitter;
3236 this.currentAncestry = [];
3237 this.enterSelectorsByNodeType = new Map();
3238 this.exitSelectorsByNodeType = new Map();
3239 this.anyTypeEnterSelectors = [];
3240 this.anyTypeExitSelectors = [];
3241 const eventNames = typeof emitter.eventNames === "function"
3242 ? emitter.eventNames()
3243 : Object.keys(emitter._events);
3244 for (const rawSelector of eventNames) {
3245 if (typeof rawSelector === "symbol") {
3246 continue;
3247 }
3248 const selector = parseSelector(rawSelector);
3249 if (selector.listenerTypes) {
3250 for (const nodeType of selector.listenerTypes) {
3251 const typeMap = selector.isExit ? this.exitSelectorsByNodeType : this.enterSelectorsByNodeType;
3252 let selectors = typeMap.get(nodeType);
3253 if (selectors == null) {
3254 typeMap.set(nodeType, (selectors = []));
3255 }
3256 selectors.push(selector);
3257 }
3258 }
3259 else {
3260 (selector.isExit ? this.anyTypeExitSelectors : this.anyTypeEnterSelectors).push(selector);
3261 }
3262 }
3263 this.anyTypeEnterSelectors.sort(compareSpecificity);
3264 this.anyTypeExitSelectors.sort(compareSpecificity);
3265 for (const selectorList of this.enterSelectorsByNodeType.values()) {
3266 selectorList.sort(compareSpecificity);
3267 }
3268 for (const selectorList of this.exitSelectorsByNodeType.values()) {
3269 selectorList.sort(compareSpecificity);
3270 }
3271 }
3272 applySelector(node, selector) {
3273 if (esquery.matches(node, selector.parsedSelector, this.currentAncestry)) {
3274 this.emitter.emit(selector.rawSelector, node);
3275 }
3276 }
3277 applySelectors(node, isExit) {
3278 const selectorsByNodeType = (isExit ? this.exitSelectorsByNodeType : this.enterSelectorsByNodeType).get(node.type) || [];
3279 const anyTypeSelectors = isExit ? this.anyTypeExitSelectors : this.anyTypeEnterSelectors;
3280 let selectorsByTypeIndex = 0;
3281 let anyTypeSelectorsIndex = 0;
3282 while (selectorsByTypeIndex < selectorsByNodeType.length || anyTypeSelectorsIndex < anyTypeSelectors.length) {
3283 if (selectorsByTypeIndex >= selectorsByNodeType.length ||
3284 (anyTypeSelectorsIndex < anyTypeSelectors.length && compareSpecificity(anyTypeSelectors[anyTypeSelectorsIndex], selectorsByNodeType[selectorsByTypeIndex]) < 0)) {
3285 this.applySelector(node, anyTypeSelectors[anyTypeSelectorsIndex++]);
3286 }
3287 else {
3288 this.applySelector(node, selectorsByNodeType[selectorsByTypeIndex++]);
3289 }
3290 }
3291 }
3292 enterNode(node) {
3293 if (node.parent) {
3294 this.currentAncestry.unshift(node.parent);
3295 }
3296 this.applySelectors(node, false);
3297 }
3298 leaveNode(node) {
3299 this.applySelectors(node, true);
3300 this.currentAncestry.shift();
3301 }
3302}
3303
3304function getStartLocation(token) {
3305 return token.range[0];
3306}
3307function search(tokens, location) {
3308 return sortedIndexBy(tokens, { range: [location] }, getStartLocation);
3309}
3310function getFirstIndex(tokens, indexMap, startLoc) {
3311 if (startLoc in indexMap) {
3312 return indexMap[startLoc];
3313 }
3314 if ((startLoc - 1) in indexMap) {
3315 const index = indexMap[startLoc - 1];
3316 const token = (index >= 0 && index < tokens.length) ? tokens[index] : null;
3317 if (token && token.range[0] >= startLoc) {
3318 return index;
3319 }
3320 return index + 1;
3321 }
3322 return 0;
3323}
3324function getLastIndex(tokens, indexMap, endLoc) {
3325 if (endLoc in indexMap) {
3326 return indexMap[endLoc] - 1;
3327 }
3328 if ((endLoc - 1) in indexMap) {
3329 const index = indexMap[endLoc - 1];
3330 const token = (index >= 0 && index < tokens.length) ? tokens[index] : null;
3331 if (token && token.range[1] > endLoc) {
3332 return index - 1;
3333 }
3334 return index;
3335 }
3336 return tokens.length - 1;
3337}
3338
3339class Cursor {
3340 constructor() {
3341 this.current = null;
3342 }
3343 getOneToken() {
3344 return this.moveNext() ? this.current : null;
3345 }
3346 getAllTokens() {
3347 const tokens = [];
3348 while (this.moveNext()) {
3349 tokens.push(this.current);
3350 }
3351 return tokens;
3352 }
3353}
3354
3355class BackwardTokenCommentCursor extends Cursor {
3356 constructor(tokens, comments, indexMap, startLoc, endLoc) {
3357 super();
3358 this.tokens = tokens;
3359 this.comments = comments;
3360 this.tokenIndex = getLastIndex(tokens, indexMap, endLoc);
3361 this.commentIndex = search(comments, endLoc) - 1;
3362 this.border = startLoc;
3363 }
3364 moveNext() {
3365 const token = (this.tokenIndex >= 0) ? this.tokens[this.tokenIndex] : null;
3366 const comment = (this.commentIndex >= 0) ? this.comments[this.commentIndex] : null;
3367 if (token && (!comment || token.range[1] > comment.range[1])) {
3368 this.current = token;
3369 this.tokenIndex -= 1;
3370 }
3371 else if (comment) {
3372 this.current = comment;
3373 this.commentIndex -= 1;
3374 }
3375 else {
3376 this.current = null;
3377 }
3378 return this.current != null && (this.border === -1 || this.current.range[0] >= this.border);
3379 }
3380}
3381
3382class BackwardTokenCursor extends Cursor {
3383 constructor(tokens, _comments, indexMap, startLoc, endLoc) {
3384 super();
3385 this.tokens = tokens;
3386 this.index = getLastIndex(tokens, indexMap, endLoc);
3387 this.indexEnd = getFirstIndex(tokens, indexMap, startLoc);
3388 }
3389 moveNext() {
3390 if (this.index >= this.indexEnd) {
3391 this.current = this.tokens[this.index];
3392 this.index -= 1;
3393 return true;
3394 }
3395 return false;
3396 }
3397 getOneToken() {
3398 return (this.index >= this.indexEnd) ? this.tokens[this.index] : null;
3399 }
3400}
3401
3402class DecorativeCursor extends Cursor {
3403 constructor(cursor) {
3404 super();
3405 this.cursor = cursor;
3406 }
3407 moveNext() {
3408 const retv = this.cursor.moveNext();
3409 this.current = this.cursor.current;
3410 return retv;
3411 }
3412}
3413
3414class FilterCursor extends DecorativeCursor {
3415 constructor(cursor, predicate) {
3416 super(cursor);
3417 this.predicate = predicate;
3418 }
3419 moveNext() {
3420 const predicate = this.predicate;
3421 while (super.moveNext()) {
3422 if (predicate(this.current)) {
3423 return true;
3424 }
3425 }
3426 return false;
3427 }
3428}
3429
3430class ForwardTokenCommentCursor extends Cursor {
3431 constructor(tokens, comments, indexMap, startLoc, endLoc) {
3432 super();
3433 this.tokens = tokens;
3434 this.comments = comments;
3435 this.tokenIndex = getFirstIndex(tokens, indexMap, startLoc);
3436 this.commentIndex = search(comments, startLoc);
3437 this.border = endLoc;
3438 }
3439 moveNext() {
3440 const token = (this.tokenIndex < this.tokens.length) ? this.tokens[this.tokenIndex] : null;
3441 const comment = (this.commentIndex < this.comments.length) ? this.comments[this.commentIndex] : null;
3442 if (token && (!comment || token.range[0] < comment.range[0])) {
3443 this.current = token;
3444 this.tokenIndex += 1;
3445 }
3446 else if (comment) {
3447 this.current = comment;
3448 this.commentIndex += 1;
3449 }
3450 else {
3451 this.current = null;
3452 }
3453 return this.current != null && (this.border === -1 || this.current.range[1] <= this.border);
3454 }
3455}
3456
3457class ForwardTokenCursor extends Cursor {
3458 constructor(tokens, _comments, indexMap, startLoc, endLoc) {
3459 super();
3460 this.tokens = tokens;
3461 this.index = getFirstIndex(tokens, indexMap, startLoc);
3462 this.indexEnd = getLastIndex(tokens, indexMap, endLoc);
3463 }
3464 moveNext() {
3465 if (this.index <= this.indexEnd) {
3466 this.current = this.tokens[this.index];
3467 this.index += 1;
3468 return true;
3469 }
3470 return false;
3471 }
3472 getOneToken() {
3473 return (this.index <= this.indexEnd) ? this.tokens[this.index] : null;
3474 }
3475 getAllTokens() {
3476 return this.tokens.slice(this.index, this.indexEnd + 1);
3477 }
3478}
3479
3480class LimitCursor extends DecorativeCursor {
3481 constructor(cursor, count) {
3482 super(cursor);
3483 this.count = count;
3484 }
3485 moveNext() {
3486 if (this.count > 0) {
3487 this.count -= 1;
3488 return super.moveNext();
3489 }
3490 return false;
3491 }
3492}
3493
3494class SkipCursor extends DecorativeCursor {
3495 constructor(cursor, count) {
3496 super(cursor);
3497 this.count = count;
3498 }
3499 moveNext() {
3500 while (this.count > 0) {
3501 this.count -= 1;
3502 if (!super.moveNext()) {
3503 return false;
3504 }
3505 }
3506 return super.moveNext();
3507 }
3508}
3509
3510class CursorFactory {
3511 constructor(TokenCursor, TokenCommentCursor) {
3512 this.TokenCursor = TokenCursor;
3513 this.TokenCommentCursor = TokenCommentCursor;
3514 }
3515 createBaseCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments) {
3516 const TokenCursor = includeComments ? this.TokenCommentCursor : this.TokenCursor;
3517 return new TokenCursor(tokens, comments, indexMap, startLoc, endLoc);
3518 }
3519 createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, skip, count) {
3520 let cursor = this.createBaseCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments);
3521 if (filter) {
3522 cursor = new FilterCursor(cursor, filter);
3523 }
3524 if (skip >= 1) {
3525 cursor = new SkipCursor(cursor, skip);
3526 }
3527 if (count >= 0) {
3528 cursor = new LimitCursor(cursor, count);
3529 }
3530 return cursor;
3531 }
3532}
3533const forward = new CursorFactory(ForwardTokenCursor, ForwardTokenCommentCursor);
3534const backward = new CursorFactory(BackwardTokenCursor, BackwardTokenCommentCursor);
3535
3536class PaddedTokenCursor extends ForwardTokenCursor {
3537 constructor(tokens, comments, indexMap, startLoc, endLoc, beforeCount, afterCount) {
3538 super(tokens, comments, indexMap, startLoc, endLoc);
3539 this.index = Math.max(0, this.index - beforeCount);
3540 this.indexEnd = Math.min(tokens.length - 1, this.indexEnd + afterCount);
3541 }
3542}
3543
3544function isCommentToken(token) {
3545 return token.type === "Line" || token.type === "Block" || token.type === "Shebang";
3546}
3547function createIndexMap(tokens, comments) {
3548 const map = Object.create(null);
3549 let tokenIndex = 0;
3550 let commentIndex = 0;
3551 let nextStart = 0;
3552 let range = null;
3553 while (tokenIndex < tokens.length || commentIndex < comments.length) {
3554 nextStart = (commentIndex < comments.length) ? comments[commentIndex].range[0] : Number.MAX_SAFE_INTEGER;
3555 while (tokenIndex < tokens.length && (range = tokens[tokenIndex].range)[0] < nextStart) {
3556 map[range[0]] = tokenIndex;
3557 map[range[1] - 1] = tokenIndex;
3558 tokenIndex += 1;
3559 }
3560 nextStart = (tokenIndex < tokens.length) ? tokens[tokenIndex].range[0] : Number.MAX_SAFE_INTEGER;
3561 while (commentIndex < comments.length && (range = comments[commentIndex].range)[0] < nextStart) {
3562 map[range[0]] = tokenIndex;
3563 map[range[1] - 1] = tokenIndex;
3564 commentIndex += 1;
3565 }
3566 }
3567 return map;
3568}
3569function createCursorWithSkip(factory, tokens, comments, indexMap, startLoc, endLoc, opts) {
3570 let includeComments = false;
3571 let skip = 0;
3572 let filter = null;
3573 if (typeof opts === "number") {
3574 skip = opts | 0;
3575 }
3576 else if (typeof opts === "function") {
3577 filter = opts;
3578 }
3579 else if (opts) {
3580 includeComments = Boolean(opts.includeComments);
3581 skip = opts.skip || 0;
3582 filter = opts.filter || null;
3583 }
3584 assert(skip >= 0, "options.skip should be zero or a positive integer.");
3585 assert(!filter || typeof filter === "function", "options.filter should be a function.");
3586 return factory.createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, skip, -1);
3587}
3588function createCursorWithCount(factory, tokens, comments, indexMap, startLoc, endLoc, opts) {
3589 let includeComments = false;
3590 let count = 0;
3591 let countExists = false;
3592 let filter = null;
3593 if (typeof opts === "number") {
3594 count = opts | 0;
3595 countExists = true;
3596 }
3597 else if (typeof opts === "function") {
3598 filter = opts;
3599 }
3600 else if (opts) {
3601 includeComments = Boolean(opts.includeComments);
3602 count = opts.count || 0;
3603 countExists = typeof opts.count === "number";
3604 filter = opts.filter || null;
3605 }
3606 assert(count >= 0, "options.count should be zero or a positive integer.");
3607 assert(!filter || typeof filter === "function", "options.filter should be a function.");
3608 return factory.createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, 0, countExists ? count : -1);
3609}
3610function createCursorWithPadding(tokens, comments, indexMap, startLoc, endLoc, beforeCount, afterCount) {
3611 if (typeof beforeCount === "undefined" && typeof afterCount === "undefined") {
3612 return new ForwardTokenCursor(tokens, comments, indexMap, startLoc, endLoc);
3613 }
3614 if (typeof beforeCount === "number" || typeof beforeCount === "undefined") {
3615 return new PaddedTokenCursor(tokens, comments, indexMap, startLoc, endLoc, beforeCount || 0, afterCount || 0);
3616 }
3617 return createCursorWithCount(forward, tokens, comments, indexMap, startLoc, endLoc, beforeCount);
3618}
3619function getAdjacentCommentTokensFromCursor(cursor) {
3620 const tokens = [];
3621 let currentToken = cursor.getOneToken();
3622 while (currentToken && isCommentToken(currentToken)) {
3623 tokens.push(currentToken);
3624 currentToken = cursor.getOneToken();
3625 }
3626 return tokens;
3627}
3628class TokenStore {
3629 constructor(tokens, comments) {
3630 this._tokens = tokens;
3631 this._comments = comments;
3632 this._indexMap = createIndexMap(tokens, comments);
3633 }
3634 getTokenByRangeStart(offset, options) {
3635 const includeComments = Boolean(options && options.includeComments);
3636 const token = forward.createBaseCursor(this._tokens, this._comments, this._indexMap, offset, -1, includeComments).getOneToken();
3637 if (token && token.range[0] === offset) {
3638 return token;
3639 }
3640 return null;
3641 }
3642 getFirstToken(node, options) {
3643 return createCursorWithSkip(forward, this._tokens, this._comments, this._indexMap, node.range[0], node.range[1], options).getOneToken();
3644 }
3645 getLastToken(node, options) {
3646 return createCursorWithSkip(backward, this._tokens, this._comments, this._indexMap, node.range[0], node.range[1], options).getOneToken();
3647 }
3648 getTokenBefore(node, options) {
3649 return createCursorWithSkip(backward, this._tokens, this._comments, this._indexMap, -1, node.range[0], options).getOneToken();
3650 }
3651 getTokenAfter(node, options) {
3652 return createCursorWithSkip(forward, this._tokens, this._comments, this._indexMap, node.range[1], -1, options).getOneToken();
3653 }
3654 getFirstTokenBetween(left, right, options) {
3655 return createCursorWithSkip(forward, this._tokens, this._comments, this._indexMap, left.range[1], right.range[0], options).getOneToken();
3656 }
3657 getLastTokenBetween(left, right, options) {
3658 return createCursorWithSkip(backward, this._tokens, this._comments, this._indexMap, left.range[1], right.range[0], options).getOneToken();
3659 }
3660 getTokenOrCommentBefore(node, skip) {
3661 return this.getTokenBefore(node, { includeComments: true, skip });
3662 }
3663 getTokenOrCommentAfter(node, skip) {
3664 return this.getTokenAfter(node, { includeComments: true, skip });
3665 }
3666 getFirstTokens(node, options) {
3667 return createCursorWithCount(forward, this._tokens, this._comments, this._indexMap, node.range[0], node.range[1], options).getAllTokens();
3668 }
3669 getLastTokens(node, options) {
3670 return createCursorWithCount(backward, this._tokens, this._comments, this._indexMap, node.range[0], node.range[1], options).getAllTokens().reverse();
3671 }
3672 getTokensBefore(node, options) {
3673 return createCursorWithCount(backward, this._tokens, this._comments, this._indexMap, -1, node.range[0], options).getAllTokens().reverse();
3674 }
3675 getTokensAfter(node, options) {
3676 return createCursorWithCount(forward, this._tokens, this._comments, this._indexMap, node.range[1], -1, options).getAllTokens();
3677 }
3678 getFirstTokensBetween(left, right, options) {
3679 return createCursorWithCount(forward, this._tokens, this._comments, this._indexMap, left.range[1], right.range[0], options).getAllTokens();
3680 }
3681 getLastTokensBetween(left, right, options) {
3682 return createCursorWithCount(backward, this._tokens, this._comments, this._indexMap, left.range[1], right.range[0], options).getAllTokens().reverse();
3683 }
3684 getTokens(node, beforeCount, afterCount) {
3685 return createCursorWithPadding(this._tokens, this._comments, this._indexMap, node.range[0], node.range[1], beforeCount, afterCount).getAllTokens();
3686 }
3687 getTokensBetween(left, right, padding) {
3688 return createCursorWithPadding(this._tokens, this._comments, this._indexMap, left.range[1], right.range[0], padding, typeof padding === "number" ? padding : undefined).getAllTokens();
3689 }
3690 commentsExistBetween(left, right) {
3691 const index = search(this._comments, left.range[1]);
3692 return (index < this._comments.length &&
3693 this._comments[index].range[1] <= right.range[0]);
3694 }
3695 getCommentsBefore(nodeOrToken) {
3696 const cursor = createCursorWithCount(backward, this._tokens, this._comments, this._indexMap, -1, nodeOrToken.range[0], { includeComments: true });
3697 return getAdjacentCommentTokensFromCursor(cursor).reverse();
3698 }
3699 getCommentsAfter(nodeOrToken) {
3700 const cursor = createCursorWithCount(forward, this._tokens, this._comments, this._indexMap, nodeOrToken.range[1], -1, { includeComments: true });
3701 return getAdjacentCommentTokensFromCursor(cursor);
3702 }
3703 getCommentsInside(node) {
3704 return this.getTokens(node, {
3705 includeComments: true,
3706 filter: isCommentToken,
3707 });
3708 }
3709}
3710
3711const emitters = new WeakMap();
3712const stores = new WeakMap();
3713function define(rootAST) {
3714 return {
3715 defineTemplateBodyVisitor(templateBodyVisitor, scriptVisitor) {
3716 if (scriptVisitor == null) {
3717 scriptVisitor = {};
3718 }
3719 if (rootAST.templateBody == null) {
3720 return scriptVisitor;
3721 }
3722 let emitter = emitters.get(rootAST);
3723 if (emitter == null) {
3724 emitter = new EventEmitter();
3725 emitter.setMaxListeners(0);
3726 emitters.set(rootAST, emitter);
3727 const programExitHandler = scriptVisitor["Program:exit"];
3728 scriptVisitor["Program:exit"] = node => {
3729 try {
3730 if (typeof programExitHandler === "function") {
3731 programExitHandler(node);
3732 }
3733 const generator = new NodeEventGenerator(emitter);
3734 traverseNodes(rootAST.templateBody, generator);
3735 }
3736 finally {
3737 scriptVisitor["Program:exit"] = programExitHandler;
3738 emitters.delete(rootAST);
3739 }
3740 };
3741 }
3742 for (const selector of Object.keys(templateBodyVisitor)) {
3743 emitter.on(selector, templateBodyVisitor[selector]);
3744 }
3745 return scriptVisitor;
3746 },
3747 getTemplateBodyTokenStore() {
3748 const ast = rootAST.templateBody;
3749 const key = ast || stores;
3750 let store = stores.get(key);
3751 if (!store) {
3752 store =
3753 ast != null
3754 ? new TokenStore(ast.tokens, ast.comments)
3755 : new TokenStore([], []);
3756 stores.set(key, store);
3757 }
3758 return store;
3759 },
3760 };
3761}
3762
3763const STARTS_WITH_LT = /^\s*</u;
3764function isVueFile(code, options) {
3765 const filePath = options.filePath || "unknown.js";
3766 return path.extname(filePath) === ".vue" || STARTS_WITH_LT.test(code);
3767}
3768function isTemplateElement(node) {
3769 return node.type === "VElement" && node.name === "template";
3770}
3771function isScriptElement(node) {
3772 return node.type === "VElement" && node.name === "script";
3773}
3774function isLang(attribute) {
3775 return attribute.directive === false && attribute.key.name === "lang";
3776}
3777function getLang(element, defaultLang) {
3778 const langAttr = element && element.startTag.attributes.find(isLang);
3779 const lang = langAttr && langAttr.value && langAttr.value.value;
3780 return lang || defaultLang;
3781}
3782function parseForESLint(code, options) {
3783 options = Object.assign({
3784 comment: true,
3785 ecmaVersion: 2015,
3786 loc: true,
3787 range: true,
3788 tokens: true,
3789 }, options || {});
3790 let result;
3791 if (!isVueFile(code, options)) {
3792 result = parseScript(code, options);
3793 }
3794 else {
3795 const skipParsingScript = options.parser === false;
3796 const tokenizer = new Tokenizer(code);
3797 const rootAST = new Parser(tokenizer, options).parse();
3798 const locationCalcurator = new LocationCalculator(tokenizer.gaps, tokenizer.lineTerminators);
3799 const script = rootAST.children.find(isScriptElement);
3800 const template = rootAST.children.find(isTemplateElement);
3801 const templateLang = getLang(template, "html");
3802 const concreteInfo = {
3803 tokens: rootAST.tokens,
3804 comments: rootAST.comments,
3805 errors: rootAST.errors,
3806 };
3807 const templateBody = template != null && templateLang === "html"
3808 ? Object.assign(template, concreteInfo)
3809 : undefined;
3810 if (skipParsingScript || script == null) {
3811 result = parseScript("", options);
3812 }
3813 else {
3814 result = parseScriptElement(script, locationCalcurator, options);
3815 }
3816 result.ast.templateBody = templateBody;
3817 }
3818 result.services = Object.assign(result.services || {}, define(result.ast));
3819 return result;
3820}
3821function parse(code, options) {
3822 return parseForESLint(code, options).ast;
3823}
3824
3825exports.AST = index;
3826exports.parse = parse;
3827exports.parseForESLint = parseForESLint;
3828//# sourceMappingURL=index.js.map