% Compiled version of the shift-reduce parser
% progcsr.pl

sr_parse([Stack], [Stack], Input, Input).

sr_parse([vp, np | Cats], RS, I, RI) :- 
   sr_parse([s | Cats], RS, I, RI).

sr_parse([np, v | Cats], RS, I, RI) :- 
   sr_parse([vp | Cats], RS, I, RI).

sr_parse([v | Cats], RS, I, RI) :- 
   sr_parse([vp | Cats], RS, I, RI).


sr_parse(Cats, RS, [toby|X], RI) :- 
   sr_parse([np | Cats], RS, X, RI).

sr_parse(Cats, RS, [scotch|X], RI) :- 
   sr_parse([np | Cats], RS, X, RI).

sr_parse(Cats, RS, [drinks|X], RI) :- 
   sr_parse([np | Cats], RS, X, RI).

sr_parse(Cats, RS, [drinks|X], RI) :- 
   sr_parse([v | Cats], RS, X, RI).

parse(Input, Start) :-
   sr_parse([], [Start], Input, []).