home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume23 / lome / part03 < prev    next >
Encoding:
Internet Message Format  |  1991-01-08  |  50.1 KB

  1. Path: j.cc.purdue.edu!mentor.cc.purdue.edu!noose.ecn.purdue.edu!samsung!zaphod.mps.ohio-state.edu!wuarchive!uunet!papaya.bbn.com!rsalz
  2. From: rsalz@bbn.com (Rich Salz)
  3. Newsgroups: comp.sources.unix
  4. Subject: v23i053:  Line oriented macro processor, Part03/09
  5. Message-ID: <3028@litchi.bbn.com>
  6. Date: 29 Nov 90 17:41:43 GMT
  7. Organization: BBN Systems and Technologies, Cambridge MA
  8. Lines: 1921
  9. Approved: rsalz@uunet.UU.NET
  10.  
  11. Submitted-by: Darren New <new@ee.udel.edu>
  12. Posting-number: Volume 23, Issue 53
  13. Archive-name: lome/part03
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 3 (of 9)."
  22. # Contents:  LOME/Iparse.c LOME/LOME0.c LOME/LOME1.c LOME/LOME3.c
  23. #   LOME/LOME6.c LOME/MIOtest.c LOME/MacroIO.doc LOME/MacroIO.h
  24. #   LOME/SCM.mac
  25. # Wrapped by new@estelle.ee.udel.edu on Tue Aug 14 16:09:57 1990
  26. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  27. if test -f 'LOME/Iparse.c' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'LOME/Iparse.c'\"
  29. else
  30. echo shar: Extracting \"'LOME/Iparse.c'\" \(5323 characters\)
  31. sed "s/^X//" >'LOME/Iparse.c' <<'END_OF_FILE'
  32. X/*
  33. X * Iparse.c
  34. X * SCM Interpreter code file
  35. X * Copyright 1988 Darren New.
  36. X * All rights reserved.
  37. X */
  38. X
  39. X#include "PPL.h"
  40. X#include "TFS.h"
  41. X#include "MacroIO.h"
  42. X
  43. X#include "Interp.h"
  44. X
  45. Xshort zero = '0',
  46. X      HeadParm = '$',
  47. X      HeadEOL = '.';
  48. X
  49. Xstruct macdef {
  50. X    funcpnt execfunc;
  51. X    str matchstr;
  52. X    funcpnt initfunc;
  53. X    };
  54. X
  55. Xstatic struct macdef macro[] = {
  56. X    Ebp,       "BEGIN PROGRAM",        Ibp,     /*  0 */
  57. X    Eep,       "END PROGRAM",          Iep,     /*  1 */
  58. X    Ebmr,      "BEGIN MAIN ROUTINE",   Ibmr,    /*  2 */
  59. X    Eemr,      "END MAIN ROUTINE",     Iemr,    /*  3 */
  60. X    Ebs,       "BEGIN SUBROUTINE $",   Ibs,     /*  4 */
  61. X    Ees,       "END SUBROUTINE $",     Ies,     /*  5 */
  62. X    El,        "LABEL $$",             Il,      /*  6 */
  63. X    Ecd,       "CHRDATA $$ $ $ $$",    Icd,     /*  7 */
  64. X    End,       "NUMDATA $$ $ $$ $$",   Ind,     /*  8 */
  65. X    Es,        "STOP $",               0,       /*  9 */
  66. X    Ec,        "CALL $",               0,       /* 10 */
  67. X    Egm,       "GET $ = MEM $",        0,       /* 11 */
  68. X    Epm,       "PUT MEM $ = $",        0,       /* 12 */
  69. X    Ef,        "FLG $ = $",            0,       /* 13 */
  70. X    Epv,       "PTR $ = VAL $",        0,       /* 14 */
  71. X    Evp,       "VAL $ = PTR $",        0,       /* 15 */
  72. X    Eva,       "VAL $ = $ + $",        0,       /* 16 */
  73. X    Evs,       "VAL $ = $ - $",        0,       /* 17 */
  74. X    Epa,       "PTR $ = $ + $",        0,       /* 18 */
  75. X    Eps,       "PTR $ = $ - $",        0,       /* 19 */
  76. X    Ept,       "PTR $ = $ * $",        0,       /* 20 */
  77. X    Epd,       "PTR $ = $ / $",        0,       /* 21 */
  78. X    Empb,      "MOV PTR $ BY $",       0,       /* 22 */
  79. X    Et,        "TO $$",                0,       /* 23 */
  80. X    Etife,     "TO $$ IF FLG $ EQ $",  0,       /* 24 */
  81. X    Etifn,     "TO $$ IF FLG $ NE $",  0,       /* 25 */
  82. X    Etive,     "TO $$ IF VAL $ EQ $",  0,       /* 26 */
  83. X    Etivn,     "TO $$ IF VAL $ NE $",  0,       /* 27 */
  84. X    Etipe,     "TO $$ IF PTR $ EQ $",  0,       /* 28 */
  85. X    Etipn,     "TO $$ IF PTR $ NE $",  0,       /* 29 */
  86. X    Etipl,     "TO $$ IF PTR $ LT $",  0,       /* 30 */
  87. X    Er,        "REWIND $",             0,       /* 31 */
  88. X    Egb,       "GET BUFF $",           0,       /* 32 */
  89. X    Epb,       "PUT BUFF $",           0,       /* 33 */
  90. X    Evi,       "VAL $ = INPUT",        0,       /* 34 */
  91. X    Eov,       "OUTPUT = VAL $",       0,       /* 35 */
  92. X    Edebug,    "DEBUG",                0,       /* 36 */
  93. X    Emt,       "MESSAGE $$$$ TO $",    0,       /* 37 */
  94. X    0, 0, 0 };
  95. X
  96. X
  97. X
  98. Xstatic char * source[MAXSRC];    /* the source file */
  99. X
  100. X
  101. Xstatic short findmacro(char *);
  102. Xstatic short findmacro(inpline)
  103. X    char * inpline;
  104. X{
  105. X    short m;
  106. X    register short c;
  107. X    short p;
  108. X    register char * s;
  109. X
  110. X    m = 0;
  111. X    while (s = macro[m].matchstr) {
  112. X    c = 0; p = 0;
  113. X    while (1) {
  114. X        if (s[c] == HeadParm) {
  115. X        if (inpline[c] != EOS)
  116. X            param[p++] = inpline[c++];
  117. X        else { m += 1; break; }
  118. X        }
  119. X        else if (s[c] == inpline[c]) {
  120. X        if (s[c] == EOS) {
  121. X            param[p] = EOS;
  122. X            return m;
  123. X            }
  124. X        else
  125. X            c += 1;
  126. X        }
  127. X        else { m += 1; break; }
  128. X        }
  129. X    }
  130. X    return -1;
  131. X    }
  132. X
  133. X
  134. Xshort DoIt()
  135. X{
  136. X    char inpline[BIGLINE];
  137. X    char * sourcefile;
  138. X    TFSfile sf;
  139. X    short l, j;
  140. X    int curline;
  141. X    int realline;
  142. X
  143. X    /* DEBUG_SETDEFS("RAW:0/190/640/200/Debug window", "T:DBugOut"); */
  144. X    /* DEBUG_ENTER("DoIt", NULL); */
  145. X
  146. X    PLStatus(6, "Reading source...");
  147. X    /* DEBUGF(0, "Reading source..."); */
  148. X
  149. X    sourcefile = PLarglist[0];
  150. X
  151. X    TFSInit();
  152. X
  153. X    sf = TFSOpen(sourcefile, "R");
  154. X    if (sf == 0) {
  155. X    PLStatus(0, "Could not open source file");
  156. X    /* DEBUG_RETURN(NULL); */
  157. X    PLExit(PLsev_error);
  158. X    }
  159. X
  160. X    realline = 1;
  161. X    while (-1 != (l = TFSRead(sf, inpline)) && 0 != l)
  162. X    realline += 1;    /* skip leading comments */
  163. X
  164. X    curline = 0;
  165. X    while (-1 != (l = TFSRead(sf, inpline))) {
  166. X    realline += 1;
  167. X    /* DEBUGF(9, "Reading line %d (%d): %s" C curline C realline C inpline); */
  168. X    for (j = 0; j < l; j++)
  169. X        if (inpline[j] == HeadEOL)
  170. X        inpline[j] = '\0';
  171. X        else
  172. X        if (islower(inpline[j]))
  173. X            inpline[j] = toupper(inpline[j]);
  174. X    if (inpline[0]) {
  175. X        j = findmacro(inpline);
  176. X        if (j == -1) {
  177. X        PLStatus(0, "Unrecognised line:");
  178. X        PLStatus(0, inpline);
  179. X        TFSClose(sf);
  180. X        TFSTerm();
  181. X        /* DEBUG_RETURN(NULL); */
  182. X        PLExit(PLsev_error);
  183. X        }
  184. X        else {
  185. X        for (l = 0; param[l]; l++) {
  186. X            if (! isupper(param[l]) && !isdigit(param[l])) {
  187. X            PLStatus(0, "Bad parameter");
  188. X            TFSClose(sf);
  189. X            TFSTerm();
  190. X            /* DEBUG_RETURN(NULL); */
  191. X            PLExit(PLsev_error);
  192. X            }
  193. X            }
  194. X        }
  195. X        if (macro[j].initfunc)
  196. X        (*macro[j].initfunc)(curline);
  197. X        source[curline++] = PLStrDup(inpline);
  198. X        if (curline >= MAXSRC) {
  199. X        PLStatus(0, "Source too big");
  200. X        TFSClose(sf);
  201. X        TFSTerm();
  202. X        /* DEBUG_RETURN(NULL); */
  203. X        PLExit(PLsev_oores);
  204. X        }
  205. X        }
  206. X    }
  207. X    if (PLerr != PLerr_eod) {
  208. X    PLStatus(0, "Error reading source file");
  209. X    TFSClose(sf);
  210. X    TFSTerm();
  211. X    /* DEBUG_RETURN(NULL); */
  212. X    PLExit(PLsev_error);
  213. X    }
  214. X
  215. X    TFSTerm();
  216. X
  217. X    PLErrClr();
  218. X
  219. X    /* DEBUGF(0, "Running..."); */
  220. X    PLStatus(6, "Running...");
  221. X
  222. X    curline = startLine;
  223. X    while (curline != -1) {
  224. X    j = findmacro(source[curline]);
  225. X    curline = (*macro[j].execfunc)(curline);
  226. X    }
  227. X
  228. X    /* DEBUGF(0, "Execution complete!"); */
  229. X    PLStatus(6, "Execution complete!");
  230. X
  231. X    /* DEBUG_RETURN(NULL); */
  232. X
  233. X    return 0;
  234. X    }
  235. X
  236. X
  237. X
  238. END_OF_FILE
  239. if test 5323 -ne `wc -c <'LOME/Iparse.c'`; then
  240.     echo shar: \"'LOME/Iparse.c'\" unpacked with wrong size!
  241. fi
  242. # end of 'LOME/Iparse.c'
  243. fi
  244. if test -f 'LOME/LOME0.c' -a "${1}" != "-c" ; then 
  245.   echo shar: Will not clobber existing file \"'LOME/LOME0.c'\"
  246. else
  247. echo shar: Extracting \"'LOME/LOME0.c'\" \(4167 characters\)
  248. sed "s/^X//" >'LOME/LOME0.c' <<'END_OF_FILE'
  249. X/*
  250. X * LOME0.c
  251. X * Line Oriented Macro Expander - Routines called by tout le monde
  252. X * Copyright 1989 Darren New
  253. X *
  254. X */
  255. X
  256. X#include "LOME.h"
  257. X
  258. X#define ADDTOLINE(c) (consline[conslinesize++] = (c))
  259. X#define ENDLINE() (consline[conslinesize] = 0)
  260. X
  261. Xvoid Message ARGS1(str,s)
  262. X{
  263. X    char t[100];
  264. X    char * u;
  265. X    strcpy(t, "********** Error: ");
  266. X    strcat(t, s);
  267. X    strcat(t, " ");
  268. X    MPutChar(0);
  269. X    for (u = t; *u; u++)
  270. X    MPutChar(*u);
  271. X    MPutChar(0);
  272. X    MPutBuff(outstream);
  273. X    }
  274. X
  275. Xvoid PopTStack()
  276. X{
  277. X    /* does everything needed to pop traceback stack */
  278. X    int i;    /* scratch */
  279. X    assert(0 < tstacksize);
  280. X    if (Sinp) PLFreeMem(Sinp);
  281. X    Sinp = NULL;
  282. X    for (i = 0; i < 10; i++) {
  283. X    if (Sp[i]) PLFreeMem(Sp[i]);
  284. X    Sp[i] = NULL;
  285. X    }
  286. X    Sretoffs = -1;
  287. X    tstacksize -= 1;
  288. X    }
  289. X
  290. X
  291. Xvoid TraceBack()
  292. X{
  293. X    char * t = "Constructed line, traceback follows:";
  294. X
  295. X    MPutChar(0);
  296. X    while (*t) MPutChar(*t++);
  297. X    MPutChar(0);
  298. X    MPutBuff(outstream);
  299. X
  300. X    consline[conslinesize] = 0;
  301. X    t = consline;
  302. X    while (*t) MPutChar(*t++);
  303. X    MPutChar(0);
  304. X    MPutBuff(outstream);
  305. X
  306. X    while (0 < tstacksize) {
  307. X    t = Sinp;
  308. X    while (*t) MPutChar(*t++);
  309. X    MPutChar(0);
  310. X    MPutBuff(outstream);
  311. X    PopTStack();
  312. X    }
  313. X
  314. X    consline[conslinesize = 0] = 0;
  315. X
  316. X    }
  317. X
  318. Xvoid IntToStr ARGS2(long,num,str,buf)
  319. X{
  320. X    /* convert a number to a string representation */
  321. X    long exponent;
  322. X    int index = 0;
  323. X
  324. X    assert(0 == num || num != - num);   /* 0x80000000 fails */
  325. X
  326. X    if (num == 0) {
  327. X    buf[index++] = params[O_ZERO];
  328. X    }
  329. X    else {
  330. X    if (num < 0) {
  331. X        buf[index++] = params[O_MINUS];
  332. X        num = 0 - num;
  333. X        }
  334. X
  335. X    /* figure out first divisor */
  336. X    for (exponent = 1000; exponent < num; exponent *= 10) {
  337. X        /* assertion fails if sizeof(long) too short */
  338. X        assert(100 < exponent);
  339. X        }
  340. X    while (num / exponent == 0)
  341. X        exponent /= 10;
  342. X    while (exponent != 0) {
  343. X        /* not especially multiply-divide efficient */
  344. X        buf[index++] = (params[O_ZERO] + (num / exponent) % 10);
  345. X        num -= (num / exponent) % 10 * exponent;
  346. X        exponent /= 10;
  347. X        }
  348. X    }
  349. X    buf[index] = 0;
  350. X
  351. X    }
  352. X
  353. X
  354. Xlong StrToInt ARGS1(str,buf)
  355. X{
  356. X    /* converts buf to a long and returns it. Returns 0 if no good. */
  357. X    long res = 0;
  358. X    long sign = 1L;
  359. X
  360. X    if (buf == NULL || *buf == 0) {
  361. X    return 0L;
  362. X    }
  363. X    if (*buf == params[O_MINUS]) {
  364. X    sign = -1L;
  365. X    buf += 1;
  366. X    }
  367. X    else if (*buf == params[O_PLUS]) {
  368. X    sign = 1L;
  369. X    buf += 1;
  370. X    }
  371. X    while (params[O_ZERO] <= *buf && *buf <= params[O_ZERO] + 9) {
  372. X    res = res * 10 + *buf - params[O_ZERO];
  373. X    buf += 1;
  374. X    }
  375. X
  376. X    if (*buf) {
  377. X    return 0L;
  378. X    }
  379. X    else {
  380. X    return res * sign;
  381. X    }
  382. X    }
  383. X
  384. X
  385. Xlong StrToIntErr ARGS2(str,buf,str*,newbuf)
  386. X{
  387. X    /* converts buf to a long and returns it. returns pointer to char that
  388. X       caused failure. */
  389. X    long res = 0;
  390. X    long sign = 1L;
  391. X
  392. X    if (buf == NULL || *buf == 0) {
  393. X    if (newbuf)
  394. X        *newbuf = buf;
  395. X    return 0L;
  396. X    }
  397. X    if (*buf == params[O_MINUS]) {
  398. X    sign = -1L;
  399. X    buf += 1;
  400. X    }
  401. X    else if (*buf == params[O_PLUS]) {
  402. X    sign = 1L;
  403. X    buf += 1;
  404. X    }
  405. X    while (params[O_ZERO] <= *buf && *buf <= params[O_ZERO] + 9) {
  406. X    res = res * 10 + *buf - params[O_ZERO];
  407. X    buf += 1;
  408. X    }
  409. X
  410. X    if (newbuf)
  411. X    *newbuf = buf;
  412. X    return res * sign;
  413. X    }
  414. X
  415. X
  416. Xvoid InsNumber ARGS1(long,num)
  417. X{
  418. X    /* Insert the decimal equivalent of the given number into the line */
  419. X    char buf[BIGLINE];
  420. X    char * p;
  421. X
  422. X    assert(0 == num || num != - num);   /* 0x80000000 fails */
  423. X
  424. X    IntToStr(num, buf);
  425. X    for (p = buf; *p; p++)
  426. X    ADDTOLINE(*p);
  427. X    ENDLINE();
  428. X
  429. X    }
  430. X
  431. X
  432. Xstr VarLookup ARGS1(str,vname)
  433. X{
  434. X    int i;
  435. X
  436. X    if (vname == NULL || *vname == 0) {
  437. X    return NULL;
  438. X    }
  439. X    for (i = 0; varname[i] && i < MAXvarnames; i++) {
  440. X    if (strcmp(vname, varname[i]) == 0) {
  441. X        return varval[i];
  442. X        }
  443. X    }
  444. X    return NULL;
  445. X    }
  446. X
  447. Xvoid VarSetVal ARGS2(str,vname,str,vval)
  448. X{
  449. X    int i;
  450. X    if (vname == NULL || *vname == 0) {
  451. X    return;
  452. X    }
  453. X    i = 0;
  454. X    while (varname[i] && i < MAXvarnames && strcmp(vname, varname[i]))
  455. X    i += 1; /* look for name */
  456. X
  457. X    if (MAXvarnames <= i) {
  458. X    Message("VFUL");
  459. X    TraceBack();
  460. X    quitting = TRUE;
  461. X    return;
  462. X    }
  463. X    if (varname[i]) {
  464. X    PLFreeMem(varval[i]);
  465. X    varval[i] = NULL;
  466. X    }
  467. X    else {
  468. X    varname[i] = PLStrDup(vname);
  469. X    }
  470. X    varval[i] = PLStrDup(vval);
  471. X    }
  472. X
  473. X
  474. X
  475. X
  476. END_OF_FILE
  477. if test 4167 -ne `wc -c <'LOME/LOME0.c'`; then
  478.     echo shar: \"'LOME/LOME0.c'\" unpacked with wrong size!
  479. fi
  480. # end of 'LOME/LOME0.c'
  481. fi
  482. if test -f 'LOME/LOME1.c' -a "${1}" != "-c" ; then 
  483.   echo shar: Will not clobber existing file \"'LOME/LOME1.c'\"
  484. else
  485. echo shar: Extracting \"'LOME/LOME1.c'\" \(4935 characters\)
  486. sed "s/^X//" >'LOME/LOME1.c' <<'END_OF_FILE'
  487. X/*
  488. X * LOME1.c
  489. X * Line Oriented Macro Expander - LoadMacros()
  490. X * Copyright 1989 Darren New
  491. X *
  492. X */
  493. X
  494. X#include "LOME.h"
  495. X
  496. Xbool LoadMacros ARGS1(int,inpstream)
  497. X{
  498. X    int i, j;        /* scratch */
  499. X
  500. X    do {
  501. X    i = MGetBuff(inpstream);
  502. X    if (i != M_OK) {
  503. X        Message("UEOF");
  504. X        return FALSE;
  505. X        }
  506. X    i = MGetChar();
  507. X    } while (i != 0);
  508. X
  509. X    /* read and parse parameter line */
  510. X
  511. X    i = MGetBuff(inpstream);
  512. X    if (i != M_OK) {
  513. X    Message("UEOF");
  514. X    return FALSE;
  515. X    }
  516. X
  517. X    for (j = 0; j < O_last; j++) {
  518. X    params[j] = MGetChar();
  519. X    if (params[j] == 0) {
  520. X        PLStatus(1, "Too few characters on parameter line");
  521. X        Message("FORM");
  522. X        return FALSE;
  523. X        }
  524. X    }
  525. X
  526. X    if (0 != MGetChar()) {
  527. X    PLStatus(1, "Too many characters on parameter line");
  528. X    Message("FORM");
  529. X    return FALSE;
  530. X    }
  531. X
  532. X    /* this operation should probably be elsewhere: */
  533. X    if (params[O_FSYMGEN] == params[O_ZERO] + 1)
  534. X    symgenval = 100;
  535. X    else if (params[O_FSYMGEN] == params[O_ZERO] + 2)
  536. X    symgenval = 1000;
  537. X
  538. X
  539. X    if (params[O_FECHO] == params[O_ZERO] + 1)
  540. X    MEchoFlag = 1;
  541. X
  542. X    /* Read and parse other lines */
  543. X
  544. X    while ((i = MGetBuff(inpstream)) == M_OK) {
  545. X    int j = 0;        /* no characters found yet */
  546. X
  547. X    /* load header */
  548. X    do {
  549. X        i = MGetChar();
  550. X
  551. X        /* see if macro header is a blank line */
  552. X        while (j == 0 && i == 0) {
  553. X        i = MGetBuff(inpstream);
  554. X        /* late-change unstructured multi-level break. Sorry. */
  555. X        if (i != M_OK) goto found_end;
  556. X        i = MGetChar();
  557. X        }
  558. X
  559. X        /* skip leading spaces, maybe */
  560. X        while (j == 0 && i == params[O_SPACE] &&
  561. X            params[O_FSPACE] == params[O_ZERO])
  562. X        i = MGetChar();
  563. X
  564. X        j = 1;        /* stop skipping leading spaces */
  565. X
  566. X        if (i == 0 || i == params[O_HEOL]) {
  567. X        macroflag[macrosize] = 2;
  568. X        macrochar[macrosize] = 0;
  569. X        }
  570. X        else if (i == params[O_ESC]) {
  571. X        i = MGetChar();
  572. X        if (i == 0) {   /* ignore final escape */
  573. X            macroflag[macrosize] = 2;
  574. X            macrochar[macrosize] = 0;
  575. X            }
  576. X        else {
  577. X            macroflag[macrosize] = 0;
  578. X            macrochar[macrosize] = i;
  579. X            }
  580. X        }
  581. X        else if (i == params[O_PHC]) {
  582. X        if (macroflag[macrosize-1] == 1) {
  583. X            /* can't have two placeholders in a row */
  584. X            PLStatus(1, "Two consecutive placeholders");
  585. X            Message("FORM");
  586. X            return FALSE;
  587. X            }
  588. X        macroflag[macrosize] = 1;
  589. X        macrochar[macrosize] = i;
  590. X        }
  591. X        else {
  592. X        macroflag[macrosize] = 0;
  593. X        macrochar[macrosize] = i;
  594. X        }
  595. X
  596. X        if (MAXmacrochars <= macrosize + 1) {
  597. X        Message("FULL");
  598. X        return FALSE;
  599. X        }
  600. X
  601. X        } while (macroflag[macrosize++] != 2);
  602. X
  603. X    /* load body */
  604. X    do {
  605. X
  606. X        j = 0;  /* number of chars read so far */
  607. X        i = MGetBuff(inpstream);
  608. X        if (i != M_OK) {
  609. X        Message("UEOF");
  610. X        return FALSE;
  611. X        }
  612. X
  613. X        do {
  614. X        i = MGetChar();
  615. X        if (i == params[O_BEOL] && j == 0) {
  616. X            /* BEOL is first on line */
  617. X            i = MGetChar();
  618. X            if (i == params[O_BEOL]) {
  619. X            macroflag[macrosize] = 3;
  620. X            macrochar[macrosize] = 0;
  621. X            macrosize += 1;
  622. X            }
  623. X            else if (params[O_ZERO] != params[O_FBLANK]) {
  624. X            /* keep blank lines */
  625. X            macroflag[macrosize] = 2;
  626. X            macrochar[macrosize] = 0;
  627. X            macrosize += 1;
  628. X            }
  629. X            i = 0;  /* discard rest of line */
  630. X            }
  631. X        else if (i == 0 || i == params[O_BEOL]) {
  632. X            /* found end of body line */
  633. X            if (j != 0 || params[O_ZERO] != params[O_FBLANK]) {
  634. X            /* chars before or keep blanks */
  635. X            macroflag[macrosize] = 2;
  636. X            macrochar[macrosize] = 0;
  637. X            macrosize += 1;
  638. X            }
  639. X            /* skip optional trailing comment */
  640. X            i = 0;
  641. X            }
  642. X        else if (i == params[O_ESC]) {
  643. X            i = MGetChar();
  644. X            if (i == 0) {   /* ignore final escape */
  645. X            macroflag[macrosize] = 2;
  646. X            macrochar[macrosize] = 0;
  647. X            macrosize += 1;
  648. X            i = 0;
  649. X            }
  650. X            else {
  651. X            macroflag[macrosize] = 0;
  652. X            macrochar[macrosize] = i;
  653. X            macrosize += 1;
  654. X            j += 1;
  655. X            }
  656. X            }
  657. X        else if (i == params[O_SUBS]) {
  658. X            i = MGetChar();
  659. X            if (i == params[O_CTRLOP] || i == params[O_FILEOP] ||
  660. X                (params[O_ZERO] <= i &&
  661. X                 i <= params[O_ZERO] + 9)) {
  662. X            macroflag[macrosize] = 1;
  663. X            macrochar[macrosize] = i;
  664. X            macrosize += 1;
  665. X            i = MGetChar();
  666. X            if (params[O_ZERO] <= i && i <= params[O_ZERO] + 9) {
  667. X                macroflag[macrosize] = 1;
  668. X                macrochar[macrosize] = i;
  669. X                macrosize += 1;
  670. X                }
  671. X            else {
  672. X                PLStatus(1, "Operation not a digit");
  673. X                Message("FORM");
  674. X                return FALSE;
  675. X                }
  676. X            }
  677. X            else {
  678. X            PLStatus(1, "Operation not digit control or file");
  679. X            Message("FORM");
  680. X            return FALSE;
  681. X            }
  682. X            j += 1;
  683. X            }
  684. X        else {
  685. X            macroflag[macrosize] = 0;
  686. X            macrochar[macrosize] = i;
  687. X            macrosize += 1;
  688. X            j += 1;
  689. X            }
  690. X
  691. X        if (MAXmacrochars <= macrosize + 1) {
  692. X            Message("FULL");
  693. X            return FALSE;
  694. X            }
  695. X
  696. X        /* end of body line loop */
  697. X        } while (i != 0);
  698. X
  699. X        /* end of body loop */
  700. X        } while (macroflag[macrosize-1] != 3);
  701. X
  702. X    /* end of macro file loop */
  703. X    found_end: ;  /* go here if there is EOF or ERROR while attempting
  704. X             to read macro header line */
  705. X    }
  706. X
  707. X    if (i != M_EOF) {
  708. X    Message("IOER");
  709. X    return FALSE;
  710. X    }
  711. X
  712. X    return TRUE;
  713. X
  714. X    }
  715. X
  716. END_OF_FILE
  717. if test 4935 -ne `wc -c <'LOME/LOME1.c'`; then
  718.     echo shar: \"'LOME/LOME1.c'\" unpacked with wrong size!
  719. fi
  720. # end of 'LOME/LOME1.c'
  721. fi
  722. if test -f 'LOME/LOME3.c' -a "${1}" != "-c" ; then 
  723.   echo shar: Will not clobber existing file \"'LOME/LOME3.c'\"
  724. else
  725. echo shar: Extracting \"'LOME/LOME3.c'\" \(5089 characters\)
  726. sed "s/^X//" >'LOME/LOME3.c' <<'END_OF_FILE'
  727. X/*
  728. X * LOME3.c
  729. X * Line Oriented Macro Expander - FindMatch()
  730. X * Copyright 1989 Darren New
  731. X *
  732. X */
  733. X
  734. X#include "LOME.h"
  735. X
  736. X#ifdef HIDPROTS
  737. XHIDDEN bool ChInStr ARGS((char, str));
  738. X#endif
  739. X
  740. XHIDDEN bool ChInStr ARGS2(char,ch,str,s)
  741. X{
  742. X    /* returns TRUE if ch can be found in s */
  743. X    for ( ; *s; s++)
  744. X    if (ch == *s)
  745. X        return TRUE;
  746. X    return FALSE;
  747. X    }
  748. X
  749. X
  750. X/* matches a balanced element starting at the front of inp. Stops on
  751. X   seeing any char in mchars or at end of inp. If mchars is empty,
  752. X   matches all of inp.
  753. X   returns number of inp chars matched,
  754. X   returns char which stopped scan (maybe 0) in *next */
  755. X
  756. Xint BalMatch ARGS3(str,inp,str,mchars,char *,next)
  757. X{
  758. X    int s;    /* offset into inp so far */
  759. X    char o, c;    /* openning and closing nests */
  760. X    int depth;    /* current nesting depth */
  761. X    bool esc;    /* current Sinp[s] was escaped */
  762. X    char ch;    /* Sinp[s] unless escape */
  763. X
  764. X    assert(mchars != NULL);
  765. X    assert(inp != NULL);
  766. X    assert(next != NULL);
  767. X
  768. X    if (*mchars == 0)
  769. X    return strlen(inp);
  770. X
  771. X    depth = 0;    /* nothing nested yet */
  772. X    o = c = 0;    /* to shut up lint */
  773. X    s = 0;    /* start at beginning */
  774. X
  775. X    do {
  776. X    ch = inp[s];
  777. X    if (esc = (ch == params[O_ESC]))
  778. X        ch = Sinp[++s];
  779. X    if (ch == 0) {
  780. X        *next = 0;
  781. X        return s;
  782. X        }
  783. X    else if (depth == 0 && ChInStr(ch, mchars)) {
  784. X        *next = ch;
  785. X        return s;
  786. X        }
  787. X    else if (depth != 0) {
  788. X        s += 1;
  789. X        if (ch == o && ! esc) depth += 1;
  790. X        if (ch == c && ! esc) depth -= 1;
  791. X        }
  792. X    else {
  793. X        /* depth == 0 and not matching character */
  794. X        s += 1;
  795. X        if (ch == params[O_OQ] && ! esc)
  796. X        o = ch, c = params[O_CQ], depth = 1;
  797. X        if (ch == params[O_OP] && !esc)
  798. X        o = ch, c = params[O_CP], depth = 1;
  799. X        }
  800. X    } while (1);
  801. X    }
  802. X
  803. X
  804. X/* finds a match in the macrochar array for the Sinp. Sets Sp[], Rretoffs.
  805. X   Sretoffs will be negative if no match was found, otherwise it will
  806. X   be a pointer to the first character to be expanded. */
  807. X
  808. X
  809. Xvoid FindMatch()
  810. X{
  811. X    int pf[10];     /* offsets of first chars of parameters */
  812. X    int pl[10];     /* offsets of first chars past parameters */
  813. X    int p;        /* parameter being matched */
  814. X    int   s;        /* current char in Sinp */
  815. X    moffs m;        /* current char in macro headers */
  816. X    bool  found;    /* stop looking */
  817. X
  818. X    assert(0 < tstacksize);
  819. X    assert(Sinp != NULL);
  820. X
  821. X    Sretoffs = -1; m = 0; found = FALSE;
  822. X    s = 0; p = 0;
  823. X
  824. X    while (m < macrosize && ! found) {
  825. X
  826. X    if (macroflag[m] == 0) {
  827. X        /* need to match this character */
  828. X
  829. X        char ch1, ch2;  /* translated Sinp[s] and macrochar[m] */
  830. X
  831. X        /* maybe switch escaped? and fix cases? to allow esc=case */
  832. X
  833. X        ch1 = Sinp[s]; ch2 = macrochar[m];
  834. X
  835. X        if (ch1 == params[O_ESC])   /* escaped? */
  836. X        ch1 = Sinp[++s];
  837. X
  838. X        if (params[O_FCASE] == params[O_ZERO]) {    /* fix cases? */
  839. X        if (params[O_UCA] <= ch1 && ch1 <= params[O_UCZ])
  840. X            ch1 = ch1 - params[O_UCA] + params[O_LCA];
  841. X        if (params[O_UCA] <= ch2 && ch2 <= params[O_UCZ])
  842. X            ch2 = ch2 - params[O_UCA] + params[O_LCA];
  843. X        }
  844. X
  845. X        if (ch1 == 0 && ch2 == params[O_SPACE]) {
  846. X        m += 1; /* allow trailing space in MH to match BEOL */
  847. X        }
  848. X        else if (ch1 == ch2) {
  849. X        s += 1;
  850. X        m += 1;
  851. X        }
  852. X        else {
  853. X        /* match failed. advance past header and body */
  854. X        while (macroflag[m] != 3)
  855. X            m += 1;
  856. X        m += 1;
  857. X        s = 0;
  858. X        p = 0;
  859. X        }
  860. X        }
  861. X    else if (macroflag[m] == 1) {
  862. X        /* here, match a balanced parameter */
  863. X        assert(p < 10);     /* should be checked in LoadMacro */
  864. X        if (macroflag[m + 1] == 2) {
  865. X        /* special case: PHC last character in header line */
  866. X        pf[p] = s;
  867. X        while (Sinp[s])
  868. X            s += 1;
  869. X        pl[p] = s;
  870. X        p += 1;
  871. X        found = TRUE;
  872. X        m += 2; /* skip PHC and HEOL */
  873. X        }
  874. X        else {
  875. X        /* PHC not last on line */
  876. X        char mchars[2]; /* char to try to end scan */
  877. X        char next;    /* char which stops scan */
  878. X        int mlen;    /* match length */
  879. X
  880. X        assert(macroflag[m + 1] == 0);  /* should be checked by LoadMacros */
  881. X        mchars[0] = macrochar[m + 1];
  882. X        mchars[1] = 0;
  883. X        pf[p] = s;
  884. X
  885. X        mlen = BalMatch(&Sinp[s], mchars, &next);
  886. X
  887. X        if (next == 0) {
  888. X            /* can't match because PHC not last on line */
  889. X            /* advance past header and body */
  890. X            while (macroflag[m] != 3)
  891. X            m += 1;
  892. X            m += 1;
  893. X            s = 0;
  894. X            p = 0;
  895. X            }
  896. X        else {
  897. X            /* good match */
  898. X            assert(Sinp[s+mlen] == macrochar[m + 1]);
  899. X            s += mlen;
  900. X            pl[p] = s;
  901. X            p += 1;
  902. X            m += 1;    /* skip placeholder character */
  903. X            }
  904. X        }
  905. X        }
  906. X    else if (macroflag[m] == 2) {
  907. X        /* here, match EOL */
  908. X        while (Sinp[s] == params[O_SPACE])
  909. X        s += 1; /* skip trailing unescaped spaces */
  910. X        if (Sinp[s] == 0) {
  911. X        m += 1;
  912. X        found = TRUE;
  913. X        }
  914. X        else {
  915. X        /* match failed. advance past header and body */
  916. X        while (macroflag[m] != 3)
  917. X            m += 1;
  918. X        m += 1;
  919. X        s = 0;
  920. X        p = 0;
  921. X        }
  922. X        }
  923. X    }
  924. X
  925. X    if (found) {
  926. X    /* set up parameter matches in stack */
  927. X    char * pnt;    /* scratch */
  928. X    int i, j;    /* scratch */
  929. X
  930. X    Sretoffs = m;
  931. X    for (i = 0; i < p; i++) {
  932. X        pnt = (char *) PLAllocMem(pl[i] + pf[i] + 1,
  933. X            PLalloc_die | PLalloc_zero);
  934. X        for (j = pf[i]; j < pl[i]; j++)
  935. X        pnt[j - pf[i]] = Sinp[j];
  936. X        Sp[i] = pnt;
  937. X        }
  938. X    }
  939. X    else {
  940. X    Sretoffs = -1;
  941. X    }
  942. X    }
  943. X
  944. X
  945. END_OF_FILE
  946. if test 5089 -ne `wc -c <'LOME/LOME3.c'`; then
  947.     echo shar: \"'LOME/LOME3.c'\" unpacked with wrong size!
  948. fi
  949. # end of 'LOME/LOME3.c'
  950. fi
  951. if test -f 'LOME/LOME6.c' -a "${1}" != "-c" ; then 
  952.   echo shar: Will not clobber existing file \"'LOME/LOME6.c'\"
  953. else
  954. echo shar: Extracting \"'LOME/LOME6.c'\" \(5725 characters\)
  955. sed "s/^X//" >'LOME/LOME6.c' <<'END_OF_FILE'
  956. X/*
  957. X * LOME6.c
  958. X * Line Oriented Macro Expander - DoFileOp()
  959. X * Copyright 1989 Darren New
  960. X *
  961. X */
  962. X
  963. X#include "LOME.h"
  964. X
  965. X
  966. Xint GetF ARGS((int));
  967. X
  968. Xint GetF ARGS1(int,offs)
  969. X{
  970. X    /* This gets the file number at the indicated offset in the consline.
  971. X       It returns -1 for a FORM error. */
  972. X
  973. X    char ch = consline[offs];
  974. X    if (conslinesize <= offs) return -1;
  975. X    if (ch == params[O_UCA]) return (int) instream;
  976. X    if (ch == params[O_UCZ]) return (int) outstream;
  977. X    if (ch < params[O_ZERO] || params[O_ZERO] + 9 < ch)
  978. X    return -1;
  979. X    return ch - params[O_ZERO];
  980. X    }
  981. X
  982. Xvoid Choke ARGS((str));
  983. X
  984. Xvoid Choke ARGS1(str,s)
  985. X{
  986. X    Message(s);
  987. X    TraceBack();
  988. X    quitting = TRUE;
  989. X    }
  990. X
  991. X
  992. Xvoid DoFileOp ARGS1(int,op /* the operation number */)
  993. X{
  994. X    int i;
  995. X
  996. X    assert(0 < tstacksize);
  997. X
  998. X    switch (op) {
  999. X
  1000. X    case 0: {
  1001. X        int f = GetF(0);
  1002. X        if (f == -1) {
  1003. X        Choke("FORM");
  1004. X        }
  1005. X        else {
  1006. X        int res = MRewind(f);
  1007. X        if (res != M_OK) {
  1008. X            Choke("IOER");
  1009. X            }
  1010. X        if (consline[1] != 0) {
  1011. X            res = MRename(f, &consline[1]);
  1012. X            if (res != M_OK) {
  1013. X            Choke("IOER");
  1014. X            }
  1015. X            }
  1016. X        }
  1017. X        break;
  1018. X        }
  1019. X
  1020. X    case 1: {
  1021. X        int from = GetF(0);
  1022. X        int to = GetF(1);
  1023. X        if (from == -1 || to == -1) {
  1024. X        Choke("FORM");
  1025. X        }
  1026. X        else {
  1027. X        char * match = &consline[2];
  1028. X        int i, j;
  1029. X        if (*match == 0) {  /* copy whole file */
  1030. X            j = M_OK;
  1031. X            i = MGetBuff(from);
  1032. X            while (i == M_OK && j == M_OK) {
  1033. X            j = MPutBuff(to);
  1034. X            i = MGetBuff(from);
  1035. X            }
  1036. X            if (i != M_EOF || j != M_OK) {
  1037. X            Choke("IOER");
  1038. X            }
  1039. X            }
  1040. X        else {            /* copy to match */
  1041. X            bool linefound = FALSE;
  1042. X            i = MGetBuff(from);
  1043. X            while (i == M_OK && ! linefound) {
  1044. X            match = &consline[2];
  1045. X            linefound = TRUE;
  1046. X            while (*match && linefound) {
  1047. X                if (MGetChar() == *match)
  1048. X                match += 1;
  1049. X                else
  1050. X                linefound = FALSE;
  1051. X                }
  1052. X            if (! linefound) {
  1053. X                if (M_OK != MPutBuff(to))
  1054. X                Choke("IOER");
  1055. X                i = MGetBuff(from);
  1056. X                }
  1057. X            }
  1058. X            if (i == M_EOF)
  1059. X            Choke("UEOF");
  1060. X            else if (i != M_OK)
  1061. X            Choke("IOER");
  1062. X            }
  1063. X        }
  1064. X        break;
  1065. X        }
  1066. X
  1067. X    case 2: {
  1068. X        int f = GetF(0);
  1069. X        if (f == -1) {
  1070. X        Choke("FORM");
  1071. X        }
  1072. X        else {
  1073. X        outstream = f;
  1074. X        }
  1075. X        break;
  1076. X        }
  1077. X
  1078. X    case 3: {
  1079. X        int f = GetF(0);
  1080. X        if (f == -1) {
  1081. X        Choke("FORM");
  1082. X        }
  1083. X        else {
  1084. X        if (consline[1] != 0) {
  1085. X            sstack[sstacksize++] = f;
  1086. X            if (MAXstreams <= sstacksize)
  1087. X            Choke("SSTK");
  1088. X            else
  1089. X            instream = f;
  1090. X            }
  1091. X        else {
  1092. X            instream = sstack[sstacksize-1] = f;
  1093. X            }
  1094. X        }
  1095. X        break;
  1096. X        }
  1097. X
  1098. X    case 4: {
  1099. X        int f = GetF(0);
  1100. X        if (f == -1) {
  1101. X        Choke("FORM");
  1102. X        }
  1103. X        else {
  1104. X        char * t = &consline[1];
  1105. X        MPutChar(0);
  1106. X        while (*t) MPutChar(*t++);
  1107. X        MPutChar(0);
  1108. X        f = MPutBuff(f);
  1109. X        if (f != M_OK)
  1110. X            Choke("IOER");
  1111. X        }
  1112. X        break;
  1113. X        }
  1114. X
  1115. X    case 5: {
  1116. X        int f = GetF(0);
  1117. X        if (f == -1) {
  1118. X        Choke("FORM");
  1119. X        }
  1120. X        else {
  1121. X        char ch = 0;
  1122. X        char * t = &consline[1];
  1123. X        char * s = NULL;
  1124. X        MPutChar(0);
  1125. X        while (*t) {
  1126. X            if (params[O_ZERO] <= *t && *t <= params[O_ZERO] + 9) {
  1127. X            if (*t != ch) {
  1128. X                ch = *t;
  1129. X                s = Sp[*t - params[O_ZERO]];
  1130. X                }
  1131. X            if (s && *s)
  1132. X                MPutChar(*s++);
  1133. X            else
  1134. X                MPutChar(params[O_SPACE]);
  1135. X            }
  1136. X            else {
  1137. X            MPutChar(*t);
  1138. X            ch = 0;
  1139. X            }
  1140. X            t += 1;
  1141. X            }
  1142. X        MPutChar(0);
  1143. X        if (M_OK != MPutBuff(f))
  1144. X            Choke("IOER");
  1145. X        }
  1146. X        break;
  1147. X        }
  1148. X
  1149. X    case 6: {   /* debugging dump */
  1150. X        char * t;
  1151. X        int i;
  1152. X
  1153. X        int f = GetF(0);
  1154. X        if (f == -1) {
  1155. X        Choke("FORM");
  1156. X        }
  1157. X        else {
  1158. X        Message("DUMP");
  1159. X
  1160. X        t = "Variable names, values follow:";
  1161. X        MPutChar(0);
  1162. X        while (*t) MPutChar(*t++);
  1163. X        MPutChar(0);
  1164. X        MPutBuff(outstream);
  1165. X
  1166. X        for (i = 0; varname[i] && i < MAXvarnames; i++) {
  1167. X            MPutChar(0);
  1168. X            MPutChar(params[O_OQ]);
  1169. X            for (t = varname[i]; *t; t++)
  1170. X            MPutChar(*t);
  1171. X            MPutChar(params[O_CQ]);
  1172. X            MPutChar(params[O_SPACE]);
  1173. X            if (varval[i]) {
  1174. X            MPutChar(params[O_OQ]);
  1175. X            for (t = varval[i]; *t; t++)
  1176. X                MPutChar(*t);
  1177. X            MPutChar(params[O_CQ]);
  1178. X            }
  1179. X            MPutChar(0);
  1180. X            MPutBuff(outstream);
  1181. X            }
  1182. X
  1183. X        t = "Parameters, values follow:";
  1184. X        MPutChar(0);
  1185. X        while (*t) MPutChar(*t++);
  1186. X        MPutChar(0);
  1187. X        MPutBuff(outstream);
  1188. X
  1189. X        for (i = 0; i < 10; i++) {
  1190. X            MPutChar(0);
  1191. X            MPutChar(params[O_ZERO] + i);
  1192. X            MPutChar(params[O_SPACE]);
  1193. X            if (Sp[i]) {
  1194. X            MPutChar(params[O_OQ]);
  1195. X            for (t = Sp[i]; *t; t++)
  1196. X                MPutChar(*t);
  1197. X            MPutChar(params[O_CQ]);
  1198. X            }
  1199. X            MPutChar(0);
  1200. X            MPutBuff(outstream);
  1201. X            }
  1202. X
  1203. X        TraceBack();
  1204. X        quitting = TRUE;
  1205. X        }
  1206. X
  1207. X        break;
  1208. X        }
  1209. X
  1210. X    case 7: {
  1211. X#ifdef PPL_h
  1212. X        /* we are using PPL.h, so use PLStatus() */
  1213. X        short pri = consline[0] - params[O_ZERO];
  1214. X        if (pri < 0) pri = 0;
  1215. X        if (9 < pri) pri = 9;
  1216. X        if (0 < conslinesize)
  1217. X        PLStatus(pri, &consline[1]);
  1218. X#endif    /* PPL_h */
  1219. X        break;
  1220. X        }
  1221. X
  1222. X    case 8: {
  1223. X        int f;
  1224. X        int p;
  1225. X        f = GetF(0);
  1226. X        p = (0 < conslinesize) ? consline[1] - params[O_ZERO] : -1;
  1227. X        if (f == -1) {
  1228. X        Choke("FORM");
  1229. X        }
  1230. X        else {
  1231. X        i = MGetBuff(f);
  1232. X        while (i == M_EOF &&
  1233. X            consline[0] == params[O_UCA] && 0 < sstacksize) {
  1234. X            sstacksize -= 1;
  1235. X            if (sstacksize)
  1236. X            instream = sstack[sstacksize-1];
  1237. X            else
  1238. X            instream = 0;
  1239. X            }
  1240. X        if (i == M_EOF)
  1241. X            Choke("UEOF");
  1242. X        else if (i == M_ILLEGAL)
  1243. X            Choke("IOER");
  1244. X        else if (0 <= p && p <= 9) {
  1245. X            /* use consline as temp storage */
  1246. X            conslinesize = 0;
  1247. X            while (0 != (consline[conslinesize++] = MGetChar()))
  1248. X            /* read next char */ ;
  1249. X            if (Sp[p]) PLFreeMem(Sp[p]);
  1250. X            Sp[p] = PLStrDup(consline);
  1251. X            }
  1252. X        }
  1253. X        break;
  1254. X        }
  1255. X
  1256. X    case 9: {
  1257. X        Message("NYET");
  1258. X        TraceBack();
  1259. X        break;
  1260. X        }
  1261. X
  1262. X    }
  1263. X
  1264. X    consline[conslinesize = 0] = 0; /* clear constructed line */
  1265. X    if (macroflag[Sretoffs] == 2)   /* skip trailing BEOL if there */
  1266. X    Sretoffs += 1;
  1267. X    }
  1268. X
  1269. X
  1270. END_OF_FILE
  1271. if test 5725 -ne `wc -c <'LOME/LOME6.c'`; then
  1272.     echo shar: \"'LOME/LOME6.c'\" unpacked with wrong size!
  1273. fi
  1274. # end of 'LOME/LOME6.c'
  1275. fi
  1276. if test -f 'LOME/MIOtest.c' -a "${1}" != "-c" ; then 
  1277.   echo shar: Will not clobber existing file \"'LOME/MIOtest.c'\"
  1278. else
  1279. echo shar: Extracting \"'LOME/MIOtest.c'\" \(4510 characters\)
  1280. sed "s/^X//" >'LOME/MIOtest.c' <<'END_OF_FILE'
  1281. X/*
  1282. X * MIOTest.c
  1283. X * Macro I/O Subsystem Test Program
  1284. X * Copyright 1988,1990 Darren New.
  1285. X * All rights reserved.
  1286. X */
  1287. X
  1288. X#include "PPL.h"
  1289. X
  1290. X#include "MacroIO.h"
  1291. X
  1292. X/******************* NOT COMPLETE ! *********************/
  1293. X
  1294. X
  1295. X
  1296. X/* This program will test your implementation of MacroIO.c.
  1297. X   Put the following lines on stream one. Output will be to stream two.
  1298. X   Output will also be to stream three.
  1299. X   A scratch file is written then read on stream nine.
  1300. X   A newly named file is written to "t:MIOTEST8.out".
  1301. X
  1302. X
  1303. X1)  This should appear on stream 2.
  1304. X2)  This too should appear on stream 2.
  1305. XX)  This should not appear at all.
  1306. X3)  If this is not followed by a totally blank line, buffer not clearing.
  1307. X4)  Lines 4 - 6 should appear twice.
  1308. X5)  If not, rewind may not be working.
  1309. X6)  This is the last duplicated line.
  1310. X7)  Line 8 should be next and contain all ten digits.
  1311. X9)  Line 9 is followed by a maximum-length line of zeros.
  1312. X10) The next line should contain only a single zero - test one item lines.
  1313. X11) Last line on stream 2 for now.
  1314. X12) This should go to stream 3.
  1315. X13) This should go to stream 3 also.
  1316. X   */
  1317. X
  1318. X
  1319. X#define ERROUT {MStopIO(); PLExit(PLsev_error);}
  1320. X
  1321. Xshort DoIt()
  1322. X{
  1323. X    /* char lb[BIGLINE]; */
  1324. X    /* short ccp; */
  1325. X
  1326. X    short ch1, ch2, ch3, ch4;
  1327. X
  1328. X    MStartIO(PLargcnt, PLarglist);
  1329. X
  1330. X    if (M_OK != MGetBuff(1))          ERROUT      /* 1 */
  1331. X    if (M_OK != MPutBuff(2))          ERROUT
  1332. X    if (M_OK != MGetBuff(1))          ERROUT      /* 2 */
  1333. X    if (M_OK != MPutBuff(2))          ERROUT
  1334. X
  1335. X    if (M_OK != MGetBuff(1))          ERROUT      /* X */
  1336. X
  1337. X    if (M_OK != MGetBuff(1))          ERROUT      /* 3 */
  1338. X    if (M_OK != MPutBuff(2))          ERROUT
  1339. X    MPutChar(0);
  1340. X    if (M_OK != MPutBuff(2))          ERROUT
  1341. X
  1342. X    if (M_OK != MGetBuff(1))          ERROUT      /* 4 */
  1343. X    if (M_OK != MPutBuff(9))          ERROUT
  1344. X    if (M_OK != MGetBuff(1))          ERROUT      /* 5 */
  1345. X    if (M_OK != MPutBuff(9))          ERROUT
  1346. X    if (M_OK != MGetBuff(1))          ERROUT      /* 6 */
  1347. X    if (M_OK != MPutBuff(9))          ERROUT
  1348. X
  1349. X    if (M_OK != MRewind(9))           ERROUT
  1350. X    if (M_OK != MGetBuff(9))          ERROUT      /* 4 */
  1351. X    if (M_OK != MPutBuff(2))          ERROUT
  1352. X    if (M_OK != MGetBuff(9))          ERROUT      /* 5 */
  1353. X    if (M_OK != MPutBuff(2))          ERROUT
  1354. X    if (M_OK != MGetBuff(9))          ERROUT      /* 6 */
  1355. X    if (M_OK != MPutBuff(2))          ERROUT
  1356. X    if (M_OK != MRewind(9))           ERROUT
  1357. X    if (M_OK != MGetBuff(9))          ERROUT      /* 4 */
  1358. X    if (M_OK != MPutBuff(2))          ERROUT
  1359. X    if (M_OK != MGetBuff(9))          ERROUT      /* 5 */
  1360. X    if (M_OK != MPutBuff(2))          ERROUT
  1361. X    if (M_OK != MGetBuff(9))          ERROUT      /* 6 */
  1362. X    if (M_OK != MPutBuff(2))          ERROUT
  1363. X
  1364. X    if (M_OK != MGetBuff(1))          ERROUT      /* 7 */
  1365. X    if (M_OK != MPutBuff(2))          ERROUT
  1366. X
  1367. X    ch1 = MGetChar();
  1368. X    if (ch1 <= 0)                     ERROUT
  1369. X    ch1 -= 7; /* now ch1 == '0' */
  1370. X    ch2 = MGetChar();
  1371. X    if (ch2 <= 0)                     ERROUT
  1372. X    ch3 = MGetChar();
  1373. X    if (ch3 <= 0)                     ERROUT
  1374. X    if (0 != MPutChar(0))             ERROUT
  1375. X    if (ch1+8 != MPutChar(ch1 + 8))   ERROUT
  1376. X    if (ch2 != MPutChar(ch2))         ERROUT
  1377. X    if (ch3 != MPutChar(ch3))         ERROUT
  1378. X    for (ch4 = 0; ch4 <= 9; ch4++)
  1379. X    if (ch4 + ch1 != MPutChar(ch4 + ch1))
  1380. X        ERROUT
  1381. X    if (0 != MPutChar(0))             ERROUT
  1382. X    if (M_OK != MPutBuff(2))          ERROUT      /* 8 */
  1383. X
  1384. X    if (M_OK != MGetBuff(1))          ERROUT      /* 9 */
  1385. X    if (M_OK != MPutBuff(2))          ERROUT
  1386. X    if (0 != MPutChar(0))             ERROUT
  1387. X    while (0 != MPutChar(ch1))
  1388. X    ;
  1389. X    if (M_OK != MPutBuff(2))          ERROUT
  1390. X
  1391. X    if (M_OK != MGetBuff(1))          ERROUT      /* 10 */
  1392. X    if (M_OK != MPutBuff(2))          ERROUT
  1393. X
  1394. X    if (ch1 != MPutChar(ch1))         ERROUT
  1395. X    if (0 != MPutChar(0))             ERROUT
  1396. X    if (M_OK != MPutBuff(2))          ERROUT
  1397. X
  1398. X    if (M_OK != MGetBuff(1))          ERROUT      /* 11 */
  1399. X    if (M_OK != MPutBuff(2))          ERROUT
  1400. X
  1401. X    if (M_OK != MGetBuff(1))          ERROUT      /* 12 */
  1402. X    if (M_OK != MPutBuff(3))          ERROUT
  1403. X
  1404. X    if (M_OK != MGetBuff(1))          ERROUT      /* 13 */
  1405. X    if (M_OK != MPutBuff(3))          ERROUT
  1406. X
  1407. X    if (M_OK != MPutBuff(8))          ERROUT      /* 13 again */
  1408. X    if (M_OK != MRename(8, "t:MIOTEST8.out"))
  1409. X                      ERROUT
  1410. X    if (M_OK != MPutBuff(8))          ERROUT      /* 13 once again */
  1411. X
  1412. X
  1413. X    if (M_EOF != MGetBuff(1))         ERROUT
  1414. X
  1415. X    MStopIO();
  1416. X
  1417. X    return 0;
  1418. X    }
  1419. X
  1420. X
  1421. END_OF_FILE
  1422. if test 4510 -ne `wc -c <'LOME/MIOtest.c'`; then
  1423.     echo shar: \"'LOME/MIOtest.c'\" unpacked with wrong size!
  1424. fi
  1425. # end of 'LOME/MIOtest.c'
  1426. fi
  1427. if test -f 'LOME/MacroIO.doc' -a "${1}" != "-c" ; then 
  1428.   echo shar: Will not clobber existing file \"'LOME/MacroIO.doc'\"
  1429. else
  1430. echo shar: Extracting \"'LOME/MacroIO.doc'\" \(5238 characters\)
  1431. sed "s/^X//" >'LOME/MacroIO.doc' <<'END_OF_FILE'
  1432. X
  1433. XThe Macro I/O subsystem must maintain certain items of state between
  1434. Xcalls. There must be at least ten streams available. Each stream must
  1435. Xbe capable of either reading or writing or both. There must be a "line
  1436. Xbuffer" (LB) capable of storing enough characters to hold the longest
  1437. Xline on any stream. There must be a "current character pointer" (CCP)
  1438. Xindicating the position of the next character to be read from or
  1439. Xwritten to the line buffer.
  1440. X
  1441. XIt is assumed that the user of the program will assign names to the
  1442. Xstreams in an unspecified way. Stream zero should always be associated
  1443. Xwith a device which discards all output and always returns end-of-file
  1444. Xduring reading.
  1445. X
  1446. XDefines in MacroIO.h include M_OK (=0), M_EOF (=1), and M_ILLEGAL (=2).
  1447. X
  1448. XMGetBuff : This must take a stream number (0 - 9) as a parameter and
  1449. Xfill the LB with the next line from that stream. It must return the OK
  1450. Xif the read was successful, or M_EOF if the end of file was detected, or
  1451. XM_ILLEGAL if reading is illegal at this time on this stream. The CCP
  1452. Xshould be set back to the beginning of the LB after this. A line
  1453. Xconsisting of all spaces being read in must cause the next MGetChar to
  1454. Xreturn zero upon the first call. A line containing leading spaces
  1455. Xbefore non-space characters must preserve those leading spaces.
  1456. XTrailing spaces after non-space characters may or may not be
  1457. Xdiscarded.
  1458. X
  1459. XMPutBuff : This must take a stream number (0 - 9) as a parameter and
  1460. Xcopy the contents of the LB to the given stream. It must return OK if
  1461. Xthe write was successful, M_EOF or M_ILLEGAL if the end of medium was
  1462. Xdetected, or ILLEGAL if writing is illegal at this time on this
  1463. Xstream. The CCP should be set back to the beginnng of the line buffer
  1464. Xafter this, but the buffer should not be cleared. Trailing spaces may
  1465. Xbe discarded either during the write to the device, from the LB, or
  1466. Xnot at all. Leading spaces before non-space characters must be
  1467. Xpreserved.
  1468. X
  1469. XMPutChar : This must take a character and put it in the LB at the
  1470. Xposition indicated by the CCP and then the CCP should be incremented.
  1471. XIf the character passed to this is zero, the LB should be terminated;
  1472. Xi.e., character zero marks the end of a line, and insertion of this
  1473. Xcharacter into the LB should cause the CCP to be reset back to the
  1474. Xbeginning. At this time, the buffer may be padded to a fixed size if
  1475. Xneeded. If this character will not fit in the LB, a zero should be
  1476. Xreturned. Otherwise, the character passed in should be returned.
  1477. X
  1478. XMGetChar : This must retrieve the character from the CCP of the LB and
  1479. Xreturn it. It must then increment the CCP. If the last character has
  1480. Xalready been retrieved, a zero should be returned, after which the
  1481. Xcurrent character position should be reset to the beginning of the
  1482. Xbuffer. See MGetBuff for information regarding spaces in the buffer.
  1483. X
  1484. XMRewind : This must take a stream number and reposition the stream to
  1485. Xthe beginning of the data available. It must not alter the contents of
  1486. Xthe LB nor of the stream addressed. If the Rewind was successful, this
  1487. Xreturns OK, otherwise it returns M_ILLEGAL. This should allow changing
  1488. Xfrom reading to writing or vica versa if possible.
  1489. X
  1490. XMRename : This must take a stream number and a string. It discards the
  1491. Xfile associated with the stream if it is a scratch file. It then does
  1492. Xwhat MRewind does, except that it behaves as if the user passed the
  1493. Xstring as the name for the file initially. This may be called any
  1494. Xnumber of times on each stream number. It cannot be used to modify
  1495. Xstream zero.
  1496. X
  1497. XMStartIO : This must do whatever is needed to set up and initialize
  1498. Xthe I/O subsystem. The parameters here will vary from implementation
  1499. Xto implementation. This could, for example, prompt the user for the
  1500. Xfile names to be associated with the streams. This will be called once
  1501. Xbefore any other I/O routines are called.
  1502. X
  1503. XMStopIO : This must do whatever is needed to terminate I/O processing.
  1504. XIt should close files and so on. It is expected that streams which
  1505. Xwere written but not explicitly named by the user were scratch streams
  1506. Xand may be discarded when MStopIO is called.
  1507. X
  1508. X
  1509. XThe mapping from the internal representation (what MGetChar returns)
  1510. Xand what the operating system handles must be done by these routines.
  1511. XThe mapping must meet the following constraints: no  character except
  1512. Xthe end-of-line or end-of-file marker(s) may map to zero, as zero is
  1513. Xreturned by MGetChar to indicate an end-of-line; the characters which
  1514. Xrepresent the digits must translate to a contiguous set of internal
  1515. Xcodes and the difference between any two digits must be the same as
  1516. Xthe difference between the corresponding internal codes; the
  1517. Xdifference between the internal code for an upper-case letter and the
  1518. Xinternal code for the corresponding lower-case letter must be the same
  1519. Xfor all letters; there may be no characters whose codes are between
  1520. Xthe codes for 'A' and 'Z' which are not uppercase letters; there may
  1521. Xbe no characters whose codes are between the codes for 'a' and 'z'
  1522. Xwhich are not lowercase letters; all characters must map to numbers
  1523. Xfrom 1 to 254 inclusive. Other than these six, no constraints are
  1524. Xplaced on the mapping. In particular, there need not be exactly
  1525. Xtwenty-six letters between 'A' and 'Z'; LOME handles this case
  1526. Xproperly.
  1527. X
  1528. X
  1529. END_OF_FILE
  1530. if test 5238 -ne `wc -c <'LOME/MacroIO.doc'`; then
  1531.     echo shar: \"'LOME/MacroIO.doc'\" unpacked with wrong size!
  1532. fi
  1533. # end of 'LOME/MacroIO.doc'
  1534. fi
  1535. if test -f 'LOME/MacroIO.h' -a "${1}" != "-c" ; then 
  1536.   echo shar: Will not clobber existing file \"'LOME/MacroIO.h'\"
  1537. else
  1538. echo shar: Extracting \"'LOME/MacroIO.h'\" \(4472 characters\)
  1539. sed "s/^X//" >'LOME/MacroIO.h' <<'END_OF_FILE'
  1540. X/*
  1541. X * MacroIO.h
  1542. X * Macro I/O Subsystem header file
  1543. X * Copyright 1988 Darren New.
  1544. X * All rights reserved.
  1545. X */
  1546. X
  1547. X
  1548. X/* Return codes from ReadBuff, WriteBuff, and Rewind.
  1549. X   NOTE: SCM WILL BREAK IF YOU CHANGE THESE. */
  1550. X
  1551. X#define M_OK 0
  1552. X#define M_EOF 1
  1553. X#define M_ILLEGAL 2
  1554. X
  1555. X
  1556. X/*
  1557. XSet this to one if you want read lines to be echoed as PLStatus lines,
  1558. Xotherwise leave this as zero.
  1559. X*/
  1560. X
  1561. Xextern short MEchoFlag;
  1562. X
  1563. X
  1564. X/*
  1565. XMGetBuff : This must take a stream number (0 - 9) as a parameter and
  1566. Xfill the LB with the next line from that stream. It must return the
  1567. Xnumber of characters read (non-negative) if the read was successful,
  1568. Xor minus one if the end of file was detected, or minus two if reading
  1569. Xis illegal at this time on this stream. The CCP should be set back to
  1570. Xthe beginning of the line buffer after this. A line consisting of all
  1571. Xspaces being read in must cause the next GetChar to return zero upon
  1572. Xthe first call. A line containing leading spaces before non-space
  1573. Xcharacters must preserve those leading spaces. Trailing spaces may be
  1574. Xsaved or discarded. A ReadBuff as the first operation on the stream or
  1575. Ximmediately after a Rewind will read the first line of the device or
  1576. Xfile.
  1577. X*/
  1578. X
  1579. Xextern int MGetBuff ARGS((int));
  1580. X
  1581. X
  1582. X/*
  1583. XMPutBuff : This must take a stream number (0 - 9) as a parameter and
  1584. Xcopy the contents of the LB to the given stream. It must return a
  1585. Xnon-negative number if the write was successful, minus one if the end
  1586. Xof medium was detected, or minus two if writing is illegal at this
  1587. Xtime on this stream. The CCP should be set back to the beginnng of the
  1588. Xline buffer after this, but the buffer should not be cleared. Trailing
  1589. Xspaces may be discarded either during the write to the device, from
  1590. Xthe LB, or not at all. Leading spaces before non-space characters must
  1591. Xbe preserved. The end-of-data mark is placed after the written line;
  1592. Xi.e., calling WriteBuff as the first operation on the stream or
  1593. Ximmediately after a Rewind will truncate the device (if possible)
  1594. Xbefore writing the line.
  1595. X*/
  1596. X
  1597. Xextern int MPutBuff ARGS((int));
  1598. X
  1599. X
  1600. X/*
  1601. XMPutChar : This must take a character and put it in the LB at the
  1602. Xposition indicated by the CCP and then the CCP should be incremented.
  1603. XIf the character passed to this is zero, the LB should be terminated;
  1604. Xi.e., character zero marks the end of a line, and insertion of this
  1605. Xcharacter into the LB should cause the CCP to be reset back to the
  1606. Xbeginning. At this time, the buffer may be padded to a fixed size if
  1607. Xneeded. If this character will not fit in the LB, a zero should be
  1608. Xreturned. Otherwise, the character passed in should be returned.
  1609. X*/
  1610. X
  1611. Xextern int MPutChar ARGS((int));
  1612. X
  1613. X
  1614. X/*
  1615. XMGetChar : This must retrieve the character from the CCP of the LB and
  1616. Xreturn it. It must then increment the CCP. If the last character has
  1617. Xalready been retrieved, a zero should be returned, after which the
  1618. Xcurrent character position should be reset to the beginning of the
  1619. Xbuffer. See MGetBuff for information regarding spaces in the buffer.
  1620. X*/
  1621. X
  1622. Xextern int MGetChar ARGS((void));
  1623. X
  1624. X
  1625. X/*
  1626. XMRewind : This must take a stream number and reposition the stream to
  1627. Xthe beginning of the data available. It must not alter the contents of
  1628. Xthe LB nor of the stream addressed. If the Rewind was successful, this
  1629. Xreturns zero, otherwise it returns minus one.
  1630. X*/
  1631. X
  1632. Xextern int MRewind ARGS((int));
  1633. X
  1634. X
  1635. X/*
  1636. XMRename : This must take a stream number and a string. It discards the
  1637. Xfile associated with the stream if it is a scratch file. It then does
  1638. Xwhat MRewind does, except that it behaves as if the user passed the
  1639. Xstring as the name for the file initially. This may be called any
  1640. Xnumber of times on each stream number. It cannot be used to modify
  1641. Xstream zero.
  1642. X*/
  1643. X
  1644. Xextern int MRename ARGS((int,str));
  1645. X
  1646. X
  1647. X/*
  1648. XMStartIO : This must do whatever is needed to set up and initialize
  1649. Xthe I/O subsystem. The parameters here will vary from implementation
  1650. Xto implementation. This could, for example, prompt the user for the
  1651. Xfile names to be associated with the streams. This will be called once
  1652. Xbefore any other I/O routines are called. Right now, the parameters
  1653. Xhere are the count and list of file names the user specified (a la
  1654. Xmain(argc, argv)).
  1655. X*/
  1656. X
  1657. Xextern int MStartIO ARGS((int,str*));
  1658. X
  1659. X
  1660. X/*
  1661. XMStopIO : This must do whatever is needed to terminate I/O processing.
  1662. XIt should close files and so on. It is expected that streams which
  1663. Xwere written but not explicitly named by the user were scratch streams
  1664. Xand will be discarded when StopIO is called.
  1665. X*/
  1666. X
  1667. Xextern int MStopIO ARGS((void));
  1668. X
  1669. X
  1670. X
  1671. END_OF_FILE
  1672. if test 4472 -ne `wc -c <'LOME/MacroIO.h'`; then
  1673.     echo shar: \"'LOME/MacroIO.h'\" unpacked with wrong size!
  1674. fi
  1675. # end of 'LOME/MacroIO.h'
  1676. fi
  1677. if test -f 'LOME/SCM.mac' -a "${1}" != "-c" ; then 
  1678.   echo shar: Will not clobber existing file \"'LOME/SCM.mac'\"
  1679. else
  1680. echo shar: Extracting \"'LOME/SCM.mac'\" \(4774 characters\)
  1681. sed "s/^X//" >'LOME/SCM.mac' <<'END_OF_FILE'
  1682. XFILE: SCM.mac
  1683. XThis file contains the macro definitions for SCM, the Simple Character
  1684. XManipulation language. This file must be changed from implementation to
  1685. Ximplementation. This file can serve as the first argument to Comp1.
  1686. XThis particular version is for generating C source code where longs
  1687. Xare 32 bits, shorts are more than 8 bits, and the MacroIO package in C
  1688. Xis available. 
  1689. X
  1690. X0$.$>
  1691. XBEGIN PROGRAM.
  1692. X/*
  1693. X * SCM Executable program.
  1694. X * Generated by SCM Macros.
  1695. X *
  1696. X */
  1697. X#include "PPL.h"
  1698. X#include "MacroIO.h"
  1699. X                        /* */
  1700. X/* Declare the memory cells */
  1701. X#define MEMSIZ 6000
  1702. Xlong MEM[MEMSIZ];
  1703. X                        /* */
  1704. X/* Declare the registers */
  1705. Xshort FA, FB, FC, FD, FE, FF, FG, FH, FI, FJ, FK, FL, FM;
  1706. Xshort FN, FO, FP, FQ, FR, FS, FT, FU, FV, FW, FX, FY, FZ;
  1707. Xshort F0, F1, F2, F3;
  1708. Xshort VA, VB, VC, VD, VE, VF, VG, VH, VI, VJ, VK, VL, VM;
  1709. Xshort VN, VO, VP, VQ, VR, VS, VT, VU, VV, VW, VX, VY, VZ;
  1710. Xshort V0, V1, V2, V3, V4, V5, V6, V7, V8, V9;
  1711. Xlong  PA, PB, PC, PD, PE, PF, PG, PH, PI, PJ, PK, PL, PM;
  1712. Xlong  PN, PO, PP, PQ, PR, PS, PT, PU, PV, PW, PX, PY, PZ;
  1713. Xlong  P0, P1, P2, P3, P4, P5, P6, P7, P8, P9;
  1714. X                        /* */
  1715. Xvoid Stop ARGS((short, short, long));
  1716. Xvoid Oops ARGS((char *));
  1717. X                        /* */
  1718. Xvoid Stop ARGS3(short,flg,short,val,long,ptr)
  1719. X{
  1720. X    PLStatus(1, "Stop!");
  1721. X    PLExit(PLsev_error);
  1722. X    }
  1723. X                        /* */
  1724. Xvoid Oops ARGS1(char*,s)
  1725. X{
  1726. X    PLStatus(1, "Oops:");
  1727. X    PLStatus(1, s);
  1728. X    PLExit(PLsev_error);
  1729. X    }
  1730. X                        /* */
  1731. X/* BEGIN PROGRAM. */
  1732. X                        /* */
  1733. X>
  1734. XEND PROGRAM.
  1735. X/* END PROGRAM. */
  1736. X/* End of generated file */
  1737. X>
  1738. XBEGIN MAIN ROUTINE.
  1739. X/* BEGIN MAIN ROUTINE. */
  1740. Xshort DoIt()
  1741. X{
  1742. X    F0 = 0; F1 = 1; F2 = 2; F3 = 3;
  1743. X    V0 = 0; V1 = 1; V2 = 2; V3 = 3; V4 = 4;
  1744. X    V5 = 5; V6 = 6; V7 = 7; V8 = 8; V9 = 9;
  1745. X    P0 = 0; P1 = 1; P2 = 2; P3 = 3; P4 = 4;
  1746. X    P5 = 5; P6 = 10;
  1747. X    P8 = ((long) MEM);
  1748. X    P9 = ((long) MEM) + sizeof(long) * MEMSIZ;
  1749. X    MStartIO(PLargcnt, PLarglist);
  1750. X>
  1751. XEND MAIN ROUTINE.
  1752. X/* END MAIN ROUTINE. */
  1753. X    MStopIO();
  1754. X    return 0;
  1755. X    }
  1756. X>
  1757. XBEGIN SUBROUTINE $.
  1758. X/* BEGIN SUBROUTINE $10. */
  1759. Xvoid Sub$10(void);
  1760. Xvoid Sub$10()
  1761. X{
  1762. X>
  1763. XEND SUBROUTINE $.
  1764. X/* END SUBROUTINE $10. */
  1765. X    return;
  1766. X    }
  1767. X>
  1768. XLABEL $$.
  1769. X    LABEL$10$20:
  1770. X>
  1771. XCHRDATA $$ $ $ $$.
  1772. X    {unsigned f = $30, v = '$40', p = $50*10+$60;
  1773. X    MEM[$10*10+$20] = (v << 24) | ((f & 3) << 22) | (p & 0x3FFFFF);}
  1774. X>
  1775. XNUMDATA $$ $ $$ $$.
  1776. X    {unsigned f = $30, v = $40*10+$50, p = $60*10+$70;
  1777. X    MEM[$10*10+$20] = (v << 24) | ((f & 3) << 22) | (p & 0x3FFFFF);}
  1778. X>
  1779. XSTOP $.
  1780. X    Stop(F$10, V$10, P$10);
  1781. X>
  1782. XCALL $.
  1783. X    Sub$10();
  1784. X>
  1785. XGET $ = MEM $.
  1786. X    if (P$20 < MEM || MEM + MEMSIZ <= P$20 || 0 != (P$20 & 3))
  1787. X    Oops("Get $00 out of range: P$20");
  1788. X    {long temp;
  1789. X    temp = * (long *) P$20;
  1790. X    V$10 = (temp >> 24) & 0xFF;
  1791. X    F$10 = (temp >> 22) & 0x03;
  1792. X    P$10 = (temp << 10) >> 10;  /* do sign extend */
  1793. X    }
  1794. X>
  1795. XPUT MEM $ = $.
  1796. X    if (P$10 < MEM || MEM + MEMSIZ <= P$10 || 0 != (P$20 & 3))
  1797. X    Oops("Put $00 out of range: P$10");
  1798. X    {long temp;
  1799. X    temp = (V$20 << 24) | ((F$20 & 3) << 22) | (P$20 & 0x3FFFFF);
  1800. X    * (long *) P$10 = temp;
  1801. X    }
  1802. X>
  1803. XFLG $ = $.
  1804. X    F$10 = F$20;
  1805. X>
  1806. XPTR $ = VAL $.
  1807. X    P$10 = (V$20 & 0xFF);
  1808. X>
  1809. XVAL $ = PTR $.
  1810. X    V$10 = (P$20 & 0xFF);
  1811. X>
  1812. XVAL $ = $ + $.
  1813. X    V$10 = V$20 + V$30;
  1814. X>
  1815. XVAL $ = $ - $.
  1816. X    V$10 = V$20 - V$30;
  1817. X>
  1818. XPTR $ = $ + $.
  1819. X    P$10 = P$20 + P$30;
  1820. X>
  1821. XPTR $ = $ - $.
  1822. X    P$10 = P$20 - P$30;
  1823. X>
  1824. XPTR $ = $ * $.
  1825. X    P$10 = P$20 * P$30;
  1826. X>
  1827. XPTR $ = $ / $.
  1828. X    P$10 = P$20 / P$30;
  1829. X>
  1830. XMOV PTR $ BY $.
  1831. X    P$10 = P$10 + sizeof(long) * P$20;
  1832. X>
  1833. XTO $$.
  1834. X    goto LABEL$10$20;
  1835. X>
  1836. XTO $$ IF FLG $ EQ $.
  1837. X    if (F$30 == F$40) goto LABEL$10$20;
  1838. X>
  1839. XTO $$ IF FLG $ NE $.
  1840. X    if (F$30 != F$40) goto LABEL$10$20;
  1841. X>
  1842. XTO $$ IF VAL $ EQ $.
  1843. X    if (V$30 == V$40) goto LABEL$10$20;
  1844. X>
  1845. XTO $$ IF VAL $ NE $.
  1846. X    if (V$30 != V$40) goto LABEL$10$20;
  1847. X>
  1848. XTO $$ IF PTR $ EQ $.
  1849. X    if (P$30 == P$40) goto LABEL$10$20;
  1850. X>
  1851. XTO $$ IF PTR $ NE $.
  1852. X    if (P$30 != P$40) goto LABEL$10$20;
  1853. X>
  1854. XTO $$ IF PTR $ LT $.
  1855. X    if (P$30 < P$40) goto LABEL$10$20;
  1856. X>
  1857. XREWIND $.
  1858. X    {long temp;
  1859. X    temp = MRewind(V$10);
  1860. X    if (temp == OK) F$10 = 0; else F$10 = 1;
  1861. X    }
  1862. X>
  1863. XGET BUFF $.
  1864. X    F$10 = MGetBuff(V$10);
  1865. X>
  1866. XPUT BUFF $.
  1867. X    F$10 = MPutBuff(V$10);
  1868. X>
  1869. XVAL $ = INPUT.
  1870. X    V$10 = MGetChar();
  1871. X>
  1872. XOUTPUT = VAL $.
  1873. X    V$10 = MPutChar(V$10);
  1874. X>
  1875. X.   An empty line will match
  1876. X>   An empty line will generate nothing
  1877. XDEBUG.
  1878. X>   The debug statement does nothing yet in compiled code
  1879. XMESSAGE $$$$ TO $.
  1880. X    MPutChar(0);
  1881. X    {long temp;
  1882. X    for (temp = 0; temp < 20; temp++)
  1883. X    MPutChar('*');
  1884. X    MPutChar($10);
  1885. X    MPutChar($20);
  1886. X    MPutChar($30);
  1887. X    MPutChar($40);
  1888. X    MPutChar(' ');
  1889. X    MPutChar('E');
  1890. X    MPutChar('R');
  1891. X    MPutChar('R');
  1892. X    MPutChar('O');
  1893. X    MPutChar('R');
  1894. X    MPutChar('!');
  1895. X    MPutChar(0);
  1896. X    temp = MPutBuff(V$50);
  1897. X    if (temp == OK) F$50 = 0;
  1898. X    else if (temp == EOF) F$50 = 1;
  1899. X    else if (temp == ILLEGAL) F$50 = 2;
  1900. X    }
  1901. X>
  1902. END_OF_FILE
  1903. if test 4774 -ne `wc -c <'LOME/SCM.mac'`; then
  1904.     echo shar: \"'LOME/SCM.mac'\" unpacked with wrong size!
  1905. fi
  1906. # end of 'LOME/SCM.mac'
  1907. fi
  1908. echo shar: End of archive 3 \(of 9\).
  1909. cp /dev/null ark3isdone
  1910. MISSING=""
  1911. for I in 1 2 3 4 5 6 7 8 9 ; do
  1912.     if test ! -f ark${I}isdone ; then
  1913.     MISSING="${MISSING} ${I}"
  1914.     fi
  1915. done
  1916. if test "${MISSING}" = "" ; then
  1917.     echo You have unpacked all 9 archives.
  1918.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1919. else
  1920.     echo You still need to unpack the following archives:
  1921.     echo "        " ${MISSING}
  1922. fi
  1923. ##  End of shell archive.
  1924. exit 0
  1925. -- 
  1926. --- Darren New --- Grad Student --- CIS --- Univ. of Delaware ---
  1927.  
  1928. exit 0 # Just in case...
  1929. -- 
  1930. Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.
  1931. Use a domain-based address or give alternate paths, or you may lose out.
  1932.