From ddc67847b742ff6d2f8e0c75757297d24d2d382a 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 be31c67c6..8052b45c2 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 @@ -235,7 +235,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 @@ -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)