137 lines
7.7 KiB
JavaScript
137 lines
7.7 KiB
JavaScript
import { LRLanguage, LanguageSupport } from '@codemirror/language';
|
|
import { html } from '@codemirror/lang-html';
|
|
import { javascriptLanguage } from '@codemirror/lang-javascript';
|
|
import { styleTags, tags } from '@lezer/highlight';
|
|
import { parseMixed } from '@lezer/common';
|
|
import { ExternalTokenizer, LRParser } from '@lezer/lr';
|
|
|
|
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
|
const Text = 1,
|
|
attributeContentSingle = 33,
|
|
attributeContentDouble = 34,
|
|
scriptAttributeContentSingle = 35,
|
|
scriptAttributeContentDouble = 36;
|
|
|
|
const text = /*@__PURE__*/new ExternalTokenizer(input => {
|
|
let start = input.pos;
|
|
for (;;) {
|
|
if (input.next == 10 /* Ch.Newline */) {
|
|
input.advance();
|
|
break;
|
|
}
|
|
else if (input.next == 123 /* Ch.BraceL */ && input.peek(1) == 123 /* Ch.BraceL */ || input.next < 0) {
|
|
break;
|
|
}
|
|
input.advance();
|
|
}
|
|
if (input.pos > start)
|
|
input.acceptToken(Text);
|
|
});
|
|
function attrContent(quote, token, script) {
|
|
return new ExternalTokenizer(input => {
|
|
let start = input.pos;
|
|
while (input.next != quote && input.next >= 0 &&
|
|
(script || input.next != 38 /* Ch.Ampersand */ && (input.next != 123 /* Ch.BraceL */ || input.peek(1) != 123 /* Ch.BraceL */)))
|
|
input.advance();
|
|
if (input.pos > start)
|
|
input.acceptToken(token);
|
|
});
|
|
}
|
|
const attrSingle = /*@__PURE__*/attrContent(39 /* Ch.SingleQuote */, attributeContentSingle, false);
|
|
const attrDouble = /*@__PURE__*/attrContent(34 /* Ch.DoubleQuote */, attributeContentDouble, false);
|
|
const scriptAttrSingle = /*@__PURE__*/attrContent(39 /* Ch.SingleQuote */, scriptAttributeContentSingle, true);
|
|
const scriptAttrDouble = /*@__PURE__*/attrContent(34 /* Ch.DoubleQuote */, scriptAttributeContentDouble, true);
|
|
|
|
// This file was generated by lezer-generator. You probably shouldn't edit it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PRqfR[PRqgQSOR_SQj`SvjxRxlQ!PsR!W!PQ!StR!Y!SQpeRrf",
|
|
nodeNames: "⚠ Text Content }} {{ Interpolation InterpolationContent Entity InvalidEntity Attribute BoundAttributeName [ Identifier ] ( ) ReferenceName # Is ExpressionAttributeValue AttributeInterpolation AttributeInterpolation EventName DirectiveName * StatementAttributeValue AttributeName AttributeValue",
|
|
maxTerm: 42,
|
|
nodeProps: [
|
|
["openedBy", 3,"{{",15,"("],
|
|
["closedBy", 4,"}}",14,")"],
|
|
["isolate", -4,5,19,25,27,""]
|
|
],
|
|
skippedNodes: [0],
|
|
repeatNodeCount: 4,
|
|
tokenData: "0r~RyOX#rXY$mYZ$mZ]#r]^$m^p#rpq$mqr#rrs%jst&Qtv#rvw&hwx)zxy*byz*xz{+`{}#r}!O+v!O!P-]!P!Q#r!Q![+v![!]+v!]!_#r!_!`-s!`!c#r!c!}+v!}#O.Z#O#P#r#P#Q.q#Q#R#r#R#S+v#S#T#r#T#o+v#o#p/X#p#q#r#q#r0Z#r%W#r%W;'S+v;'S;:j-V;:j;=`$g<%lO+vQ#wTUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rQ$ZSO#q#r#r;'S#r;'S;=`$g<%lO#rQ$jP;=`<%l#rR$t[UQvPOX#rXY$mYZ$mZ]#r]^$m^p#rpq$mq#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR%qTyPUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR&XTaPUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR&oXUQWPOp'[pq#rq!]'[!]!^#r!^#q'[#q#r(d#r;'S'[;'S;=`)t<%lO'[R'aXUQOp'[pq#rq!]'[!]!^'|!^#q'[#q#r(d#r;'S'[;'S;=`)t<%lO'[R(TTVPUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR(gXOp'[pq#rq!]'[!]!^'|!^#q'[#q#r)S#r;'S'[;'S;=`)t<%lO'[P)VUOp)Sq!])S!]!^)i!^;'S)S;'S;=`)n<%lO)SP)nOVPP)qP;=`<%l)SR)wP;=`<%l'[R*RTzPUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR*iT^PUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR+PT_PUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR+gThPUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR+}b[PUQO}#r}!O+v!O!Q#r!Q![+v![!]+v!]!c#r!c!}+v!}#R#r#R#S+v#S#T#r#T#o+v#o#q#r#q#r$W#r%W#r%W;'S+v;'S;:j-V;:j;=`$g<%lO+vR-YP;=`<%l+vR-dTwPUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR-zTUQbPO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR.bTZPUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR.xT]PUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR/^VUQO#o#r#o#p/s#p#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR/zTSPUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#r~0^TO#q#r#q#r0m#r;'S#r;'S;=`$g<%lO#r~0rOR~",
|
|
tokenizers: [text, attrSingle, attrDouble, scriptAttrSingle, scriptAttrDouble, 0, 1],
|
|
topRules: {"Content":[0,2],"Attribute":[1,9]},
|
|
tokenPrec: 0
|
|
});
|
|
|
|
const exprParser = /*@__PURE__*/javascriptLanguage.parser.configure({
|
|
top: "SingleExpression"
|
|
});
|
|
const baseParser = /*@__PURE__*/parser.configure({
|
|
props: [
|
|
/*@__PURE__*/styleTags({
|
|
Text: tags.content,
|
|
Is: tags.definitionOperator,
|
|
AttributeName: tags.attributeName,
|
|
"AttributeValue ExpressionAttributeValue StatementAttributeValue": tags.attributeValue,
|
|
Entity: tags.character,
|
|
InvalidEntity: tags.invalid,
|
|
"BoundAttributeName/Identifier": tags.attributeName,
|
|
"EventName/Identifier": /*@__PURE__*/tags.special(tags.attributeName),
|
|
"ReferenceName/Identifier": tags.variableName,
|
|
"DirectiveName/Identifier": tags.keyword,
|
|
"{{ }}": tags.brace,
|
|
"( )": tags.paren,
|
|
"[ ]": tags.bracket,
|
|
"# '*'": tags.punctuation
|
|
})
|
|
]
|
|
});
|
|
const exprMixed = { parser: exprParser }, statementMixed = { parser: javascriptLanguage.parser };
|
|
const textParser = /*@__PURE__*/baseParser.configure({
|
|
wrap: /*@__PURE__*/parseMixed((node, input) => node.name == "InterpolationContent" ? exprMixed : null),
|
|
});
|
|
const attrParser = /*@__PURE__*/baseParser.configure({
|
|
wrap: /*@__PURE__*/parseMixed((node, input) => {
|
|
var _a;
|
|
return node.name == "InterpolationContent" ? exprMixed
|
|
: node.name != "AttributeInterpolation" ? null
|
|
: ((_a = node.node.parent) === null || _a === void 0 ? void 0 : _a.name) == "StatementAttributeValue" ? statementMixed : exprMixed;
|
|
}),
|
|
top: "Attribute"
|
|
});
|
|
const textMixed = { parser: textParser }, attrMixed = { parser: attrParser };
|
|
const baseHTML = /*@__PURE__*/html({ selfClosingTags: true });
|
|
function mkAngular(language) {
|
|
return language.configure({ wrap: parseMixed(mixAngular) }, "angular");
|
|
}
|
|
/**
|
|
A language provider for Angular Templates.
|
|
*/
|
|
const angularLanguage = /*@__PURE__*/mkAngular(baseHTML.language);
|
|
function mixAngular(node, input) {
|
|
switch (node.name) {
|
|
case "Attribute":
|
|
return /^[*#(\[]|\{\{/.test(input.read(node.from, node.to)) ? attrMixed : null;
|
|
case "Text":
|
|
return textMixed;
|
|
}
|
|
return null;
|
|
}
|
|
/**
|
|
Angular Template language support.
|
|
*/
|
|
function angular(config = {}) {
|
|
let base = baseHTML;
|
|
if (config.base) {
|
|
if (config.base.language.name != "html" || !(config.base.language instanceof LRLanguage))
|
|
throw new RangeError("The base option must be the result of calling html(...)");
|
|
base = config.base;
|
|
}
|
|
return new LanguageSupport(base.language == baseHTML.language ? angularLanguage : mkAngular(base.language), [base.support, base.language.data.of({
|
|
closeBrackets: { brackets: ["[", "{", '"'] },
|
|
indentOnInput: /^\s*[\}\]]$/
|
|
})]);
|
|
}
|
|
|
|
export { angular, angularLanguage };
|