message: Small refactor of recognizer_engine for better readability
  and making it easier for V8 to inline some hot spots.
diff: @@ -870,19 +870,28 @@ export class RecognizerEngine {
  )
  return ruleResult
  } catch (e) {
  + this.subruleInternalError(e, options, (<any>ruleToCall).ruleName)
  + }
  + }
  +
  + subruleInternalError(
  + this: MixedInParser,
  + e: any,
  + options: SubruleMethodOpts,
  + ruleName: string
  + ): void {
  if (isRecognitionException(e) && e.partialCstResult !== undefined) {
  this.cstPostNonTerminal(
  e.partialCstResult,
  options !== undefined && options.LABEL !== undefined
  ? options.LABEL
  - : (<any>ruleToCall).ruleName
  + : ruleName
  )
  delete e.partialCstResult
  }
  throw e
  }
  - }
  consumeInternal(
  this: MixedInParser,
  @@ -897,6 +906,31 @@ export class RecognizerEngine {
  this.consumeToken()
  consumedToken = nextToken
  } else {
  + this.consumeInternalError(tokType, nextToken, options)
  + }
  + } catch (eFromConsumption) {
  + consumedToken = this.consumeInternalRecovery(
  + tokType,
  + idx,
  + eFromConsumption
  + )
  + }
  +
  + this.cstPostTerminal(
  + options !== undefined && options.LABEL !== undefined
  + ? options.LABEL
  + : tokType.tokenName,
  + consumedToken
  + )
  + return consumedToken
  + }
  +
  + consumeInternalError(
  + this: MixedInParser,
  + tokType: TokenType,
  + nextToken: IToken,
  + options: ConsumeMethodOpts
  + ): void {
  let msg
  let previousToken = this.LA(0)
  if (options !== undefined && options.ERR_MSG) {
  @@ -913,7 +947,13 @@ export class RecognizerEngine {
  new MismatchedTokenException(msg, nextToken, previousToken)
  )
  }
  - } catch (eFromConsumption) {
  +
  + consumeInternalRecovery(
  + this: MixedInParser,
  + tokType: TokenType,
  + idx: number,
  + eFromConsumption: Error
  + ): IToken {
  // no recovery allowed during backtracking, otherwise backtracking may recover invalid syntax and accept it
  // but the original syntax could have been parsed successfully without any backtracking + recovery
  if (
  @@ -922,19 +962,11 @@ export class RecognizerEngine {
  eFromConsumption.name === "MismatchedTokenException" &&
  !this.isBackTracking()
  ) {
  - let follows = this.getFollowsForInRuleRecovery(
  - <any>tokType,
  - idx
  - )
  + let follows = this.getFollowsForInRuleRecovery(<any>tokType, idx)
  try {
  - consumedToken = this.tryInRuleRecovery(
  - <any>tokType,
  - follows
  - )
  + return this.tryInRuleRecovery(<any>tokType, follows)
  } catch (eFromInRuleRecovery) {
  - if (
  - eFromInRuleRecovery.name === IN_RULE_RECOVERY_EXCEPTION
  - ) {
  + if (eFromInRuleRecovery.name === IN_RULE_RECOVERY_EXCEPTION) {
  // failed in RuleRecovery.
  // throw the original error in order to trigger reSync error recovery
  throw eFromConsumption
  @@ -947,15 +979,6 @@ export class RecognizerEngine {
  }
  }
  - this.cstPostTerminal(
  - options !== undefined && options.LABEL !== undefined
  - ? options.LABEL
  - : tokType.tokenName,
  - consumedToken
  - )
  - return consumedToken
  - }
  -
  saveRecogState(this: MixedInParser): IParserState {
  // errors is a getter which will clone the errors array
  let savedErrors = this.errors
  