home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l216 / 2.ddi / XPARS.SCA < prev    next >
Encoding:
Text File  |  1987-03-23  |  991 b   |  39 lines

  1. /***********************************************************
  2.  
  3.           Turbo Prolog Toolbox
  4.           (C) Copyright 1987 Borland International.
  5. ***********************************************************/          
  6.  
  7.  
  8. /* remove the comments around the include directive below, in */
  9. /* order to run XPARS.SCA as a stand alone program.           */
  10.  
  11. /* include "xpars.dom" */
  12.  
  13. domains
  14.   ttok = t(tok,integer)
  15.   tokl = ttok*
  16.  
  17. predicates
  18.   tokl(string,tokl)
  19.   maketok(string,tok,string,string)
  20.   str_tok(string,tok)
  21.  
  22. clauses
  23.   tokl(STR,[t(TOK,0)|TOKL]):-
  24.         fronttoken(STR,STRTOK,STR1),!,
  25.         maketok(STRTOK,TOK,STR1,STR2),
  26.         tokl(STR2,TOKL).
  27.   tokl(_,[]).
  28.  
  29.   str_tok("+",plus):-!.
  30.   str_tok("-",minus):-!.
  31.   str_tok("*",mult):-!.
  32.   str_tok("/",div):-!.
  33.   str_tok("^",power):-!.
  34.  
  35.   maketok(STR,TOK,S,S):-str_tok(STR,TOK),!.
  36.   maketok(INTSTR,int(INTEGER),S,S):-str_int(INTSTR,INTEGER),!.
  37.   maketok(STRING,id(STRING),S,S):-isname(STRING),!.
  38.  
  39.