UNPKG

@gdquest/gd-exercise

Version:

Core package that handles logic for the GDExercise project.

4 lines 491 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:70, const:80, await:86, in:116, as:122, 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: \"KtQ`QUOOP#rOQOOOOQQ'#Cq'#CqOOQQ'#Ch'#ChO#wQUO'#CbO#|QUO'#CaO&OQYO'#CyO&iQUO'#CzO&nQUO'#CxO(jQYO'#FmO*bQUO'#CwO*iQYO'#FmO*vQUO'#DOOOQQ'#Fq'#FqO,cQYO'#C`O,^QUO'#C}O,pQUO'#DmO(qQUO'#DpOOQQ'#EQ'#EQO(qQUO'#EYOOQQ'#Fm'#FmOOQQ'#C`'#C`O.aQUO'#C_OOQR'#C_'#C_O.lQVO'#EmOOQR'#Ei'#EiOOQR'#Fg'#FgOOQR'#FQ'#FQQ`QUOOOOQQ'#Cl'#ClO1bQUO'#DOO1gQUO'#DTO(qQUO'#DWO1lQUO'#ElO1qQUO'#EOO1qQUO'#CsO1vQUO'#E[O1{QUO'#E^O2QQUO'#E`OOQQ'#Eb'#EbO(qQUO'#EdO2VQUO'#EjO,pQUO'#EnO2[QUO'#EtO2aQUO'#EvO,pQUO'#FOP2fOUO'#FfPOOO)CAY)CAYO2qQUO,58|O3`QUO'#DQOOQQ,59q,59qO(qQUO,59iOOQQ,5:T,5:TO3eQUO'#CuO3lQYO,59fO5iQUO'#FTO5nQYO,59dOOQQ,59c,59cO7qQUO,59cOOQQ'#FU'#FUO7vQUO'#DOO8RQYO'#FlO8`QUO'#DrO8eQUO,59cO,pQUO,5:XOOQQ-E9S-E9SO8lQUO,59jO8qQUO,59oO8vQUO,5;UO8{QUO,5;WO(qQUO,59tO(qQUO,59tO(qQUO,59tO(qQUO,59tO(qQUO,59tO(qQUO,59tO(qQUO,59tO(qQUO,59tO(qQUO,59tO(qQUO,59tO(qQUO,5:nO(qQUO,59tO9QQUO,59tO3`QUO,5:UO9VQUO,5:qO:cQYO'#DoO:mQUO'#FsO:uQUO,5:XO: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q%h$SQ'e'pR'h'uR%^#z\",\n nodeNames: \"\u26A0 Comment Script SimpleStatement SmallStatement StandaloneAnnotationNode AnnotationNode @ Identifier ) ( CallParamsLiteralExpressionNode LiteralExpressionNode True False Null BuiltinConstants PI TAU INF NaN String , AssertNode assert CallParamsExpressionNode ] ArrayExpressionNode SubscriptExpressionNode VariableName GetNodeExpressionNode . [ 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 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,30,33,42,44,59,60,63,66,67,68,80,82,84,87,90,\"ExpressionNode\",-3,34,39,41,\"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}!^!_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#f3R#f#g;b#g#o3R~;iS!X~W~!Q![3R!c!}3R#R#S3R#T#o3R~;zUW~!Q![3R!c!}3R#R#S3R#T#X3R#X#Y<^#Y#o3R~<cUW~!Q![3R!c!}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!b~~?wP!S~#p#q?z~@PO!Y~~@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: 3508\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 GetNodeExpressionNode = 30,\n BracketL = 32,\n VariableNode = 34,\n TypeCast = 36,\n Type = 38,\n ConstantNode = 39,\n ParameterNode = 41,\n AwaitExpressionNode = 42,\n BinaryOperatorExpressionNode = 44,\n AndOp = 53,\n OrOp = 55,\n NotOp = 57,\n CallExpressionNode = 59,\n CastExpressionNode = 60,\n DictionaryExpressionNode = 63,\n BraceL = 64,\n DictionaryEntry = 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