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 Nov 4, 2019
1 parent 095c3f1 commit ddc6784
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,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 @@ -244,8 +244,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 ddc6784

Please sign in to comment.