From 582dcc13dc2ef4eed29c5eb45ab6bbc51dd72e1b Mon Sep 17 00:00:00 2001 From: Maarten Sijm Date: Mon, 8 Jul 2019 18:12:08 +0200 Subject: [PATCH] Correctly calculate contains-the-follow-of --- .../java/org/metaborg/sdf2table/parsetable/ParseTable.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/org.metaborg.sdf2table/src/main/java/org/metaborg/sdf2table/parsetable/ParseTable.java b/org.metaborg.sdf2table/src/main/java/org/metaborg/sdf2table/parsetable/ParseTable.java index 18d1f8a65..397f28804 100644 --- a/org.metaborg.sdf2table/src/main/java/org/metaborg/sdf2table/parsetable/ParseTable.java +++ b/org.metaborg.sdf2table/src/main/java/org/metaborg/sdf2table/parsetable/ParseTable.java @@ -238,7 +238,7 @@ private void calculateFollow() { for(ISymbol s : symbols) { for(IProduction p : symbolProductionsMapping.get(s)) { List 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 @@ -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)