}
*/
- parse(context, position, path) {
- const result = this.#parser.parse(context, position, { parent: path, parser: this.#parser, index: 0 });
+ parse(context, position, path, index) {
+ path = this.makePath(path, index);
+ const result = this.#parser.parse(context, position, path, 0);
if (result.status) {
result.value = this.#mapper(result.value);
}
@@ -1872,15 +2037,12 @@ class MapParser extends Parser {
/**
* @protected
* @param {Context} context
- * @param {Number} indent
+ * @param {String} indentation
* @param {PathNode} path
+ * @param {Number} index
*/
- doToString(context, indent, path) {
- const childrenPath = { parent: path, parser: this.#parser, index: 0 };
- if (this.isHighlighted(context, path)) {
- context.highlighted = context.highlighted instanceof Parser ? this.#parser : childrenPath;
- }
- let result = this.#parser.toString(context, indent, childrenPath);
+ doToString(context, indentation, path, index) {
+ let result = this.#parser.toString(context, indentation, path, 0);
if (this.#parser instanceof RegExpParser) {
if (Object.values(RegExpParser.common).includes(this.#parser.regexp)) {
if (
@@ -1896,8 +2058,7 @@ class MapParser extends Parser {
if (serializedMapper.length > 60 || serializedMapper.includes("\n")) {
serializedMapper = "(...) => { ... }";
}
- serializedMapper = ` -> map<${serializedMapper}>`;
- result = Parser.appendBeforeHighlight(result, serializedMapper);
+ result += ` -> map<${serializedMapper}>`;
return result
}
}
@@ -1945,16 +2106,14 @@ class SequenceParser extends Parser {
* @param {Context} context
* @param {Number} position
* @param {PathNode} path
+ * @param {Number} index
*/
- parse(context, position, path) {
+ parse(context, position, path, index) {
+ path = this.makePath(path, index);
const value = /** @type {ParserValue