Prolog recursion grammar
问题 at the moment I am having a problem with looping back to noun_phrase from np2 . I was wondering if someone can help me loop back to noun_phrase . Here is some code: noun_phrase([X|T],(det(X), NP2),Rem):- det(X), np2(T,NP2,Rem). np2([H|T],np2(adj(H),Rest),NP) :- adj(H), np2(T,Rest,Rem), noun_phrase(NP,Rem,_). I want to loop from np2 back to noun_phrase . I think the code for np2 is wrong as I just hacked it together. 回答1: Encoding a grammar directly in Prolog is a quite cumbersome process. Yes