// SPDX-License-Identifier: Apache-2.0
import { ConfigKeyError } from '../config-key-error.js';
import { ConfigKeyFormatter } from '../config-key-formatter.js';
export class LexerNode {
    parent;
    name;
    formatter;
    constructor(parent, name, formatter = ConfigKeyFormatter.instance()) {
        this.parent = parent;
        this.name = name;
        this.formatter = formatter;
        if (parent && !parent.isInternal()) {
            throw new ConfigKeyError('Parent must be an instance of InternalNode');
        }
    }
    path() {
        const segments = [];
        // eslint-disable-next-line @typescript-eslint/no-this-alias
        let node = this;
        while (node) {
            segments.push(node.name);
            node = node.parent;
        }
        segments.reverse();
        return this.formatter.join(...segments);
    }
}
//# sourceMappingURL=lexer-node.js.map