From f9083b1df9456d007364f59a1109d90448a72ff7 Mon Sep 17 00:00:00 2001 From: Maarten Sijm Date: Tue, 25 Feb 2020 20:44:21 +0100 Subject: [PATCH] Use new EOFSymbol in SLR parsing This EOFSymbol was introduced when changing the EOF value from 256 to -1 --- .../java/org/metaborg/sdf2table/parsetable/ParseTable.java | 7 +++++++ 1 file changed, 7 insertions(+) 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 cdf17be7d..e0d51e4ef 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 @@ -16,6 +16,8 @@ import com.google.common.collect.*; +import static org.metaborg.parsetable.characterclasses.CharacterClassFactory.EOF_SINGLETON; + public class ParseTable implements IParseTable, Serializable { // FIXME Currently generating an LR(0) table, compute first/follow sets to generate SLR(1) @@ -198,6 +200,11 @@ private void calculateFirst() { s.setFirst(((CharacterClassSymbol) s).getCC()); continue; } + // The FIRST set of an EOFSymbol is equal to the EOF singleton character class. + if(s instanceof EOFSymbol) { + s.setFirst(EOF_SINGLETON); + continue; + } for(IProduction p : symbolProductionsMapping.get(s)) { // Direct contributions: