UNPKG

@gdquest/gd-exercise

Version:

Core package that handles logic for the GDExercise project.

4 lines 494 kB
{ "version": 3, "sources": ["../../codemirror-gdscript/src/index.mts", "../../lezer-gdscript/src/parser.js", "../../lezer-gdscript/src/tokens.js", "../../lezer-gdscript/src/parser.terms.js", "../../lezer-gdscript/src/highlight.js", "../../../node_modules/.pnpm/@lezer+common@1.0.3/node_modules/@lezer/common/dist/index.js", "../../codemirror-gdscript/src/complete.mts", "../../../node_modules/.pnpm/@lezer+common@1.0.3/node_modules/@lezer/common/dist/index.js", "../../../node_modules/.pnpm/@lezer+lr@1.3.9/node_modules/@lezer/lr/dist/index.js", "../../../node_modules/.pnpm/@lezer+highlight@1.1.6/node_modules/@lezer/highlight/dist/index.js", "../../../node_modules/.pnpm/@codemirror+autocomplete@6.8.1_@codemirror+language@6.9.0_@codemirror+state@6.2.1_@codemirror_xdyrjbo3jiz3uawtkjryt6trui/node_modules/@codemirror/autocomplete/dist/index.js"], "sourcesContent": ["import {\n foldNodeProp,\n foldInside,\n indentNodeProp,\n LRLanguage,\n LanguageSupport,\n type TreeIndentContext,\n} from \"@codemirror/language\";\n\nimport { parser } from \"@gdquest/lezer-gdscript\";\n\nimport { globalCompletion, localCompletionSource } from \"./complete.mts\";\nimport { type SyntaxNode } from \"@lezer/common\";\nexport { globalCompletion, localCompletionSource };\n\nfunction indentBody(\n context: TreeIndentContext,\n node: SyntaxNode\n): number | null {\n const base = context.baseIndentFor(node);\n const line = context.lineAt(context.pos, -1);\n const to = line.from + line.text.length;\n // Don't consider blank, deindented lines at the end of the\n // block part of the block\n if (\n /^\\s*($|#)/.test(line.text) &&\n context.node.to < to + 100 &&\n !/\\S/.test(context.state.sliceDoc(to, context.node.to)) &&\n context.lineIndent(context.pos, -1) <= base\n ) {\n return null;\n }\n // A normally deindenting keyword that appears at a higher\n // indentation than the block should probably be handled by the next\n // level\n if (\n /^\\s*(else:|elif)/.test(context.textAfter) &&\n context.lineIndent(context.pos, -1) > base\n ) {\n return null;\n }\n return base + context.unit;\n}\n\nexport const gdscriptLanguage = LRLanguage.define({\n name: \"gdscript\",\n parser: parser.configure({\n props: [\n indentNodeProp.add({\n Body: (context) => {\n return indentBody(context, context.node) ?? context.continue();\n },\n IfNode: (context) => {\n return /^\\s*(else:|elif )/.test(context.textAfter)\n ? context.baseIndent\n : context.continue();\n },\n SuiteNode: (context) => {\n return indentBody(context, context.node) ?? context.continue();\n },\n String: () => {\n return null;\n },\n Script: (context) => {\n if (\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n context.pos + /\\s*/.exec(context.textAfter)![0].length >=\n context.node.to\n ) {\n let endBody = null;\n for (let cur: SyntaxNode | null = context.node, to = cur.to; ; ) {\n cur = cur.lastChild;\n if (cur == null || cur.to !== to) break;\n if (cur.type.name === \"Body\") endBody = cur;\n }\n if (endBody != null) {\n const bodyIndent = indentBody(context, endBody);\n if (bodyIndent != null) return bodyIndent;\n }\n }\n return context.continue();\n },\n }),\n foldNodeProp.add({\n \"ArrayExpressionNode DictionaryExpressionNode\": foldInside,\n Body: (node, state) => ({\n from: node.from + 1,\n to: node.to - (node.to === state.doc.length ? 0 : 1),\n }),\n }),\n ],\n }),\n languageData: {\n closeBrackets: {\n brackets: [\"(\", \"[\", \"{\", \"'\", '\"', \"'''\", '\"\"\"'],\n },\n commentTokens: { line: \"#\" },\n // eslint-disable-next-line no-useless-escape\n indentOnInput: /^\\s*([\\}\\]\\)]|else:|elif )$/,\n },\n});\n\nexport function gdscript(): LanguageSupport {\n return new LanguageSupport(gdscriptLanguage, [\n gdscriptLanguage.data.of({ autocomplete: localCompletionSource }),\n gdscriptLanguage.data.of({ autocomplete: globalCompletion }),\n ]);\n}\n", "// This file was generated by lezer-generator. You probably shouldn't edit it.\nimport {LRParser} from \"@lezer/lr\"\nimport {indentation, newlines, trackIndent} from \"./tokens.js\"\nimport {gdscriptHighlighting} from \"./highlight\"\nconst spec_Identifier = {__proto__:null,PI:34, TAU:36, INF:38, NaN:40, assert:48, var:68, const:78, await:84, in:114, as:120, func:138, preload:162, is:176, class_name:186, extends:190, signal:194, pass:198, return:202, class:214, if:222, elif:226, else:230, for:234, match:238, while:254}\nexport const parser = LRParser.deserialize({\n version: 14,\n states: \"KnQ`QUOOP#rOQOOOOQQ'#Cq'#CqOOQQ'#Ch'#ChO#wQUO'#CbO#|QUO'#CaO&OQYO'#CyO&iQUO'#CxO(_QUO'#CwO(fQYO'#FmO*fQUO'#C}OOQQ'#Fn'#FnO,RQYO'#C`O+|QUO'#C|O,`QUO'#DlO.PQUO'#DoO&nQUO'#DpOOQQ'#EQ'#EQO&nQUO'#EYOOQQ'#Fm'#FmOOQQ'#C`'#C`O.UQUO'#C_OOQR'#C_'#C_O.aQVO'#EmOOQR'#Ei'#EiOOQR'#Fg'#FgOOQR'#FQ'#FQQ`QUOOOOQQ'#Cl'#ClO1VQUO'#C}O1[QUO'#DSO&nQUO'#DVO1aQUO'#ElO1fQUO'#EOO1fQUO'#CsO1kQUO'#E[O1pQUO'#E^O1uQUO'#E`OOQQ'#Eb'#EbO&nQUO'#EdO1zQUO'#EjO,`QUO'#EnO2PQUO'#EtO2UQUO'#EvO,`QUO'#FOP2ZOUO'#FfPOOO)CAY)CAYO2fQUO,58|O3TQUO'#DPOOQQ,59p,59pO&nQUO,59hOOQQ,5:S,5:SO3YQUO'#CuO3aQUO'#FSO3fQYO,59dOOQQ,59c,59cO5iQUO,59cOOQQ'#FT'#FTO5nQUO'#C}O5yQYO'#FlO6WQUO'#DrO6]QUO,59cO,`QUO,5:WOOQQ-E9R-E9RO6dQUO,59iO6iQUO,59nO6nQUO,5;UO6sQUO,5;WO&nQUO,59sO&nQUO,59sO&nQUO,59sO&nQUO,59sO&nQUO,59sO&nQUO,59sO&nQUO,59sO&nQUO,59sO&nQUO,59sO&nQUO,59sO&nQUO,5:nO&nQUO,59sO6xQUO,59sO3TQUO,5:TO6}QUO,5:qO8ZQYO'#DnO8eQUO'#FpO8mQUO,5:WO8rQYO,5:ZO:lQYO,5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ralExpressionNode True False Null BuiltinConstants PI TAU INF NaN String , AssertNode assert CallParamsExpressionNode ] ArrayExpressionNode SubscriptExpressionNode VariableName . [ AssignmentExpressionNode VariableNode var TypeCast : Type ConstantNode const ParameterNode AwaitExpressionNode await BinaryOperatorExpressionNode ArithOp ArithOp ArithOp BitOp CompareOp BitOp BitOp BitOp AndOp LogicOp OrOp LogicOp NotOp in CallExpressionNode CastExpressionNode as } DictionaryExpressionNode { DictionaryEntry GetNodeExpressionNode GroupedExpressionNode IdentifierExpressionNode LambdaExpressionNode func CallParamsParameterNode AssignmentExpressionNode FunctionReturnType Body SuiteNodeBody Newline SuiteNode Indent Dedent ExpressionNodeBody PreloadExpressionNode preload SelfExpressionNode SelfToken TernaryOperatorExpressionNode TernaryOp TernaryOp TypeTestExpressionNode is ClassName UnaryOperatorNode ArithOp ClassNameStatement class_name ExtendsStatement extends SignalStatement signal PassStatement pass ReturnNode return Eof StatementGroup ; CompoundStatement ClassNode class FunctionNode IfNode IfClause if ElifClause elif ElseClause else ForNode for MatchNode match MatchBranchNode PatternNode VarPatternNode IdentifierPatternNode LiteralPatternNode WildcardPatternNode WhileNode while\",\n maxTerm: 165,\n context: trackIndent,\n nodeProps: [\n [\"group\", -2,3,105,\"Statement\",-18,12,27,28,32,41,43,58,59,62,65,66,67,68,80,82,84,87,90,\"ExpressionNode\",-3,33,38,40,\"AssignableNode\"],\n [\"openedBy\", 9,\"(\"],\n [\"closedBy\", 10,\")\"]\n ],\n propSources: [gdscriptHighlighting],\n skippedNodes: [0,1],\n repeatNodeCount: 11,\n tokenData: \"@U~R|XY#{pq#{qr$Wrs$est(Vtu(quv(vvw(}wx)[xy,|yz-Rz{-W{|-e|}-l}!O-q!O!P.Q!P!Q/]!Q!R/d!R![0U![!]1v!]!^1}!^!_2S!_!`2d!`!a2l!a!b2w!b!c2|!c!}3R!}#O3d#P#Q3i#Q#R3n#R#S3s#T#U4W#U#Y3R#Y#Z5k#Z#b3R#b#c7{#c#d:y#d#g3R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!}3R#R#S3R#T#`3R#`#a<u#a#o3R~<zUW~!Q![3R!c!}3R#R#S3R#T#Y3R#Y#Z=^#Z#o3R~=eS!u~W~!Q![3R!c!}3R#R#S3R#T#o3R~=vUW~!Q![3R!c!}3R#R#S3R#T#f3R#f#g>Y#g#o3R~>_UW~!Q![3R!c!}3R#R#S3R#T#i3R#i#j>q#j#o3R~>vUW~!Q![3R!c!}3R#R#S3R#T#X3R#X#Y?Y#Y#o3R~?aS]~W~!Q![3R!c!}3R#R#S3R#T#o3R~?rO!a~~?wP!R~#p#q?z~@PO!X~~@UO!_~\",\n tokenizers: [indentation, newlines, 0, 1, 2],\n topRules: {\"Script\":[0,2]},\n specialized: [{term: 8, get: value => spec_Identifier[value] || -1}],\n tokenPrec: 3491\n})\n", "import { ContextTracker, ExternalTokenizer } from \"@lezer/lr\";\nimport {\n // created\n // indentation\n indent,\n dedent,\n // newlines\n newline as newlineToken,\n blankLineStart,\n newlineBracketed,\n eof,\n // existing\n GroupedExpressionNode,\n ArrayExpressionNode,\n DictionaryExpressionNode,\n CallExpressionNode,\n CallParamsExpressionNode,\n CallParamsLiteralExpressionNode,\n CallParamsParameterNode,\n // tokens\n ParenL,\n BracketL,\n BraceL,\n} from \"./parser.terms\";\n\nconst bracketed = new Set([\n GroupedExpressionNode,\n ArrayExpressionNode,\n DictionaryExpressionNode,\n CallExpressionNode,\n CallParamsExpressionNode,\n CallParamsLiteralExpressionNode,\n CallParamsParameterNode,\n]);\n\nconst newline = \"\\n\".charCodeAt(0);\nconst carriageReturn = \"\\r\".charCodeAt(0);\nconst space = \" \".charCodeAt(0);\nconst tab = \"\\t\".charCodeAt(0);\nconst hash = \"#\".charCodeAt(0);\n\nclass IndentLevel {\n constructor(parent, depth) {\n this.parent = parent;\n // -1 means this is not an actual indent level but a set of brackets\n this.depth = depth;\n this.hash =\n (parent ? (parent.hash + parent.hash) << 8 : 0) + depth + (depth << 4);\n }\n}\n\nconst topIndent = new IndentLevel(null, 0);\n\nfunction isLineBreak(ch) {\n return ch === newline || ch === carriageReturn;\n}\n\nexport const newlines = new ExternalTokenizer(\n (input, stack) => {\n let prev;\n if (input.next < 0) {\n input.acceptToken(eof);\n } else if (stack.context.depth < 0) {\n if (isLineBreak(input.next)) {\n input.acceptToken(newlineBracketed, 1);\n }\n } else if (\n ((prev = input.peek(-1)) < 0 || isLineBreak(prev)) &&\n stack.canShift(blankLineStart)\n ) {\n let spaces = 0;\n while (input.next === space || input.next === tab) {\n input.advance();\n spaces++;\n }\n if (\n input.next === newline ||\n input.next === carriageReturn ||\n input.next === hash\n ) {\n input.acceptToken(blankLineStart, -spaces);\n }\n } else if (isLineBreak(input.next)) {\n input.acceptToken(newlineToken, 1);\n }\n },\n { contextual: true }\n);\n\nfunction countIndent(space) {\n let depth = 0;\n for (let i = 0; i < space.length; i++)\n depth += space.charCodeAt(i) === tab ? 8 - (depth % 8) : 1;\n return depth;\n}\n\nexport const trackIndent = new ContextTracker({\n start: topIndent,\n reduce(context, term) {\n return context.depth < 0 && bracketed.has(term) ? context.parent : context;\n },\n shift(context, term, stack, input) {\n switch (term) {\n case indent:\n return new IndentLevel(\n context,\n countIndent(input.read(input.pos, stack.pos))\n );\n case dedent:\n return context.parent;\n case ParenL:\n case BracketL:\n case BraceL:\n return new IndentLevel(context, -1);\n default:\n return context;\n }\n },\n hash(context) {\n return context.hash;\n },\n});\n\nexport const indentation = new ExternalTokenizer((input, stack) => {\n const contextDepth = stack.context.depth;\n if (contextDepth < 0) return;\n\n const prev = input.peek(-1);\n\n if (!(prev === newline || prev === carriageReturn)) {\n return;\n }\n\n let chars = 0;\n let depth = 0;\n\n while (true) {\n if (input.next === space) {\n depth++;\n } else if (input.next === tab) {\n depth += 8 - (depth % 8);\n } else {\n break;\n }\n\n input.advance();\n chars += 1;\n }\n\n if (\n depth !== contextDepth &&\n input.next !== newline &&\n input.next !== carriageReturn &&\n input.next !== hash\n ) {\n if (depth < contextDepth) {\n input.acceptToken(dedent, -chars);\n } else {\n input.acceptToken(indent);\n }\n }\n});\n", "// This file was generated by lezer-generator. You probably shouldn't edit it.\nexport const\n indent = 140,\n dedent = 141,\n newline = 142,\n blankLineStart = 143,\n newlineBracketed = 144,\n eof = 145,\n Comment = 1,\n Script = 2,\n SimpleStatement = 3,\n SmallStatement = 4,\n AnnotationNode = 6,\n Identifier = 8,\n ParenL = 10,\n CallParamsLiteralExpressionNode = 11,\n LiteralExpressionNode = 12,\n True = 13,\n False = 14,\n Null = 15,\n BuiltinConstants = 16,\n String = 21,\n AssertNode = 23,\n CallParamsExpressionNode = 25,\n ArrayExpressionNode = 27,\n SubscriptExpressionNode = 28,\n VariableName = 29,\n BracketL = 31,\n VariableNode = 33,\n TypeCast = 35,\n Type = 37,\n ConstantNode = 38,\n ParameterNode = 40,\n AwaitExpressionNode = 41,\n BinaryOperatorExpressionNode = 43,\n AndOp = 52,\n OrOp = 54,\n NotOp = 56,\n CallExpressionNode = 58,\n CastExpressionNode = 59,\n DictionaryExpressionNode = 62,\n BraceL = 63,\n DictionaryEntry = 64,\n GetNodeExpressionNode = 65,\n GroupedExpressionNode = 66,\n IdentifierExpressionNode = 67,\n LambdaExpressionNode = 68,\n CallParamsParameterNode = 70,\n FunctionReturnType = 72,\n Body = 73,\n SuiteNodeBody = 74,\n Newline = 75,\n SuiteNode = 76,\n Indent = 77,\n Dedent = 78,\n ExpressionNodeBody = 79,\n PreloadExpressionNode = 80,\n SelfToken = 83,\n TernaryOperatorExpressionNode = 84,\n TypeTestExpressionNode = 87,\n ClassName = 89,\n UnaryOperatorNode = 90,\n ClassNameStatement = 92,\n ExtendsStatement = 94,\n SignalStatement = 96,\n PassStatement = 98,\n ReturnNode = 100,\n Eof = 102,\n CompoundStatement = 105,\n ClassNode = 106,\n FunctionNode = 108,\n IfNode = 109,\n IfClause = 110,\n ElifClause = 112,\n ElseClause = 114,\n ForNode = 116,\n MatchNode = 118,\n MatchBranchNode = 120,\n PatternNode = 121,\n WhileNode = 126\n", "import { styleTags, tags as t } from \"@lezer/highlight\";\n\nexport const gdscriptHighlighting = styleTags({\n \"for while if elif else return break continue pass assert await match case\":\n t.controlKeyword,\n \"in not and or is del\": t.operatorKeyword,\n \"func class class_name extends const var\": t.definitionKeyword,\n \"preload load\": t.moduleKeyword,\n \"as PI TAU INF NaN\": t.keyword,\n True: t.bool,\n False: t.bool,\n Null: t.bool,\n Comment: t.lineComment,\n Number: t.number,\n String: t.string,\n UpdateOp: t.updateOperator,\n ArithOp: t.arithmeticOperator,\n BitOp: t.bitwiseOperator,\n CompareOp: t.compareOperator,\n AssignOp: t.definitionOperator,\n \"ClassNode/Identifier ClassNode/ExtendsStatement/Identifier VariableNode/TypeCast/Type/Identifier\":\n t.definition(t.className),\n \"( )\": t.paren,\n \"[ ]\": t.squareBracket,\n \"{ }\": t.brace,\n \".\": t.derefOperator,\n \", ;\": t.separator,\n});\n", "// FIXME profile adding a per-Tree TreeNode cache, validating it by\n// parent pointer\n/// The default maximum length of a `TreeBuffer` node.\nconst DefaultBufferLength = 1024;\nlet nextPropID = 0;\nclass Range {\n constructor(from, to) {\n this.from = from;\n this.to = to;\n }\n}\n/// Each [node type](#common.NodeType) or [individual tree](#common.Tree)\n/// can have metadata associated with it in props. Instances of this\n/// class represent prop names.\nclass NodeProp {\n /// Create a new node prop type.\n constructor(config = {}) {\n this.id = nextPropID++;\n this.perNode = !!config.perNode;\n this.deserialize = config.deserialize || (() => {\n throw new Error(\"This node type doesn't define a deserialize function\");\n });\n }\n /// This is meant to be used with\n /// [`NodeSet.extend`](#common.NodeSet.extend) or\n /// [`LRParser.configure`](#lr.ParserConfig.props) to compute\n /// prop values for each node type in the set. Takes a [match\n /// object](#common.NodeType^match) or function that returns undefined\n /// if the node type doesn't get this prop, and the prop's value if\n /// it does.\n add(match) {\n if (this.perNode)\n throw new RangeError(\"Can't add per-node props to node types\");\n if (typeof match != \"function\")\n match = NodeType.match(match);\n return (type) => {\n let result = match(type);\n return result === undefined ? null : [this, result];\n };\n }\n}\n/// Prop that is used to describe matching delimiters. For opening\n/// delimiters, this holds an array of node names (written as a\n/// space-separated string when declaring this prop in a grammar)\n/// for the node types of closing delimiters that match it.\nNodeProp.closedBy = new NodeProp({ deserialize: str => str.split(\" \") });\n/// The inverse of [`closedBy`](#common.NodeProp^closedBy). This is\n/// attached to closing delimiters, holding an array of node names\n/// of types of matching opening delimiters.\nNodeProp.openedBy = new NodeProp({ deserialize: str => str.split(\" \") });\n/// Used to assign node types to groups (for example, all node\n/// types that represent an expression could be tagged with an\n/// `\"Expression\"` group).\nNodeProp.group = new NodeProp({ deserialize: str => str.split(\" \") });\n/// The hash of the [context](#lr.ContextTracker.constructor)\n/// that the node was parsed in, if any. Used to limit reuse of\n/// contextual nodes.\nNodeProp.contextHash = new NodeProp({ perNode: true });\n/// The distance beyond the end of the node that the tokenizer\n/// looked ahead for any of the tokens inside the node. (The LR\n/// parser only stores this when it is larger than 25, for\n/// efficiency reasons.)\nNodeProp.lookAhead = new NodeProp({ perNode: true });\n/// This per-node prop is used to replace a given node, or part of a\n/// node, with another tree. This is useful to include trees from\n/// different languages in mixed-language parsers.\nNodeProp.mounted = new NodeProp({ perNode: true });\n/// A mounted tree, which can be [stored](#common.NodeProp^mounted) on\n/// a tree node to indicate that parts of its content are\n/// represented by another tree.\nclass MountedTree {\n constructor(\n /// The inner tree.\n tree, \n /// If this is null, this tree replaces the entire node (it will\n /// be included in the regular iteration instead of its host\n /// node). If not, only the given ranges are considered to be\n /// covered by this tree. This is used for trees that are mixed in\n /// a way that isn't strictly hierarchical. Such mounted trees are\n /// only entered by [`resolveInner`](#common.Tree.resolveInner)\n /// and [`enter`](#common.SyntaxNode.enter).\n overlay, \n /// The parser used to create this subtree.\n parser) {\n this.tree = tree;\n this.overlay = overlay;\n this.parser = parser;\n }\n}\nconst noProps = Object.create(null);\n/// Each node in a syntax tree has a node type associated with it.\nclass NodeType {\n /// @internal\n constructor(\n /// The name of the node type. Not necessarily unique, but if the\n /// grammar was written properly, different node types with the\n /// same name within a node set should play the same semantic\n /// role.\n name, \n /// @internal\n props, \n /// The id of this node in its set. Corresponds to the term ids\n /// used in the parser.\n id, \n /// @internal\n flags = 0) {\n this.name = name;\n this.props = props;\n this.id = id;\n this.flags = flags;\n }\n /// Define a node type.\n static define(spec) {\n let props = spec.props && spec.props.length ? Object.create(null) : noProps;\n let flags = (spec.top ? 1 /* NodeFlag.Top */ : 0) | (spec.skipped ? 2 /* NodeFlag.Skipped */ : 0) |\n (spec.error ? 4 /* NodeFlag.Error */ : 0) | (spec.name == null ? 8 /* NodeFlag.Anonymous */ : 0);\n let type = new NodeType(spec.name || \"\", props, spec.id, flags);\n if (spec.props)\n for (let src of spec.props) {\n if (!Array.isArray(src))\n src = src(type);\n if (src) {\n if (src[0].perNode)\n throw new RangeError(\"Can't store a per-node prop on a node type\");\n props[src[0].id] = src[1];\n }\n }\n return type;\n }\n /// Retrieves a node prop for this type. Will return `undefined` if\n /// the prop isn't present on this node.\n prop(prop) { return this.props[prop.id]; }\n /// True when this is the top node of a grammar.\n get isTop() { return (this.flags & 1 /* NodeFlag.Top */) > 0; }\n /// True when this node is produced by a skip rule.\n get isSkipped() { return (this.flags & 2 /* NodeFlag.Skipped */) > 0; }\n /// Indicates whether this is an error node.\n get isError() { return (this.flags & 4 /* NodeFlag.Error */) > 0; }\n /// When true, this node type doesn't correspond to a user-declared\n /// named node, for example because it is used to cache repetition.\n get isAnonymous() { return (this.flags & 8 /* NodeFlag.Anonymous */) > 0; }\n /// Returns true when this node's name or one of its\n /// [groups](#common.NodeProp^group) matches the given string.\n is(name) {\n if (typeof name == 'string') {\n if (this.name == name)\n return true;\n let group = this.prop(NodeProp.group);\n return group ? group.indexOf(name) > -1 : false;\n }\n return this.id == name;\n }\n /// Create a function from node types to arbitrary values by\n /// specifying an object whose property names are node or\n /// [group](#common.NodeProp^group) names. Often useful with\n /// [`NodeProp.add`](#common.NodeProp.add). You can put multiple\n /// names, separated by spaces, in a single property name to map\n /// multiple node names to a single value.\n static match(map) {\n let direct = Object.create(null);\n for (let prop in map)\n for (let name of prop.split(\" \"))\n direct[name] = map[prop];\n return (node) => {\n for (let groups = node.prop(NodeProp.group), i = -1; i < (groups ? groups.length : 0); i++) {\n let found = direct[i < 0 ? node.name : groups[i]];\n if (found)\n return found;\n }\n };\n }\n}\n/// An empty dummy node type to use when no actual type is available.\nNodeType.none = new NodeType(\"\", Object.create(null), 0, 8 /* NodeFlag.Anonymous */);\n/// A node set holds a collection of node types. It is used to\n/// compactly represent trees by storing their type ids, rather than a\n/// full pointer to the type object, in a numeric array. Each parser\n/// [has](#lr.LRParser.nodeSet) a node set, and [tree\n/// buffers](#common.TreeBuffer) can only store collections of nodes\n/// from the same set. A set can have a maximum of 2**16 (65536) node\n/// types in it, so that the ids fit into 16-bit typed array slots.\nclass NodeSet {\n /// Create a set with the given types. The `id` property of each\n /// type should correspond to its position within the array.\n constructor(\n /// The node types in this set, by id.\n types) {\n this.types = types;\n for (let i = 0; i < types.length; i++)\n if (types[i].id != i)\n throw new RangeError(\"Node type ids should correspond to array positions when creating a node set\");\n }\n /// Create a copy of this set with some node properties added. The\n /// arguments to this method can be created with\n /// [`NodeProp.add`](#common.NodeProp.add).\n extend(...props) {\n let newTypes = [];\n for (let type of this.types) {\n let newProps = null;\n for (let source of props) {\n let add = source(type);\n if (add) {\n if (!newProps)\n newProps = Object.assign({}, type.props);\n newProps[add[0].id] = add[1];\n }\n }\n newTypes.push(newProps ? new NodeType(type.name, newProps, type.id, type.flags) : type);\n }\n return new NodeSet(newTypes);\n }\n}\nconst CachedNode = new WeakMap(), CachedInnerNode = new WeakMap();\n/// Options that control iteration. Can be combined with the `|`\n/// operator to enable multiple ones.\nvar IterMode;\n(function (IterMode) {\n /// When enabled, iteration will only visit [`Tree`](#common.Tree)\n /// objects, not nodes packed into\n /// [`TreeBuffer`](#common.TreeBuffer)s.\n IterMode[IterMode[\"ExcludeBuffers\"] = 1] = \"ExcludeBuffers\";\n /// Enable this to make iteration include anonymous nodes (such as\n /// the nodes that wrap repeated grammar constructs into a balanced\n /// tree).\n IterMode[IterMode[\"IncludeAnonymous\"] = 2] = \"IncludeAnonymous\";\n /// By default, regular [mounted](#common.NodeProp^mounted) nodes\n /// replace their base node in iteration. Enable this to ignore them\n /// instead.\n IterMode[IterMode[\"IgnoreMounts\"] = 4] = \"IgnoreMounts\";\n /// This option only applies in\n /// [`enter`](#common.SyntaxNode.enter)-style methods. It tells the\n /// library to not enter mounted overlays if one covers the given\n /// position.\n IterMode[IterMode[\"IgnoreOverlays\"] = 8] = \"IgnoreOverlays\";\n})(IterMode || (IterMode = {}));\n/// A piece of syntax tree. There are two ways to approach these\n/// trees: the way they are actually stored in memory, and the\n/// convenient way.\n///\n/// Syntax trees are stored as a tree of `Tree` and `TreeBuffer`\n/// objects. By packing detail information into `TreeBuffer` leaf\n/// nodes, the representation is made a lot more memory-efficient.\n///\n/// However, when you want to actually work with tree nodes, this\n/// representation is very awkward, so most client code will want to\n/// use the [`TreeCursor`](#common.TreeCursor) or\n/// [`SyntaxNode`](#common.SyntaxNode) interface instead, which provides\n/// a view on some part of this data structure, and can be used to\n/// move around to adjacent nodes.\nclass Tree {\n /// Construct a new tree. See also [`Tree.build`](#common.Tree^build).\n constructor(\n /// The type of the top node.\n type, \n /// This node's child nodes.\n children, \n /// The positions (offsets relative to the start of this tree) of\n /// the children.\n positions, \n /// The total length of this tree\n length, \n /// Per-node [node props](#common.NodeProp) to associate with this node.\n props) {\n this.type = type;\n this.children = children;\n this.positions = positions;\n this.length = length;\n /// @internal\n this.props = null;\n if (props && props.length) {\n this.props = Object.create(null);\n for (let [prop, value] of props)\n this.props[typeof prop == \"number\" ? prop : prop.id] = value;\n }\n }\n /// @internal\n toString() {\n let mounted = this.prop(NodeProp.mounted);\n if (mounted && !mounted.overlay)\n return mounted.tree.toString();\n let children = \"\";\n for (let ch of this.children) {\n let str = ch.toString();\n if (str) {\n if (children)\n children += \",\";\n children += str;\n }\n }\n return !this.type.name ? children :\n (/\\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) +\n (children.length ? \"(\" + children + \")\" : \"\");\n }\n /// Get a [tree cursor](#common.TreeCursor) positioned at the top of\n /// the tree. Mode can be used to [control](#common.IterMode) which\n /// nodes the cursor visits.\n cursor(mode = 0) {\n return new TreeCursor(this.topNode, mode);\n }\n /// Get a [tree cursor](#common.TreeCursor) pointing into this tree\n /// at the given position and side (see\n /// [`moveTo`](#common.TreeCursor.moveTo).\n cursorAt(pos, side = 0, mode = 0) {\n let scope = CachedNode.get(this) || this.topNode;\n let cursor = new TreeCursor(scope);\n cursor.moveTo(pos, side);\n CachedNode.set(this, cursor._tree);\n return cursor;\n }\n /// Get a [syntax node](#common.SyntaxNode) object for the top of the\n /// tree.\n get topNode() {\n return new TreeNode(this, 0, 0, null);\n }\n /// Get the [syntax node](#common.SyntaxNode) at the given position.\n /// If `side` is -1, this will move into nodes that end at the\n /// position. If 1, it'll move into nodes that start at the\n /// position. With 0, it'll only enter nodes that cover the position\n /// from both sides.\n ///\n /// Note that this will not enter\n /// [overlays](#common.MountedTree.overlay), and you often want\n /// [`resolveInner`](#common.Tree.resolveInner) instead.\n resolve(pos, side = 0) {\n let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, false);\n CachedNode.set(this, node);\n return node;\n }\n /// Like [`resolve`](#common.Tree.resolve), but will enter\n /// [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node\n /// pointing into the innermost overlaid tree at the given position\n /// (with parent links going through all parent structure, including\n /// the host trees).\n resolveInner(pos, side = 0) {\n let node = resolveNode(CachedInnerNode.get(this) || this.topNode, pos, side, true);\n CachedInnerNode.set(this, node);\n return node;\n }\n /// Iterate over the tree and its children, calling `enter` for any\n /// node that touches the `from`/`to` region (if given) before\n /// running over such a node's children, and `leave` (if given) when\n /// leaving the node. When `enter` returns `false`, that node will\n /// not have its children iterated over (or `leave` called).\n iterate(spec) {\n let { enter, leave, from = 0, to = this.length } = spec;\n let mode = spec.mode || 0, anon = (mode & IterMode.IncludeAnonymous) > 0;\n for (let c = this.cursor(mode | IterMode.IncludeAnonymous);;) {\n let entered = false;\n if (c.from <= to && c.to >= from && (!anon && c.type.isAnonymous || enter(c) !== false)) {\n if (c.firstChild())\n continue;\n entered = true;\n }\n for (;;) {\n if (entered && leave && (anon || !c.type.isAnonymous))\n leave(c);\n if (c.nextSibling())\n break;\n if (!c.parent())\n return;\n entered = true;\n }\n }\n }\n /// Get the value of the given [node prop](#common.NodeProp) for this\n /// node. Works with both per-node and per-type props.\n prop(prop) {\n return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : undefined;\n }\n /// Returns the node's [per-node props](#common.NodeProp.perNode) in a\n /// format that can be passed to the [`Tree`](#common.Tree)\n /// constructor.\n get propValues() {\n let result = [];\n if (this.props)\n for (let id in this.props)\n result.push([+id, this.props[id]]);\n return result;\n }\n /// Balance the direct children of this tree, producing a copy of\n /// which may have children grouped into subtrees with type\n /// [`NodeType.none`](#common.NodeType^none).\n balance(config = {}) {\n return this.children.length <= 8 /* Balance.BranchFactor */ ? this :\n balanceRange(NodeType.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new Tree(this.type, children, positions, length, this.propValues), config.makeTree || ((children, positions, length) => new Tree(NodeType.none, children, positions, length)));\n }\n /// Build a tree from a postfix-ordered buffer of node information,\n /// or a cursor over such a buffer.\n static build(data) { return buildTree(data); }\n}\n/// The empty tree\nTree.empty = new Tree(NodeType.none, [], [], 0);\nclass FlatBufferCursor {\n constructor(buffer, index) {\n this.buffer = buffer;\n this.index = index;\n }\n get id() { return this.buffer[this.index - 4]; }\n get start() { return this.buffer[this.index - 3]; }\n get end() { return this.buffer[this.index - 2]; }\n get size() { return this.buffer[this.index - 1]; }\n get pos() { return this.index; }\n next() { this.index -= 4; }\n fork() { return new FlatBufferCursor(this.buffer, this.index); }\n}\n/// Tree buffers contain (type, start, end, endIndex) quads for each\n/// node. In such a buffer, nodes are stored in prefix order (parents\n/// before children, with the endIndex of the parent indicating which\n/// children belong to it).\nclass TreeBuffer {\n /// Create a tree buffer.\n constructor(\n /// The buffer's content.\n buffer, \n /// The total length of the group of nodes in the buffer.\n length, \n /// The node set used in this buffer.\n set) {\n this.buffer = buffer;\n this.length = length;\n this.set = set;\n }\n /// @internal\n get type() { return NodeType.none; }\n /// @internal\n toString() {\n let result = [];\n for (let index = 0; index < this.buffer.length;) {\n result.push(this.childString(index));\n index = this.buffer[index + 3];\n }\n return result.join(\",\");\n }\n /// @internal\n childString(index) {\n let id = this.buffer[index], endIndex = this.buffer[index + 3];\n let type = this.set.types[id], result = type.name;\n if (/\\W/.test(result) && !type.isError)\n result = JSON.stringify(result);\n index += 4;\n if (endIndex == index)\n return result;\n let children = [];\n while (index < endIndex) {\n children.push(this.childString(index));\n index = this.buffer[index + 3];\n }\n return result + \"(\" + children.join(\",\") + \")\";\n }\n /// @internal\n findChild(startIndex, endIndex, dir, pos, side) {\n let { buffer } = this, pick = -1;\n for (let i = startIndex; i != endIndex; i = buffer[i + 3]) {\n if (checkSide(side, pos, buffer[i + 1], buffer[i + 2])) {\n pick = i;\n if (dir > 0)\n break;\n }\n }\n return pick;\n }\n /// @internal\n slice(startI, endI, from) {\n let b = this.buffer;\n let copy = new Uint16Array(endI - startI), len = 0;\n for (let i = startI, j = 0; i < endI;) {\n copy[j++] = b[i++];\n copy[j++] = b[i++] - from;\n let to = copy[j++] = b[i++] - from;\n copy[j++] = b[i++] - startI;\n len = Math.max(len, to);\n }\n return new TreeBuffer(copy, len, this.set);\n }\n}\nfunction checkSide(side, pos, from, to) {\n switch (side) {\n case -2 /* Side.Before */: return from < pos;\n case -1 /* Side.AtOrBefore */: return to >= pos && from < pos;\n case 0 /* Side.Around */: return from < pos && to > pos;\n case 1 /* Side.AtOrAfter */: return from <= pos && to > pos;\n case 2 /* Side.After */: return to > pos;\n case 4 /* Side.DontCare */: return true;\n }\n}\nfunction enterUnfinishedNodesBefore(node, pos) {\n let scan = node.childBefore(pos);\n while (scan) {\n let last = scan.lastChild;\n if (!last || last.to != scan.to)\n break;\n if (last.type.isError && last.from == last.to) {\n node = scan;\n scan = last.prevSibling;\n }\n else {\n scan = last;\n }\n }\n return node;\n}\nfunction resolveNode(node, pos, side, overlays) {\n var _a;\n // Move up to a node that actually holds the position, if possible\n while (node.from == node.to ||\n (side < 1 ? node.from >= pos : node.from > pos) ||\n (side > -1 ? node.to <= pos : node.to < pos)) {\n let parent = !overlays && node instanceof TreeNode && node.index < 0 ? null : node.parent;\n if (!parent)\n return node;\n node = parent;\n }\n let mode = overlays ? 0 : IterMode.IgnoreOverlays;\n // Must go up out of overlays when those do not overlap with pos\n if (overlays)\n for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) {\n if (scan instanceof TreeNode && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from)\n node = parent;\n }\n for (;;) {\n let inner = node.enter(pos, side, mode);\n if (!inner)\n return node;\n node = inner;\n }\n}\nclass TreeNode {\n constructor(_tree, from, \n // Index in parent node, set to -1 if the node is not a direct child of _parent.node (overlay)\n index, _parent) {\n this._tree = _tree;\n this.from = from;\n this.index = index;\n this._parent = _parent;\n }\n get type() { return this._tree.type; }\n get name() { return this._tree.type.name; }\n get to() { return this.from + this._tree.length; }\n nextChild(i, di