package.dist.index.cjs Maven / Gradle / Ivy
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var lr = require('@lezer/lr');
var highlight = require('@lezer/highlight');
// This file was generated by lezer-generator. You probably shouldn't edit it.
const StartTag = 1,
StartCloseTag = 2,
MissingCloseTag = 3,
mismatchedStartCloseTag = 4,
incompleteStartCloseTag = 5,
commentContent$1 = 35,
piContent$1 = 36,
cdataContent$1 = 37,
Element = 11,
OpenTag = 13;
/* Hand-written tokenizer for XML tag matching. */
function nameChar(ch) {
return ch == 45 || ch == 46 || ch == 58 || ch >= 65 && ch <= 90 || ch == 95 || ch >= 97 && ch <= 122 || ch >= 161
}
function isSpace(ch) {
return ch == 9 || ch == 10 || ch == 13 || ch == 32
}
let cachedName = null, cachedInput = null, cachedPos = 0;
function tagNameAfter(input, offset) {
let pos = input.pos + offset;
if (cachedInput == input && cachedPos == pos) return cachedName
while (isSpace(input.peek(offset))) offset++;
let name = "";
for (;;) {
let next = input.peek(offset);
if (!nameChar(next)) break
name += String.fromCharCode(next);
offset++;
}
cachedInput = input; cachedPos = pos;
return cachedName = name || null
}
function ElementContext(name, parent) {
this.name = name;
this.parent = parent;
this.hash = parent ? parent.hash : 0;
for (let i = 0; i < name.length; i++) this.hash += (this.hash << 4) + name.charCodeAt(i) + (name.charCodeAt(i) << 8);
}
const elementContext = new lr.ContextTracker({
start: null,
shift(context, term, stack, input) {
return term == StartTag ? new ElementContext(tagNameAfter(input, 1) || "", context) : context
},
reduce(context, term) {
return term == Element && context ? context.parent : context
},
reuse(context, node, _stack, input) {
let type = node.type.id;
return type == StartTag || type == OpenTag
? new ElementContext(tagNameAfter(input, 1) || "", context) : context
},
hash(context) { return context ? context.hash : 0 },
strict: false
});
const startTag = new lr.ExternalTokenizer((input, stack) => {
if (input.next != 60 /* '<' */) return
input.advance();
if (input.next == 47 /* '/' */) {
input.advance();
let name = tagNameAfter(input, 0);
if (!name) return input.acceptToken(incompleteStartCloseTag)
if (stack.context && name == stack.context.name) return input.acceptToken(StartCloseTag)
for (let cx = stack.context; cx; cx = cx.parent) if (cx.name == name) return input.acceptToken(MissingCloseTag, -2)
input.acceptToken(mismatchedStartCloseTag);
} else if (input.next != 33 /* '!' */ && input.next != 63 /* '?' */) {
return input.acceptToken(StartTag)
}
}, {contextual: true});
function scanTo(type, end) {
return new lr.ExternalTokenizer(input => {
for (let endPos = 0, len = 0;; len++) {
if (input.next < 0) {
if (len) input.acceptToken(type);
break
}
if (input.next == end.charCodeAt(endPos)) {
endPos++;
if (endPos == end.length) {
if (len >= end.length) input.acceptToken(type, 1 - end.length);
break
}
} else {
endPos = input.next == end.charCodeAt(0) ? 1 : 0;
}
input.advance();
}
})
}
const commentContent = scanTo(commentContent$1, "-->");
const piContent = scanTo(piContent$1, "?>");
const cdataContent = scanTo(cdataContent$1, "]]>");
const xmlHighlighting = highlight.styleTags({
Text: highlight.tags.content,
"StartTag StartCloseTag EndTag SelfCloseEndTag": highlight.tags.angleBracket,
TagName: highlight.tags.tagName,
"MismatchedCloseTag/Tagname": [highlight.tags.tagName, highlight.tags.invalid],
AttributeName: highlight.tags.attributeName,
AttributeValue: highlight.tags.attributeValue,
Is: highlight.tags.definitionOperator,
"EntityReference CharacterReference": highlight.tags.character,
Comment: highlight.tags.blockComment,
ProcessingInst: highlight.tags.processingInstruction,
DoctypeDecl: highlight.tags.documentMeta,
Cdata: highlight.tags.special(highlight.tags.string)
});
// This file was generated by lezer-generator. You probably shouldn't edit it.
const parser = lr.LRParser.deserialize({
version: 14,
states: ",SOQOaOOOrOxO'#CfOzOpO'#CiO!tOaO'#CgOOOP'#Cg'#CgO!{OrO'#CrO#TOtO'#CsO#]OpO'#CtOOOP'#DS'#DSOOOP'#Cv'#CvQQOaOOOOOW'#Cw'#CwO#eOxO,59QOOOP,59Q,59QOOOO'#Cx'#CxO#mOpO,59TO#uO!bO,59TOOOP'#C{'#C{O$TOaO,59RO$[OpO'#CoOOOP,59R,59ROOOQ'#C|'#C|O$dOrO,59^OOOP,59^,59^OOOS'#C}'#C}O$lOtO,59_OOOP,59_,59_O$tOpO,59`O$|OpO,59`OOOP-E6t-E6tOOOW-E6u-E6uOOOP1G.l1G.lOOOO-E6v-E6vO%UO!bO1G.oO%UO!bO1G.oO%dOpO'#CkO%lO!bO'#CyO%zO!bO1G.oOOOP1G.o1G.oOOOP1G.w1G.wOOOP-E6y-E6yOOOP1G.m1G.mO&VOpO,59ZO&_OpO,59ZOOOQ-E6z-E6zOOOP1G.x1G.xOOOS-E6{-E6{OOOP1G.y1G.yO&gOpO1G.zO&gOpO1G.zOOOP1G.z1G.zO&oO!bO7+$ZO&}O!bO7+$ZOOOP7+$Z7+$ZOOOP7+$c7+$cO'YOpO,59VO'bOpO,59VO'jO!bO,59eOOOO-E6w-E6wO'xOpO1G.uO'xOpO1G.uOOOP1G.u1G.uO(QOpO7+$fOOOP7+$f7+$fO(YO!bO<`#X;'S%y;'S;=`&_<%lO%yX>eV{WOr%ysv%yw#T%y#T#U>z#U;'S%y;'S;=`&_<%lO%yX?PV{WOr%ysv%yw#h%y#h#i?f#i;'S%y;'S;=`&_<%lO%yX?kV{WOr%ysv%yw#T%y#T#U
© 2015 - 2024 Weber Informatics LLC | Privacy Policy