% Grammar 5.7: BH-GRN version of program 5.2
% If loaded after Program C.1, wiil be compiled into a top-down, depth-first DCG.
% Otherwise, can be used with a bottom-up parser.

:-op(1100, xfx, --->).
:-op(1100, xfx, ===>).


s ---> [np(Per, Y), vp(Per, Y)].

np(Per, Y) ---> [pro(Per, Y)].
np(3, Num) ---> [det(Num), nbar(Num)].

nbar(Num) ---> [n(Num)].
nbar(Num) ---> [adj, nbar(Num)].

vp(Per, Y) ---> [vi(Per, Y)].
vp(Per, Y) ---> [vbe(Per, Y), adj].

det(sing) ===> [this].
det(plu) ===> [these].
det(_Num) ===> [the].

n(sing) ===> [knight].
n(plu) ===> [knights].
n(_Num) ===> [sheep].

pro(1, sing) ===> [i].
pro(1, plu) ===> [we].
pro(2, _Num) ===> [you].
pro(3, sing) ===> [it].
pro(3, plu) ===> [they].

adj ===> [tipsy].

vbe(1, sing) ===> [am].
vbe(1, plu) ===> [are].
vbe(2, _Num) ===> [are].
vbe(3, plu) ===> [are].
vbe(3, sing) ===> [is].

vi(_Per, _Num) ===> [slept].
vi(1, _Num) ===> [sleep].
vi(2, _Num) ===> [sleep].
vi(3, plu) ===> [sleep].
vi(3, sing) ===> [sleeps].

