home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / prolog / pdprolog / rsent.pro < prev    next >
Text File  |  1986-05-05  |  1KB  |  36 lines

  1. read_in([W|Ws]) :- get0(C), readword(C,W,C1), restsent(W,C1,Ws).
  2.  
  3. restsent( W,_,[]) :- lastword(W), !.
  4. restsent(W,C,[W1|Ws]) :- readword(C,W1,C1), restsent(W1,C1,Ws).
  5.  
  6. readword(C,W,C1) :- single_character(C), !, name(W,[C]), get0(C1).
  7. readword(C,W,C2) :-
  8.     in_word(C,NewC), !,
  9.     get0(C1),
  10.     restword(C1,Cs,C2),
  11.     name(W,[NewC|Cs]).
  12. readword(C,W,C2) :- get0(C1), readword(C1,W,C2).
  13.  
  14. restword(C,[NewC|Cs],C2) :-
  15.     in_word(C,NewC), !,
  16.     get0(C1),
  17.     restword(C1,Cs,C2).
  18. restword(C,[],C).
  19.  
  20. single_character(44).  /* , */
  21. single_character(59).  /* ; */
  22. single_character(58).  /* : */
  23. single_character(63).  /* ? */
  24. single_character(33).  /* ! */
  25. single_character(46).  /* . */
  26.  
  27. in_word(C,C) :- C>96, C<123.                /* a b..z */
  28. in_word(C,L) :- C>64, C<91, L is C+32.      /* A,B..Z */
  29. in_word(C,C) :- C>47, C<58.                 /* 1,2,..9 */
  30. in_word(39,39).                             /*  ' */
  31. in_word(45,45).                             /* - */
  32.  
  33. lastword( '.' ).
  34. lastword( '!' ).
  35. lastword( '?' ).
  36.