Skip to content

Commit

Permalink
Correctly calculate contains-the-follow-of
Browse files Browse the repository at this point in the history
  • Loading branch information
mpsijm committed Jul 18, 2019
1 parent 34f9364 commit a1809ec
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private void calculateFollow() {
for(Symbol s : symbols) {
for(IProduction p : symbolProductionsMapping.get(s)) {
List<ISymbol> rightHand = p.rightHand();
for(int i = 0, rightHandSize = rightHand.size(); i < rightHandSize; i++) {
i: for(int i = 0, rightHandSize = rightHand.size(); i < rightHandSize; i++) {
ISymbol symbolI = rightHand.get(i);

// If p is of the shape A = A0 ... Ai Ak ... Am Aj ... An
Expand All @@ -209,8 +209,9 @@ private void calculateFollow() {
ISymbol symbolJ = rightHand.get(j);
containsTheFirstOf.put(symbolI, symbolJ);

// If Ak ... An are NOT all nullable, continue with next Ai
if(!symbolJ.isNullable())
break;
continue i;
}

// If Ak ... An are all nullable, FOLLOW(Ai) contains FOLLOW(A)
Expand Down

0 comments on commit a1809ec

Please sign in to comment.