# test grammar for slr generator nonterminal S Integer terminal 0 ( ) topsym S S --> 0 { return 1; } S --> ( S ) { return 2; } EOF This grammar generates all strings (((... 0 ...))) with 0 or more pairs of matching parentheses around 0. Output of the my parser generator, SLR version. (fsm defines LR state transition table): FSM with 7 states created state 0: S --> .0 S --> .( S ) START --> .S EOF state 1: S --> 0 . state 2: S --> .0 S --> .( S ) S --> ( .S ) state 3: START --> S .EOF state 4: S --> ( S .) state 5: START --> S EOF . state 6: S --> ( S ) . Nullible Nonterminals: FIRST SETS: S : ( 0 START : ( 0 FOLLOW SETS: S : ) EOF START : Code generated that sets the finite state machine: public void settable() { for(int i=0;i<7;i++) FSM.add(new Hashtable()); FSM.get(0).put("0",new shift(1)); FSM.get(0).put("(",new shift(2)); FSM.get(0).put("S",new gotonext(3)); FSM.get(1).put(")",new reduce(0)); FSM.get(1).put("EOF",new reduce(0)); FSM.get(2).put("0",new shift(1)); FSM.get(2).put("(",new shift(2)); FSM.get(2).put("S",new gotonext(4)); FSM.get(3).put("EOF",new accept()); FSM.get(4).put(")",new shift(6)); FSM.get(6).put(")",new reduce(1)); FSM.get(6).put("EOF",new reduce(1)); } // settable