private LookAheadSet FindConflicts(ProductionPattern pattern, int maxLength) { LookAheadSet result = new LookAheadSet(maxLength); for (int i = 0; i < pattern.Count; i++) { var set1 = pattern[i].LookAhead; for (int j = 0; j < i; j++) { var set2 = pattern[j].LookAhead; result.AddAll(set1.CreateIntersection(set2)); } } if (result.IsRepetitive()) { ThrowAmbiguityException(pattern.Name, null, result); } return(result); }