From a1809ecf523d8f49759bd5716f4113337f970c44 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 431d72fed..7c1b0eb40 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 @@ -200,7 +200,7 @@ private void calculateFollow() { for(Symbol 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 @@ -209,8 +209,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)