home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l210 / 1.ddi / EXAMPLES.ARC / CH12EX04.PRO < prev    next >
Encoding:
Prolog Source  |  1988-06-21  |  787 b   |  27 lines

  1. /*
  2.    Turbo Prolog 2.0 Chapter 12, Example Program 4
  3.    
  4.    Copyright (c) 1986, 88 by Borland International, Inc
  5.    
  6. */
  7.    
  8. domains
  9.    sentence   = sentence(nounphrase, verbphrase)
  10.    nounphrase = nounp(article, noun); name(name)
  11.    verbphrase = verb(verb); verbphrase(verb, nounphrase)
  12.    article, noun, name, verb = symbol
  13.  
  14. predicates
  15.    write_sentence(sentence)
  16.    write_nounphrase(nounphrase)
  17.    write_verbphrase(verbphrase)
  18.  
  19. clauses
  20.    write_sentence(sentence(S, V)) :-
  21.       write_nounphrase(S) , write_verbphrase(V).
  22.    write_nounphrase(nounp(A, N)) :- write(A, ' ', N, ' ').
  23.    write_nounphrase(name(N)) :- write(N, ' ').
  24.    write_verbphrase(verb(V)) :- write(V, ' ').
  25.    write_verbphrase(verbphrase(V, N)) :-
  26.       write(V, ' ') , write_nounphrase(N).
  27.