Skip to content

Commit 6f513b7

Browse files
committed
Correctly calculate contains-the-follow-of
1 parent 216e13b commit 6f513b7

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ private void calculateFollow() {
235235
for(ISymbol s : symbols) {
236236
for(IProduction p : symbolProductionsMapping.get(s)) {
237237
List<ISymbol> rightHand = p.rightHand();
238-
for(int i = 0, rightHandSize = rightHand.size(); i < rightHandSize; i++) {
238+
i: for(int i = 0, rightHandSize = rightHand.size(); i < rightHandSize; i++) {
239239
ISymbol symbolI = rightHand.get(i);
240240

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

247+
// If Ak ... An are NOT all nullable, continue with next Ai
247248
if(!symbolJ.isNullable())
248-
break;
249+
continue i;
249250
}
250251

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

0 commit comments

Comments
 (0)