/*******************************************************/ /* Very simple PSG with no semantics */ /*******************************************************/ :- multifile '--->'/2. % Sicstus 3 :- op(1200,xfx,--->). % Comma is op(1000,xfy,','). /*******************************************************/ /* Interface for bottom-up chart parser/generator */ /*******************************************************/ string(Category, Category). semantics(Category, [Category]). lookup_word(Word, Category) :- (Category ---> [Word]), !. lookup_word(Word, Category) :- write('unknown word: '),write(Word),nl,fail. lookup_term(Category, Word, Category) :- (Category ---> [Word]). empty_sem(empty, empty). /*******************************************************/ /* Interface for tree printer */ /*******************************************************/ format_tree_node(Node, Functor) :- functor(Node, Functor, _). portray(X) :- write(X). /*******************************************************/ /* Grammar */ /*******************************************************/ s ---> np, vp. np ---> n. np ---> d, n. np ---> d, ap, n. np ---> d, n, pp. np ---> d, ap, n, pp. vp ---> v. vp ---> v, np. vp ---> v, pp. vp ---> v, np, pp. pp ---> p, np. ap ---> a. ap ---> a, ap. d ---> [the]. d ---> [some]. a ---> [big]. a ---> [brown]. a ---> [old]. n ---> [birds]. n ---> [fleas]. n ---> [dog]. n ---> [hunter]. v ---> [attack]. v ---> [ate]. v ---> [watched]. p ---> [for]. p ---> [beside]. p ---> [with].