This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/Logtalk/examples/dcgs/parsetree.lgt
pmoura f1b417f1c3 Logtalk 2.15.2 files.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@812 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
2003-04-02 13:57:50 +00:00

30 lines
520 B
Plaintext

:- object(parsetree,
implements(parsep)).
parse(List, Tree) :-
phrase(sentence(Tree), List).
sentence(s(NP,VP)) --> noun_phrase(NP), verb_phrase(VP).
noun_phrase(np(D,NP)) --> determiner(D), noun(NP).
noun_phrase(NP) --> noun(NP).
verb_phrase(vp(V)) --> verb(V).
verb_phrase(vp(V,NP)) --> verb(V), noun_phrase(NP).
determiner(d(the)) --> [the].
determiner(d(a)) --> [a].
noun(n(boy)) --> [boy].
noun(n(girl)) --> [girl].
verb(v(likes)) --> [likes].
verb(v(hates)) --> [hates].
:- end_object.