message: Avoid infinite loops during validations caused by left recursion
diff: @@ -14,14 +14,24 @@ import {tokenName, tokenLabel} from "../../scan/tokens_public"
  import {first} from "./first"
  import {containsPath, getLookaheadPathsForOr, Alternative} from "./lookahead"
  import {VERSION} from "../../version"
  +import {isEmpty} from "../../utils/utils"
  +import {every} from "../../utils/utils"
  export function validateGrammar(topLevels:gast.Rule[], maxLookahead:number, ignoredIssues:IgnoredParserIssues):IParserDefinitionError[] {
  let duplicateErrors:any = utils.map(topLevels, validateDuplicateProductions)
  let leftRecursionErrors:any = utils.map(topLevels, currTopRule => validateNoLeftRecursion(currTopRule, currTopRule))
  - let emptyAltErrors = map(topLevels, validateEmptyOrAlternative)
  - let ambiguousAltsErrors = map(topLevels, currTopRule =>
  +
  + let emptyAltErrors = []
  + let ambiguousAltsErrors = []
  +
  + // left recursion could cause infinite loops in the following validations.
  + // It is safest to first have the user fix the left recursion errors first and only then examine farther issues.
  + if (every(leftRecursionErrors, isEmpty)) {
  + emptyAltErrors = map(topLevels, validateEmptyOrAlternative)
  + ambiguousAltsErrors = map(topLevels, currTopRule =>
  validateAmbiguousAlternationAlternatives(currTopRule, maxLookahead, ignoredIssues))
  + }
  return <any>utils.flatten(duplicateErrors.concat(leftRecursionErrors, emptyAltErrors, ambiguousAltsErrors))
  }
  