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 24, 2020
1 parent e0a6d3a commit 3eb3c6e
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,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 @@ -272,8 +272,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 3eb3c6e

Please sign in to comment.