Skip to content

Commit 3f93359

Browse files
committed
Correctly calculate contains-the-follow-of
1 parent 9930025 commit 3f93359

File tree

1 file changed

+3
-2
lines changed
  • org.metaborg.sdf2table/src/main/java/org/metaborg/sdf2table/parsetable

1 file changed

+3
-2
lines changed

org.metaborg.sdf2table/src/main/java/org/metaborg/sdf2table/parsetable/ParseTable.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ private void calculateFollow() {
200200
for(Symbol s : symbols) {
201201
for(IProduction p : symbolProductionsMapping.get(s)) {
202202
List<ISymbol> rightHand = p.rightHand();
203-
for(int i = 0, rightHandSize = rightHand.size(); i < rightHandSize; i++) {
203+
i: for(int i = 0, rightHandSize = rightHand.size(); i < rightHandSize; i++) {
204204
ISymbol symbolI = rightHand.get(i);
205205

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

212+
// If Ak ... An are NOT all nullable, continue with next Ai
212213
if(!symbolJ.isNullable())
213-
break;
214+
continue i;
214215
}
215216

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

0 commit comments

Comments
 (0)