UNPKG

@amplitude/ampli

Version:

Amplitude CLI

43 lines (42 loc) 1.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const state_1 = require("./state"); class MultilineComment extends state_1.State { constructor(source, prefix, postfix, nesting) { super('comment', source, prefix.length); this.prefix = prefix; this.postfix = postfix; this.nesting = nesting; this.nestingLevel = 0; } visit(fromIndex) { if (this.isPrefix(this.prefix, fromIndex)) { if (this.nesting) { this.nestingLevel += 1; } this.length += this.prefix.length; return this; } if (this.isPrefix(this.postfix, fromIndex)) { if (this.nestingLevel > 0) { this.nestingLevel -= 1; this.length += this.postfix.length; return this; } this.length += this.postfix.length; return undefined; } this.length += 1; return this; } } class MultiLineCommentFactory extends state_1.StateFactory { constructor(source, prefix, postfix, nesting) { super(source, prefix, postfix); this.nesting = nesting; } createState() { return new MultilineComment(this.source, this.prefix, this.postfix, this.nesting); } } exports.default = MultiLineCommentFactory;