Skip to content

Commit 084742e

Browse files
committed
Use new EOFSymbol in SLR parsing
This EOFSymbol was introduced when changing the EOF value from 256 to -1
1 parent c355713 commit 084742e

File tree

1 file changed

+7
-0
lines changed
  • org.metaborg.sdf2table/src/main/java/org/metaborg/sdf2table/parsetable

1 file changed

+7
-0
lines changed

org.metaborg.sdf2table/src/main/java/org/metaborg/sdf2table/parsetable/ParseTable.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
import com.google.common.collect.*;
1818

19+
import static org.metaborg.parsetable.characterclasses.CharacterClassFactory.EOF_SINGLETON;
20+
1921
public class ParseTable implements IParseTable, Serializable {
2022

2123
// FIXME Currently generating an LR(0) table, compute first/follow sets to generate SLR(1)
@@ -198,6 +200,11 @@ private void calculateFirst() {
198200
s.setFirst(((CharacterClassSymbol) s).getCC());
199201
continue;
200202
}
203+
// The FIRST set of an EOFSymbol is equal to the EOF singleton character class.
204+
if(s instanceof EOFSymbol) {
205+
s.setFirst(EOF_SINGLETON);
206+
continue;
207+
}
201208

202209
for(IProduction p : symbolProductionsMapping.get(s)) {
203210
// Direct contributions:

0 commit comments

Comments
 (0)