call method

FirstFollowResult call(
  1. ProductionsMap productions, [
  2. String startSymbol = ''
])

With a given ProductionsMap and startSymbol, the algorithm starts to calculate the first and follow sets

Implementation

FirstFollowResult call(
  ProductionsMap productions, [
  String startSymbol = '',
]) {
  firstList.clear();
  followList.clear();
  followList[startSymbol] = <String>{"'\$'"};
  for (final entry in productions.entries) {
    itProduces(entry.key, entry.value);
    firstOf(entry.key, productions, firstList);
  }
  followLoop:
  for (final entry in productions.entries) {
    if (entry.key == startSymbol) {
      continue followLoop;
    }
    followOf(
      entry.key,
      productions,
      followList: followList,
      hasToo: <String>{},
      firstList: firstList,
      allProducers: allProducers,
    );
  }
  return FirstFollowResult(firstList, followList);
}