Skip to content

Commit

Permalink
Use new EOFSymbol in SLR parsing
Browse files Browse the repository at this point in the history
This EOFSymbol was introduced when changing the EOF value from 256 to -1
  • Loading branch information
mpsijm committed Apr 30, 2021
1 parent d0c829c commit a18f39f
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit a18f39f

Please sign in to comment.