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 Feb 25, 2020
1 parent 589e581 commit 582dcc1
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ private void calculateFollow() {
for(ISymbol 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 @@ -247,8 +247,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 582dcc1

Please sign in to comment.