* Consume and return the plain //getCurrentToken current symbol. * * E.g., given the following input with A being the current * lookahead symbol, this function moves the cursor to B and returns * A. * * * A B * ^
()
| 340 | * listeners. |
| 341 | */ |
| 342 | consume() { |
| 343 | const o = this.getCurrentToken(); |
| 344 | if (o.type !== Token.EOF) { |
| 345 | this.getInputStream().consume(); |
| 346 | } |
| 347 | const hasListener = this._parseListeners !== null && this._parseListeners.length > 0; |
| 348 | if (this.buildParseTrees || hasListener) { |
| 349 | let node; |
| 350 | if (this._errHandler.inErrorRecoveryMode(this)) { |
| 351 | node = this._ctx.addErrorNode(o); |
| 352 | } else { |
| 353 | node = this._ctx.addTokenNode(o); |
| 354 | } |
| 355 | node.invokingState = this.state; |
| 356 | if (hasListener) { |
| 357 | this._parseListeners.forEach(function (listener) { |
| 358 | if (node instanceof ErrorNode || (node.isErrorNode !== undefined && node.isErrorNode())) { |
| 359 | listener.visitErrorNode(node); |
| 360 | } else if (node instanceof TerminalNode) { |
| 361 | listener.visitTerminal(node); |
| 362 | } |
| 363 | }); |
| 364 | } |
| 365 | } |
| 366 | return o; |
| 367 | } |
| 368 | |
| 369 | addContextToParseTree() { |
| 370 | // add current context to parent if we have a parent |
no test coverage detected