| 154 | // The VPT class constructor initializes with an optional matcher or patterns, always invoking 'begin' for the matcher and only for patterns matching the root pattern. |
| 155 | // Note: Instances of VPT with a matcher or patterns cannot be shared; VPT constructor must execute for each new parser. |
| 156 | constructor(options) { |
| 157 | if (options === undefined) |
| 158 | throw new Error("invalid options"); |
| 159 | this.node = this.makeNode(NodeType.root); |
| 160 | this.matcher = options.matcher; |
| 161 | this.patterns = options.patterns; |
| 162 | this.doEvent("onBegin"); |
| 163 | } |
| 164 | |
| 165 | // Execute 'matcher events' unconditionally and 'pattern events' selectively when nodes match a pattern. |
| 166 | doEvent(event) { |