-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
The following test problem shows a missing reduce on $ (EOF) for state 0.
Grammar:
S -> a
S -> epsilon
I'll create a pull request with fix.
import util.*;
import lr0.*;
import lr1.*;
public class TestLR
{
public static void main(String[] args) {
String g = "S -> a\n" +
"S -> epsilon\n";
LR0Parser lr0Parser = new LR0Parser(new Grammar(g));
if (lr0Parser.parserSLR1()) {
System.out.println(lr0Parser.actionTableStr());
System.out.println(lr0Parser.goToTableStr());
}
else {
System.out.println("parse not ok");
}
}
}$ java TestLR
Rules:
0 : S' -> S
1 : S -> a
2 : S -> epsilon
Action Table :
a $
--------------------------------
|0 | SHIFT 2| |
--------------------------------
|1 | | REDUCE 2|
--------------------------------
|2 | | REDUCE 1|
--------------------------------
|3 | | ACCEPT |
--------------------------------
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels