:- op(1150, xfx, '--->').

% sr_parse(Words, Startsymbol)
sr_parse(W, S):-
   sr_parse([], W, S).

% Ok, if no more words 
% and startsymbol on stack
sr_parse([S], [], S).

% Reduce Stack by one rule
sr_parse([V2,V1|Stack], W, S):-
   (LHS ---> (V1,V2)),
   sr_parse([LHS|Stack], W, S).

% Consume word and shift its cat on stack
sr_parse(Stack,[W1|W],S):-
   (LHS ---> [W1]),
   sr_parse([LHS|Stack], W, S).
