1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const Builder_1 = require("./Builder");
|
4 |
|
5 | class GrammarAnnotation extends Builder_1.default {
|
6 | constructor(spec, prod, node) {
|
7 | super(spec, node);
|
8 | this.production = prod;
|
9 | }
|
10 | build() {
|
11 | if (!this.node.firstChild)
|
12 | return;
|
13 | if (this.node.firstChild.nodeType === 3) {
|
14 | this.node.firstChild.textContent = '[' + this.node.firstChild.textContent;
|
15 | }
|
16 | else {
|
17 | const pre = this.spec.doc.createTextNode('[');
|
18 | this.node.insertBefore(pre, this.node.children[0]);
|
19 | }
|
20 | const post = this.spec.doc.createTextNode(']');
|
21 | this.node.appendChild(post);
|
22 | }
|
23 | }
|
24 | exports.default = GrammarAnnotation;
|