home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l216 / 2.ddi / XMINIGOL.PRO < prev    next >
Encoding:
Text File  |  1987-03-23  |  3.8 KB  |  177 lines

  1. /***************************************************************
  2.      Turbo Prolog Toolbox
  3.      (C) Copyright 1987 Borland International.
  4. ***************************************************************/
  5.  
  6.  
  7. code=4000
  8. include "tdoms.pro"
  9.  
  10. DOMAINS
  11.   CURSOR = INTEGER
  12.   PROCID = STRING
  13.  
  14. DATABASE
  15.   source(STRING)
  16.   filename(STRING)
  17.   pdwstate(ROW,COL,SYMBOL,ROW,COL)
  18.   insmode
  19.   lineinpstate(STRING,COL)
  20.   lineinpflag
  21.   error(STRING,CURSOR)
  22.  
  23. include "tpreds.pro"
  24. include "status.pro"
  25. include "pulldown.pro"
  26. include "lineinp.pro"
  27. include "filename.pro"
  28.  
  29. include "xminigol.dom"
  30.  
  31. PREDICATES
  32.   scan_error(STRING,CURSOR)
  33.  
  34. include "xminigol.sca"
  35.  
  36. PREDICATES
  37.   strlist_str(STRINGLIST,STRING)
  38.   ed(STRING,CURSOR)
  39.   change(DBASEDOM)
  40.   resetflags
  41.   nondeterm repparse
  42.   parse
  43.   better_error(CURSOR)
  44.   new_error(STRING,CURSOR)
  45.  
  46. PREDICATES
  47.   expect(CURSORTOK,TOKL,TOKL)
  48.   syntax_error(STRING,TOKL)
  49.   checkempty(TOKL)
  50.  
  51. include "xminigol.par"
  52.  
  53. CLAUSES
  54.   better_error(CURSOR):-
  55.     error(_,OLDCURSOR),OLDCURSOR>=CURSOR,!,fail.
  56.   better_error(_).
  57.  
  58.   new_error(_,_):-retract(error(_,_)),fail.
  59.   new_error(MSG,CURSOR):-assert(error(MSG,CURSOR)).
  60.  
  61.   expect(TOK,[TOK|L],L):-!.
  62.   expect(t(TOK,_),[t(_,CURSOR)|_],_):-
  63.     better_error(CURSOR),
  64.     str_tok(STR,TOK),
  65.     concat(STR," expected",MSG),
  66.     new_error(MSG,CURSOR),fail.
  67.  
  68.   syntax_error(PROD,[t(_,CURSOR)|_]):-
  69.     better_error(CURSOR),
  70.     concat("Syntax error in ",PROD,MSG),
  71.     new_error(MSG,CURSOR),fail.
  72.  
  73.   scan_error(MSG,CURSOR):-ed(MSG,CURSOR),fail.
  74.  
  75.   checkempty([]):-!.
  76.   checkempty([t(_,CURSOR)|_]):-
  77.     better_error(CURSOR),
  78.     new_error("Syntax error",CURSOR).
  79.  
  80.   strlist_str([],"").
  81.   strlist_str([H|T],STR):-
  82.     concat(H," ",H1),
  83.     strlist_str(T,STR1),
  84.     concat(H1,STR1,STR).
  85.  
  86.   ed(MSG,CURSOR):-
  87.     source(TXT),
  88.     editmsg(TXT,TXT1,"","",MSG,CURSOR,"",RET),
  89.     RET><1,!,
  90.     change(source(TXT1)).
  91.  
  92.   resetflags:-retract(error(_,_)),fail.
  93.   resetflags.
  94.  
  95.   change(source(_)):-retract(source(_)),fail.
  96.   change(filename(_)):-retract(filename(_)),fail.
  97.   change(X):-assert(X).
  98.  
  99.   repparse.
  100.   repparse:-error(MSG,CURSOR),ed(MSG,CURSOR),!,repparse.
  101.  
  102.  
  103.   parse:-
  104.     repparse,
  105.     resetflags,
  106.     source(STR1),
  107.     tokl(0,STR1,L),
  108.     s_sent(L,L1,X),
  109.     checkempty(L1),!,
  110.     makewindow(2,23,23,"",0,0,25,80),
  111.     write(X),
  112.     readkey(_),
  113.     removewindow.
  114.   parse:-
  115.     write(">> Parsing aborted"),nl,beep.
  116.  
  117.   pdwaction(1,0):-
  118.     shiftwindow(OLD),shiftwindow(1),
  119.     parse,
  120.     shiftwindow(OLD),
  121.     refreshstatus.
  122.   pdwaction(2,0):-
  123.     shiftwindow(OLD),shiftwindow(1),
  124.     source(TXT),
  125.     editmsg(TXT,TXT1,"","","",0,"",RET),
  126.     shiftwindow(OLD),
  127.     RET><1,!,
  128.     change(source(TXT1)),
  129.     refreshstatus.
  130.   pdwaction(2,0):-refreshstatus.
  131.   pdwaction(3,1):-
  132.     readfilename(5,40,66,66,txt,"",NEW),
  133.     change(filename(NEW)),
  134.     file_str(NEW,NEWSOURCE),!,
  135.     change(source(NEWSOURCE)),
  136.     shiftwindow(OLDW),
  137.     shiftwindow(1),
  138.     window_str(NEWSOURCE),
  139.     shiftwindow(OLDW),
  140.     refreshstatus.
  141.   pdwaction(3,1).
  142.   pdwaction(3,2):-
  143.     source(SOURCE),
  144.     filename(OLD),
  145.     readfilename(5,40,66,66,txt,OLD,NEW),
  146.     change(filename(NEW)),
  147.     file_str(NEW,SOURCE),
  148.     refreshstatus,!.
  149.   pdwaction(3,2).
  150.   pdwaction(3,3):-setdir(5,40,66,66).
  151.   pdwaction(4,0):-
  152.     lineinput(5,70,40,66,66,"Are you sure (y/n) ? ","",ANS),
  153.     upper_lower(ANS,ANS1),
  154.     ANS1><"y".
  155.  
  156.  
  157.   filename("minigol.txt").
  158.   source("").
  159.  
  160. GOAL
  161.  
  162. /*
  163.           1         2         3         4         5         6         7
  164. 01234567890123456789012345678901234567890123456789012345678901234567890123456789
  165.        COMPILE            EDIT              FILES               QUIT
  166. */
  167.   makewindow(1,23,23,"Edit",3,0,21,80),
  168.   makestatus(112," Select with arrows or use first upper case letter"),
  169.   pulldown(66,
  170.       [ curtain(7,"Compile",[]),
  171.         curtain(26,"Edit",[]),
  172.         curtain(44,"Files",["Load","Save","Dir"]),
  173.             curtain(64,"Quit"      ,[])
  174.           ],_,_).
  175.  
  176.  
  177.