% file: bup2--for possessive NPs in English
% query: parse([my,father,s,mother,s,brother])?

% interface
parse(S) :- bup(lex,_,np,S,[]).

% exit condition
bup(Goal, _, Goal,S,S) :- !.

% lexical rules
bup(lex, noun, Goal,[sister|S1], S) :-
    bup(noun, _, Goal,S1,S).

bup(lex, noun, Goal,[brother|S1], S) :-
    bup(noun, _, Goal,S1,S).

bup(lex, noun, Goal,[mother|S1], S) :-
    bup(noun, _, Goal,S1,S).

bup(lex, noun, Goal,[father|S1], S) :-
    bup(noun, _, Goal,S1,S).

bup(lex, poss, Goal,[s|S1], S) :-
    bup(poss, _, Goal,S1,S).

bup(lex, det, Goal, [my|S1], S) :-
   bup(det, _, Goal, S1, S).

% non-terminal rules   
% corresponds to np --> det, noun 
bup(det, np, Goal, S0, S) :-
    bup(lex, _ ,noun, S0, S1),
    bup(np, _, Goal, S1, S).

% corresponds to det --> np, poss
bup(np, det, Goal, S0, S) :-
    bup(lex, _, poss, S0, S1),
    bup(det, _, Goal, S1, S).

