home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2184 < prev    next >
Internet Message Format  |  1990-12-28  |  36KB

  1. From: markz@ssc.UUCP (Mark Zenier)
  2. Newsgroups: alt.sources
  3. Subject: Frankenstein Cross Assemblers, Base source, Part 3 of 3
  4. Message-ID: <594@ssc.UUCP>
  5. Date: 4 Dec 90 07:49:20 GMT
  6.  
  7. ---- Cut Here and feed the following to sh ----
  8. #!/bin/sh
  9. # This is part 03 of Frankasm/Base
  10. # ============= fryylex.c ==============
  11. if test -f 'fryylex.c' -a X"$1" != X"-c"; then
  12.     echo 'x - skipping fryylex.c (File already exists)'
  13. else
  14. echo 'x - extracting fryylex.c (Text)'
  15. sed 's/^X//' << 'SHAR_EOF' > 'fryylex.c' &&
  16. X/*
  17. XHEADER:     ;
  18. XTITLE:         Frankenstein Cross Assemblers;
  19. XVERSION:     2.0;
  20. XDESCRIPTION: "    Reconfigurable Cross-assembler producing Intel (TM)
  21. X        Hex format object records.  ";
  22. XKEYWORDS:     cross-assemblers, 1805, 2650, 6301, 6502, 6805, 6809, 
  23. X        6811, tms7000, 8048, 8051, 8096, z8, z80;
  24. XSYSTEM:     UNIX, MS-Dos ;
  25. XFILENAME:     fryylex.c;
  26. XWARNINGS:     "This software is in the public domain.  
  27. X        Any prior copyright claims are relinquished.  
  28. X
  29. X        This software is distributed with no warranty whatever.  
  30. X        The author takes no responsibility for the consequences 
  31. X        of its use.
  32. X
  33. X        Yacc (or Bison) required to compile."  ;
  34. XSEE-ALSO:     as*.y (yacc input files);
  35. XAUTHORS:     Mark Zenier;
  36. XCOMPILERS:     Microport Sys V/AT, ATT Yacc, Turbo C V1.5, Bison (CUG disk 285)
  37. X        (previous versions Xenix, Unisoft 68000 Version 7, Sun 3);
  38. X*/
  39. X
  40. X
  41. X/*
  42. X    description    lexical analyzer for framework cross assembler
  43. X    usage        Framework cross assembler, Unix
  44. X    history        September 13, 1987
  45. X            September 14, 1990  Dosify, 6 char unique names
  46. X            October, 1990  hand carved scanner
  47. X*/
  48. X
  49. X#include <stdio.h>
  50. X#include "frasmdat.h"
  51. X#include "fraytok.h"
  52. X
  53. X#ifndef DEBUG
  54. X#define DEBUG 0
  55. X#endif
  56. X
  57. X    extern YYSTYPE yylval; 
  58. X
  59. X    enum symflag {Symopcode, Symsym} whichsym = Symopcode;
  60. X
  61. X    FILE *yyin;
  62. X
  63. X    char finbuff[INBUFFSZ] = "L:"; 
  64. X        /* initialization nonreusable, wiped out by pass 2 */
  65. X    static char *frainptr = &finbuff[2];
  66. X        /* point to null byte after L: on start up */
  67. X    enum readacts nextreadact = Nra_normal;
  68. X
  69. X
  70. Xfrareadrec()
  71. X/*
  72. X    description    read a line, on end of file, pop the include file
  73. X            stack.
  74. X    return        FALSE    got a line
  75. X            TRUE    end of input
  76. X*/
  77. X{
  78. X    while( fgets(&finbuff[2], INBUFFSZ -2, yyin) == (char *)NULL)
  79. X    {
  80. X        if(currfstk == 0)
  81. X        {
  82. X            return TRUE;
  83. X        }
  84. X        else
  85. X        {
  86. X            fclose(yyin);
  87. X            yyin = infilestk[--currfstk].fpt;
  88. X            fprintf(intermedf, "X:%s\n",infilestk[currfstk].fnm);
  89. X        }
  90. X    }
  91. X    return FALSE;
  92. X}
  93. X
  94. Xstatic int currtok=0; /* subscript of next token to return */
  95. Xstatic int intokcnt=0; /* number of tokens in queue */
  96. X
  97. Xstatic struct
  98. X{
  99. X    char *textstrt, *textend;
  100. X    YYSTYPE  lvalv;
  101. X    int tokv; 
  102. X    enum {Yetprint, Yetsymbol, Yetreserved, Yetopcode, 
  103. X        Yetconstant, Yetstring, Yetunprint, Yetinvalid } errtype;
  104. X}  scanqueue[INBUFFSZ], *lasttokfetch, *nexttokload;
  105. X
  106. Xstatic char tempstrpool[2*INBUFFSZ];
  107. Xstatic char *tptrstr;
  108. X
  109. X#define     CXC00_SKIP    0
  110. X#define     CXC01_SPACE    1
  111. X#define     CXC02_NL    2
  112. X#define     CXC03_LETTER    3
  113. X#define     CXC04_QUOTE    4
  114. X#define     CXC05_OTHER    5
  115. X#define     CXC06_DOLLAR    6
  116. X#define     CXC07_PERCENT    7
  117. X#define     CXC08_APP    8
  118. X#define     CXC09_BIN    9
  119. X#define     CXC10_OCT    10
  120. X#define     CXC11_DEC    11
  121. X#define     CXC12_SEMIC    12
  122. X#define     CXC13_LT    13
  123. X#define     CXC14_EQ    14
  124. X#define     CXC15_GT    15
  125. X#define     CXC16_AT    16
  126. X#define     CXC17_HEXU    17
  127. X#define     CXC18_B    18
  128. X#define     CXC19_D    19
  129. X#define     CXC20_H    20
  130. X#define     CXC21_OQ    21
  131. X#define     CXC22_HEXL    22
  132. X#define     CXC23_BL    23
  133. X#define     CXC24_DL    24
  134. X#define     CXC25_BSLASH    25
  135. X#define  NUMCHARSETS    26
  136. X
  137. Xstatic char chartrantab[128] = {
  138. X/* 00 nul soh stx etx*/  CXC00_SKIP, CXC00_SKIP, CXC00_SKIP, CXC00_SKIP,
  139. X/* 04 eot enq ack bel*/  CXC00_SKIP, CXC00_SKIP, CXC00_SKIP, CXC00_SKIP,
  140. X/* 08 bs  ht  nl  vt */  CXC00_SKIP, CXC01_SPACE, CXC02_NL, CXC00_SKIP,
  141. X/* 0c np  cr  so  si */  CXC00_SKIP, CXC00_SKIP, CXC00_SKIP, CXC00_SKIP,
  142. X/* 10 dle dc1 dc2 dc3*/  CXC00_SKIP, CXC00_SKIP, CXC00_SKIP, CXC00_SKIP,
  143. X/* 14 dc4 nak syn etb*/  CXC00_SKIP, CXC00_SKIP, CXC00_SKIP, CXC00_SKIP,
  144. X/* 18 can em  sub esc*/  CXC00_SKIP, CXC00_SKIP, CXC00_SKIP, CXC00_SKIP,
  145. X/* 1c fs  gs  rs  us */  CXC00_SKIP, CXC00_SKIP, CXC00_SKIP, CXC00_SKIP,
  146. X/* 20 sp  !  "  # */  CXC01_SPACE, CXC03_LETTER, CXC04_QUOTE, CXC05_OTHER,
  147. X/* 24  $  %  &  ' */  CXC06_DOLLAR, CXC07_PERCENT, CXC03_LETTER, CXC08_APP,
  148. X/* 28  (  )  *  + */  CXC05_OTHER, CXC05_OTHER, CXC05_OTHER, CXC05_OTHER,
  149. X/* 2c  ,  -  .  / */  CXC05_OTHER, CXC05_OTHER, CXC05_OTHER, CXC05_OTHER,
  150. X/* 30  0  1  2  3 */  CXC09_BIN, CXC09_BIN, CXC10_OCT, CXC10_OCT,
  151. X/* 34  4  5  6  7 */  CXC10_OCT, CXC10_OCT, CXC10_OCT, CXC10_OCT,
  152. X/* 38  8  9  :  ; */  CXC11_DEC, CXC11_DEC, CXC05_OTHER, CXC12_SEMIC,
  153. X/* 3c  <  =  >  ? */  CXC13_LT, CXC14_EQ, CXC15_GT, CXC05_OTHER,
  154. X/* 40  @  A  B  C */  CXC16_AT, CXC17_HEXU, CXC18_B, CXC17_HEXU,
  155. X/* 44  D  E  F  G */  CXC19_D, CXC17_HEXU, CXC17_HEXU, CXC03_LETTER,
  156. X/* 48  H  I  J  K */  CXC20_H, CXC03_LETTER, CXC03_LETTER, CXC03_LETTER,
  157. X/* 4c  L  M  N  O */  CXC03_LETTER, CXC03_LETTER, CXC03_LETTER, CXC21_OQ,
  158. X/* 50  P  Q  R  S */  CXC03_LETTER, CXC21_OQ, CXC03_LETTER, CXC03_LETTER,
  159. X/* 54  T  U  V  W */  CXC03_LETTER, CXC03_LETTER, CXC03_LETTER, CXC03_LETTER,
  160. X/* 58  X  Y  Z  [ */  CXC03_LETTER, CXC03_LETTER, CXC03_LETTER, CXC05_OTHER,
  161. X/* 5c  \  ]  ^  _ */  CXC25_BSLASH, CXC05_OTHER, CXC03_LETTER, CXC03_LETTER,
  162. X/* 60  `  a  b  c */  CXC05_OTHER, CXC22_HEXL, CXC23_BL, CXC22_HEXL,
  163. X/* 64  d  e  f  g */  CXC24_DL, CXC22_HEXL, CXC22_HEXL, CXC03_LETTER,
  164. X/* 68  h  i  j  k */  CXC20_H, CXC03_LETTER, CXC03_LETTER, CXC03_LETTER,
  165. X/* 6c  l  m  n  o */  CXC03_LETTER, CXC03_LETTER, CXC03_LETTER, CXC21_OQ,
  166. X/* 70  p  q  r  s */  CXC03_LETTER, CXC21_OQ, CXC03_LETTER, CXC03_LETTER,
  167. X/* 74  t  u  v  w */  CXC03_LETTER, CXC03_LETTER, CXC03_LETTER, CXC03_LETTER,
  168. X/* 78  x  y  z  { */  CXC03_LETTER, CXC03_LETTER, CXC03_LETTER, CXC05_OTHER,
  169. X/* 7c vb  }  ~  del*/  CXC05_OTHER, CXC05_OTHER, CXC03_LETTER, CXC00_SKIP } ;
  170. X
  171. X
  172. X#if DEBUG
  173. X
  174. Xstatic char * statelab[] = {
  175. X        " 0 start of label",
  176. X        " 1 comment",
  177. X        " 2 label",
  178. X        " 3 rest of line",
  179. X        " 4 symbol",
  180. X        " 5 dollar",
  181. X        " 6 hex dollar",
  182. X        " 7 at sign",
  183. X        " 8 octal at",
  184. X        " 9 percent",
  185. X        "10 bin percent",
  186. X        "11 quote string",
  187. X        "12 appos. string",
  188. X        "13 greater than",
  189. X        "14 less than",
  190. X        "15 base 2 maybe",
  191. X        "16 base 8 maybe",
  192. X        "17 base 10 maybe",
  193. X        "18 hex",
  194. X        "19 found b ",
  195. X        "20 found d",
  196. X        "21 bslash quote",
  197. X        "22 bslash appos",
  198. X        };
  199. X            
  200. Xstatic char *actlab[] = {
  201. X        " 0 skip/no op",
  202. X        " 1 load EOL token",
  203. X        " 2 start string",
  204. X        " 3 process label",
  205. X        " 4 save string char",
  206. X        " 5 load single char token",
  207. X        " 6 load EQ token",
  208. X        " 7 process symbol",
  209. X        " 8 load $ token",
  210. X        " 9 setup for $hex",
  211. X        "10 accumulate 0-9 constant",
  212. X        "11 accumulate A-F constant",
  213. X        "12 accumulate a-f constant",
  214. X        "13 load Constant token",
  215. X        "14 load @ token",
  216. X        "15 setup for @octal",
  217. X        "16 setup for %binary",
  218. X        "17 load % token",
  219. X        "18 load String token",
  220. X        "19 load GE token",
  221. X        "20 load GT token",
  222. X        "21 load LE token",
  223. X        "22 load NE token",
  224. X        "23 load LT token",
  225. X        "24 save numeric char 0-9",
  226. X        "25 save numeric char A-F",
  227. X        "26 save numeric char a-f",
  228. X        "27 convert numeric string base 2",
  229. X        "28 convert numeric string base 8",
  230. X        "29 convert numeric string base 10",
  231. X        "30 convert numeric string base 16",
  232. X        "31 save numeric 0xb",
  233. X        "32 save numeric 0xd",
  234. X        "33 set text start",
  235. X        "34 token choke"
  236. X        };
  237. X
  238. X#endif  /* DEBUG */
  239. X
  240. Xstatic struct
  241. X{
  242. X    char action;
  243. X    char nextstate;
  244. X    char contin;
  245. X}     *thisact, characttab [23][NUMCHARSETS] =
  246. X{
  247. X/*
  248. X    STATE 0 =    {start of label}
  249. X*/
  250. X    {
  251. X    /* SKIP    */      /* SPACE   */    /* NL      */      /* LETTER  */ 
  252. X    /* QUOTE   */      /* OTHER   */    /* DOLLAR  */      /* PERCENT */ 
  253. X    /* APP     */      /* BIN     */     /* OCT     */      /* DEC     */ 
  254. X    /* SEMIC   */      /* LT      */    /* EQ      */      /* GT      */ 
  255. X    /* AT      */      /* HEXU    */    /* B       */      /* D       */ 
  256. X    /* H       */      /* OQ      */    /* HEXL    */      /* BL      */ 
  257. X    /* DL      */     /* BSLASH  */
  258. X    {0, 0, FALSE},    {0, 3, FALSE},    {1, 0, FALSE},    {2, 2, TRUE},
  259. X    {2,11, FALSE},    {5, 3, FALSE},    {33, 5, FALSE},    {33, 9, FALSE},
  260. X    {2,12, FALSE},    {2,15, TRUE},    {2,16, TRUE},    {2,17, TRUE},
  261. X    {0, 1, FALSE},    {0,14, FALSE},    {6, 3, FALSE},    {0,13, FALSE},
  262. X    {33, 7, FALSE},    {2, 2, TRUE},    {2, 2, TRUE},    {2, 2, TRUE},
  263. X    {2, 2, TRUE},    {2, 2, TRUE},    {2, 2, TRUE},    {2, 2, TRUE},
  264. X    {2, 2, TRUE},    {5, 3, FALSE}
  265. X    },
  266. X
  267. X/*
  268. X    STATE 1 =    {comment}
  269. X*/
  270. X    {
  271. X    {0, 1, FALSE},    {0, 1, FALSE},    {1, 0, FALSE},    {0, 1, FALSE},
  272. X    {0, 1, FALSE},    {0, 1, FALSE},    {0, 1, FALSE},    {0, 1, FALSE},
  273. X    {0, 1, FALSE},    {0, 1, FALSE},    {0, 1, FALSE},    {0, 1, FALSE},
  274. X    {0, 1, FALSE},    {0, 1, FALSE},    {0, 1, FALSE},    {0, 1, FALSE},
  275. X    {0, 1, FALSE},    {0, 1, FALSE},    {0, 1, FALSE},    {0, 1, FALSE},
  276. X    {0, 1, FALSE},    {0, 1, FALSE},    {0, 1, FALSE},    {0, 1, FALSE},
  277. X    {0, 1, FALSE},    {0, 1, FALSE} 
  278. X    },
  279. X
  280. X/*
  281. X    STATE 2 =    {label}
  282. X*/
  283. X    {
  284. X    {0, 2, FALSE},    {3, 3, FALSE},    {3, 3, TRUE},    {4, 2, FALSE},
  285. X    {3, 3, TRUE},    {3, 3, TRUE},    {3, 3, TRUE},    {3, 3, TRUE},
  286. X    {3, 3, TRUE},    {4, 2, FALSE},    {4, 2, FALSE},    {4, 2, FALSE},
  287. X    {3, 1, FALSE},    {3,14, FALSE},    {3, 3, TRUE},    {3,13, FALSE},
  288. X    {3, 3, TRUE},    {4, 2, FALSE},    {4, 2, FALSE},    {4, 2, FALSE},
  289. X    {4, 2, FALSE},    {4, 2, FALSE},    {4, 2, FALSE},    {4, 2, FALSE},
  290. X    {4, 2, FALSE},  {3, 3, TRUE} 
  291. X    },
  292. X
  293. X/*
  294. X    STATE 3  =    {rest of line}
  295. X*/
  296. X    {
  297. X    {0, 3, FALSE},    {0, 3, FALSE},    {1, 0, FALSE},    {2, 4, TRUE},
  298. X    {2,11, FALSE},    {5, 3, FALSE},    {33, 5, FALSE},    {33, 9, FALSE},
  299. X    {2,12, FALSE},    {2,15, TRUE},    {2,16, TRUE},    {2,17, TRUE},
  300. X    {0, 1, FALSE},    {0,14, FALSE},    {6, 3, FALSE},    {0,13, FALSE},
  301. X    {33, 7, FALSE},    {2, 4, TRUE},    {2, 4, TRUE},    {2, 4, TRUE},
  302. X    {2, 4, TRUE},    {2, 4, TRUE},    {2, 4, TRUE},    {2, 4, TRUE},
  303. X    {2, 4, TRUE} ,    {5, 3, FALSE}
  304. X    },
  305. X
  306. X/*
  307. X    STATE 4 =    {symbol}
  308. X*/
  309. X    {
  310. X    {0, 4, FALSE},    {7, 3, FALSE},    {7, 3, TRUE},    {4, 4, FALSE},
  311. X    {7, 3, TRUE},    {7, 3, TRUE},    {7, 3, TRUE},    {7, 3, TRUE},
  312. X    {7, 3, TRUE},    {4, 4, FALSE},    {4, 4, FALSE},    {4, 4, FALSE},
  313. X    {7, 1, FALSE},    {7,14, FALSE},    {7, 3, TRUE},    {7,13, FALSE},
  314. X    {7, 3, TRUE},    {4, 4, FALSE},    {4, 4, FALSE},    {4, 4, FALSE},
  315. X    {4, 4, FALSE},    {4, 4, FALSE},    {4, 4, FALSE},    {4, 4, FALSE},
  316. X    {4, 4, FALSE},    {7, 3, TRUE}
  317. X    },
  318. X
  319. X/*
  320. X    STATE 5 =    {dollar}
  321. X*/
  322. X    {
  323. X    {0, 5, FALSE},    {8, 3, FALSE},    {8, 3, TRUE},    {8, 3, TRUE},
  324. X    {8, 3, TRUE},    {8, 3, TRUE},    {8, 3, TRUE},    {8, 3, TRUE},
  325. X    {8, 3, TRUE},    {9, 6, TRUE},    {9, 6, TRUE},    {9, 6, TRUE},
  326. X    {8, 1, FALSE},    {8,14, FALSE},    {8, 3, TRUE},    {8,13, FALSE},
  327. X    {8, 3, TRUE},    {9, 6, TRUE},    {9, 6, TRUE},    {9, 6, TRUE},
  328. X    {8, 3, TRUE},    {8, 3, TRUE},    {9, 6, TRUE},    {9, 6, TRUE},
  329. X    {9, 6, TRUE} ,    {8, 3, TRUE}
  330. X    },
  331. X
  332. X/*
  333. X    STATE 6 =    {dollar hex}
  334. X*/
  335. X
  336. X    {
  337. X    {0, 6, FALSE},    {13, 3, FALSE},    {13, 3, TRUE},    {13, 3, TRUE},
  338. X    {13, 3, TRUE},    {13, 3, TRUE},    {13, 3, TRUE},    {13, 3, TRUE},
  339. X    {13, 3, TRUE},    {10, 6, FALSE},    {10, 6, FALSE},    {10, 6, FALSE},
  340. X    {13, 1, FALSE},    {13,14, FALSE},    {13, 3, TRUE},    {13,13, FALSE},
  341. X    {13, 3, TRUE},    {11, 6, FALSE},    {11, 6, FALSE},    {11, 6, FALSE},
  342. X    {13, 3, TRUE},    {13, 3, TRUE},    {12, 6, FALSE},    {12, 6, FALSE},
  343. X    {12, 6, FALSE},    {13, 3, TRUE}
  344. X    },
  345. X/*
  346. X    STATE 7 =    {at sign}
  347. X*/
  348. X    {
  349. X    {0, 7, FALSE},    {14, 3, FALSE},    {14, 3, TRUE},    {14, 3, TRUE},
  350. X    {14, 3, TRUE},    {14, 3, TRUE},    {14, 3, TRUE},    {14, 3, TRUE},
  351. X    {14, 3, TRUE},    {15, 8, TRUE},    {15, 8, TRUE},    {14, 3, TRUE},
  352. X    {14, 1, FALSE},    {14,14, FALSE},    {14, 3, TRUE},    {14,13, FALSE},
  353. X    {14, 3, TRUE},    {14, 3, TRUE},    {14, 3, TRUE},    {14, 3, TRUE},
  354. X    {14, 3, TRUE},    {14, 3, TRUE},    {14, 3, TRUE},    {14, 3, TRUE},
  355. X    {14, 3, TRUE},    {14, 3, TRUE}
  356. X    },
  357. X
  358. X/*
  359. X    STATE 8 =    {at octal}
  360. X*/
  361. X    {
  362. X    {0, 8, FALSE},    {13, 3, FALSE},    {13, 3, TRUE},    {13, 3, TRUE},
  363. X    {13, 3, TRUE},    {13, 3, TRUE},    {13, 3, TRUE},    {13, 3, TRUE},
  364. X    {13, 3, TRUE},    {10, 8, FALSE},    {10, 8, FALSE},    {13, 3, TRUE},
  365. X    {13, 1, FALSE},    {13,14, FALSE},    {13, 3, TRUE},    {13,13, FALSE},
  366. X    {13, 3, TRUE},    {13, 3, TRUE},    {13, 3, TRUE},    {13, 3, TRUE},
  367. X    {13, 3, TRUE},    {13, 3, TRUE},    {13, 3, TRUE},    {13, 3, TRUE},
  368. X    {13, 3, TRUE},    {13, 3, TRUE}
  369. X    },
  370. X
  371. X/*
  372. X    STATE 9 =    {percent}
  373. X*/
  374. X    {
  375. X    {0, 9, FALSE},    {17, 3, FALSE},    {17, 3, TRUE},    {17, 3, TRUE},
  376. X    {17, 3, TRUE},    {17, 3, TRUE},    {17, 3, TRUE},    {17, 3, TRUE},
  377. X    {17, 3, TRUE},    {16,10, TRUE},    {17, 3, TRUE},    {17, 3, TRUE},
  378. X    {17, 1, FALSE},    {17,14, FALSE},    {17, 3, TRUE},    {17,13, FALSE},
  379. X    {17, 3, TRUE},    {17, 3, TRUE},    {17, 3, TRUE},    {17, 3, TRUE},
  380. X    {17, 3, TRUE},    {17, 3, TRUE},    {17, 3, TRUE},    {17, 3, TRUE},
  381. X    {17, 3, TRUE},    {17, 3, TRUE}
  382. X    },
  383. X
  384. X/*
  385. X    STATE 10 =    {percent binary}
  386. X*/
  387. X    {
  388. X    {0,10, FALSE},    {13, 3, FALSE},    {13, 3, TRUE},    {13, 3, TRUE},
  389. X    {13, 3, TRUE},    {13, 3, TRUE},    {13, 3, TRUE},    {13, 3, TRUE},
  390. X    {13, 3, TRUE},    {10,10, FALSE},    {13, 3, TRUE},    {13, 3, TRUE},
  391. X    {13, 1, FALSE},    {13,14, FALSE},    {13, 3, TRUE},    {13,13, FALSE},
  392. X    {13, 3, TRUE},    {13, 3, TRUE},    {13, 3, TRUE},    {13, 3, TRUE},
  393. X    {13, 3, TRUE},    {13, 3, TRUE},    {13, 3, TRUE},    {13, 3, TRUE},
  394. X    {13, 3, TRUE},    {13, 3, TRUE}
  395. X    },
  396. X
  397. X/*
  398. X    STATE 11 =    {quote string}
  399. X*/
  400. X    {
  401. X    {0,11, FALSE},    {4,11, FALSE},    {34, 3, TRUE},    {4,11, FALSE},
  402. X    {18, 3, FALSE},    {4,11, FALSE},    {4,11, FALSE},    {4,11, FALSE},
  403. X    {4,11, FALSE},    {4,11, FALSE},    {4,11, FALSE},    {4,11, FALSE},
  404. X    {4,11, FALSE},    {4,11, FALSE},    {4,11, FALSE},    {4,11, FALSE},
  405. X    {4,11, FALSE},    {4,11, FALSE},    {4,11, FALSE},    {4,11, FALSE},
  406. X    {4,11, FALSE},    {4,11, FALSE},    {4,11, FALSE},    {4,11, FALSE},
  407. X    {4,11, FALSE},  {4,21, FALSE}
  408. X    },
  409. X
  410. X/*
  411. X    STATE 12 =    {app string}
  412. X*/
  413. X    {
  414. X    {0,12, FALSE},    {4,12, FALSE},    {34, 3, TRUE},    {4,12, FALSE},
  415. X    {4,12, FALSE},    {4,12, FALSE},    {4,12, FALSE},    {4,12, FALSE},
  416. X    {18, 3, FALSE},    {4,12, FALSE},    {4,12, FALSE},    {4,12, FALSE},
  417. X    {4,12, FALSE},    {4,12, FALSE},    {4,12, FALSE},    {4,12, FALSE},
  418. X    {4,12, FALSE},    {4,12, FALSE},    {4,12, FALSE},    {4,12, FALSE},
  419. X    {4,12, FALSE},    {4,12, FALSE},    {4,12, FALSE},    {4,12, FALSE},
  420. X    {4,12, FALSE},    {4,22, FALSE}
  421. X    },
  422. X
  423. X/*
  424. X    STATE 13 =    {greater than}
  425. X*/
  426. X    {
  427. X    {0,13, FALSE},    {20, 3, FALSE},    {20, 3, TRUE},    {20, 3, TRUE},
  428. X    {20, 3, TRUE},    {20, 3, TRUE},    {20, 3, TRUE},    {20, 3, TRUE},
  429. X    {20, 3, TRUE},    {20, 3, TRUE},    {20, 3, TRUE},    {20, 3, TRUE},
  430. X    {20, 1, FALSE},    {20,14, FALSE},    {19, 3, FALSE},    {20,13, FALSE},
  431. X    {20, 3, TRUE},    {20, 3, TRUE},    {20, 3, TRUE},    {20, 3, TRUE},
  432. X    {20, 3, TRUE},    {20, 3, TRUE},    {20, 3, TRUE},    {20, 3, TRUE},
  433. X    {20, 3, TRUE},    {20, 3, TRUE}
  434. X    },
  435. X
  436. X/*
  437. X    STATE 14 =    {less than}
  438. X*/
  439. X    {
  440. X    {0,14, FALSE},    {23, 3, FALSE},    {23, 3, TRUE},    {23, 3, TRUE},
  441. X    {23, 3, TRUE},    {23, 3, TRUE},    {23, 3, TRUE},    {23, 3, TRUE},
  442. X    {23, 3, TRUE},    {23, 3, TRUE},    {23, 3, TRUE},    {23, 3, TRUE},
  443. X    {23, 1, FALSE},    {23,14, FALSE},    {21, 3, FALSE},    {22,13, FALSE},
  444. X    {23, 3, TRUE},    {23, 3, TRUE},    {23, 3, TRUE},    {23, 3, TRUE},
  445. X    {23, 3, TRUE},    {23, 3, TRUE},    {23, 3, TRUE},    {23, 3, TRUE},
  446. X    {23, 3, TRUE},    {23, 3, TRUE}
  447. X    },
  448. X
  449. X/*
  450. X    STATE 15 =    {base 2 maybe}
  451. X*/
  452. X    {
  453. X    {0,15, FALSE},    {29, 3, FALSE},    {29, 3, TRUE},    {29, 3, TRUE},
  454. X    {29, 3, TRUE},    {29, 3, TRUE},    {29, 3, TRUE},    {29, 3, TRUE},
  455. X    {29, 3, TRUE},    {24,15, FALSE},    {24,16, FALSE},    {24,17, FALSE},
  456. X    {29, 1, FALSE},    {29,14, FALSE},    {29, 3, TRUE},    {29,13, FALSE},
  457. X    {29, 3, TRUE},    {25,18, FALSE},    {0,19, FALSE},    {0,20, FALSE},
  458. X    {30, 3, FALSE},    {28, 3, FALSE},    {26,18, FALSE},    {0,19, FALSE},
  459. X    {0,20, FALSE},    {29, 3, TRUE}
  460. X    },
  461. X
  462. X/*
  463. X    STATE 16 =    {base 8 maybe}
  464. X*/
  465. X    {    
  466. X    {0,16, FALSE},    {29, 3, FALSE},    {29, 3, TRUE},    {29, 3, TRUE},
  467. X    {29, 3, TRUE},    {29, 3, TRUE},    {29, 3, TRUE},    {29, 3, TRUE},
  468. X    {29, 3, TRUE},    {24,16, FALSE},    {24,16, FALSE},    {24,17, FALSE},
  469. X    {29, 1, FALSE},    {29,14, FALSE},    {29, 3, TRUE},    {29,13, FALSE},
  470. X    {29, 3, TRUE},    {25,18, FALSE},    {25,18, FALSE},    {0,20, FALSE},
  471. X    {30, 3, FALSE},    {28, 3, FALSE},    {26,18, FALSE},    {26,18, FALSE},
  472. X    {0,20, FALSE},    {29, 3, TRUE}
  473. X    },
  474. X
  475. X/*
  476. X    STATE 17 =    {base10 maybe}
  477. X*/
  478. X    {    
  479. X    {0,17, FALSE},    {29, 3, FALSE},    {29, 3, TRUE},    {29, 3, TRUE},
  480. X    {29, 3, TRUE},    {29, 3, TRUE},    {29, 3, TRUE},    {29, 3, TRUE},
  481. X    {29, 3, TRUE},    {24,17, FALSE},    {24,17, FALSE},    {24,17, FALSE},
  482. X    {29, 1, FALSE},    {29,14, FALSE},    {29, 3, TRUE},    {29,13, FALSE},
  483. X    {29, 3, TRUE},    {25,18, FALSE},    {25,18, FALSE},    {0,20, FALSE},
  484. X    {30, 3, FALSE},    {34, 3, FALSE},    {26,18, FALSE},    {26,18, FALSE},
  485. X    {0,20, FALSE},    {29, 3, TRUE}
  486. X    },
  487. X
  488. X/*
  489. X    STATE 18 =    {hex}
  490. X*/
  491. X    {    
  492. X    {0,18, FALSE},    {34, 3, FALSE},    {34, 3, TRUE},    {34, 3, TRUE},
  493. X    {34, 3, TRUE},    {34, 3, TRUE},    {34, 3, TRUE},    {34, 3, TRUE},
  494. X    {34, 3, TRUE},    {24,18, FALSE},    {24,18, FALSE},    {24,18, FALSE},
  495. X    {34, 1, FALSE},    {34,14, FALSE},    {34, 3, TRUE},    {34,13, FALSE},
  496. X    {34, 3, TRUE},    {25,18, FALSE},    {25,18, FALSE},    {25,18, FALSE},
  497. X    {30, 3, FALSE},    {34, 3, TRUE},    {26,18, FALSE},    {26,18, FALSE},
  498. X    {26,18, FALSE},    {34, 3, TRUE}
  499. X    },
  500. X
  501. X/*
  502. X    STATE 19 =    {bin or hex}
  503. X*/
  504. X    {    
  505. X    {0,19, FALSE},    {27, 3, FALSE},    {27, 3, TRUE},    {27, 3, TRUE},
  506. X    {27, 3, TRUE},    {27, 3, TRUE},    {27, 3, TRUE},    {27, 3, TRUE},
  507. X    {27, 3, TRUE},    {31,18, TRUE},    {31,18, TRUE},    {31,18, TRUE},
  508. X    {27, 1, FALSE},    {27,14, FALSE},    {27, 3, TRUE},    {27,13, FALSE},
  509. X    {27, 3, TRUE},    {31,18, TRUE},    {31,18, TRUE},    {31,18, TRUE},
  510. X    {31,18, TRUE},    {27, 3, TRUE},    {31,18, TRUE},    {31,18, TRUE},
  511. X    {31,18, TRUE},    {27, 3, TRUE}
  512. X    },
  513. X
  514. X/*
  515. X    STATE 20 =    {dec or hex}
  516. X*/
  517. X    {    
  518. X    {0,20, FALSE},    {29, 3, FALSE},    {29, 3, TRUE},    {29, 3, TRUE},
  519. X    {29, 3, TRUE},    {29, 3, TRUE},    {29, 3, TRUE},    {29, 3, TRUE},
  520. X    {29, 3, TRUE},    {32,18, TRUE},    {32,18, TRUE},    {32,18, TRUE},
  521. X    {29, 1, FALSE},    {29,14, FALSE},    {29, 3, TRUE},    {29,13, FALSE},
  522. X    {29, 3, TRUE},    {32,18, TRUE},    {32,18, TRUE},    {32,18, TRUE},
  523. X    {32,18, TRUE},    {29, 3, TRUE},    {32,18, TRUE},    {32,18, TRUE},
  524. X    {32,18, TRUE},    {29, 3, TRUE}
  525. X    },
  526. X
  527. X/*
  528. X    STATE 21 =    {bslash quote}
  529. X*/
  530. X    {
  531. X    {0,21, FALSE},    {4,11, FALSE},    {34, 3, TRUE},    {4,11, FALSE},
  532. X    {4,11, FALSE},    {4,11, FALSE},    {4,11, FALSE},    {4,11, FALSE},
  533. X    {4,11, FALSE},    {4,11, FALSE},    {4,11, FALSE},    {4,11, FALSE},
  534. X    {4,11, FALSE},    {4,11, FALSE},    {4,11, FALSE},    {4,11, FALSE},
  535. X    {4,11, FALSE},    {4,11, FALSE},    {4,11, FALSE},    {4,11, FALSE},
  536. X    {4,11, FALSE},    {4,11, FALSE},    {4,11, FALSE},    {4,11, FALSE},
  537. X    {4,11, FALSE},  {4,11, FALSE}
  538. X    },
  539. X
  540. X/*
  541. X    STATE 22 =    {bslash appos}
  542. X*/
  543. X    {
  544. X    {0,22, FALSE},    {4,12, FALSE},    {34, 3, TRUE},    {4,12, FALSE},
  545. X    {4,12, FALSE},    {4,12, FALSE},    {4,12, FALSE},    {4,12, FALSE},
  546. X    {4,12, FALSE},    {4,12, FALSE},    {4,12, FALSE},    {4,12, FALSE},
  547. X    {4,12, FALSE},    {4,12, FALSE},    {4,12, FALSE},    {4,12, FALSE},
  548. X    {4,12, FALSE},    {4,12, FALSE},    {4,12, FALSE},    {4,12, FALSE},
  549. X    {4,12, FALSE},    {4,12, FALSE},    {4,12, FALSE},    {4,12, FALSE},
  550. X    {4,12, FALSE},    {4,12, FALSE}
  551. X    }
  552. X};
  553. X    
  554. X#define YEXL 32
  555. Xstatic char yytext[YEXL];
  556. X
  557. Xstatic char *erryytextex(type)
  558. X    int type;
  559. X{
  560. X    char * strptr, *endptr;
  561. X    int charcnt;
  562. X
  563. X    strptr = (lasttokfetch -> textstrt) - 1;
  564. X    if(type == STRING)
  565. X    {
  566. X        endptr = (lasttokfetch -> textend) - 1;
  567. X        if(*endptr == '\n')
  568. X            endptr --;
  569. X    }
  570. X    else
  571. X    {
  572. X        endptr = (lasttokfetch -> textend) - 2;
  573. X    }
  574. X
  575. X    for(charcnt = 0; (strptr <= endptr) && charcnt < (YEXL - 1); charcnt ++)
  576. X    {
  577. X        yytext[charcnt] = *strptr++;
  578. X    }
  579. X    yytext[charcnt] = '\0';
  580. X}
  581. X
  582. Xint yylex()
  583. X{
  584. X    int scanstate;
  585. X    char *thistokstart;
  586. X    register char nextchar;
  587. X    int charset;
  588. X    long consaccum, consbase;
  589. X
  590. X
  591. X
  592. X    if(currtok >= intokcnt)
  593. X    {
  594. X        switch(nextreadact)
  595. X        {
  596. X        case Nra_new:  /* access next file */
  597. X            fprintf(intermedf, "F:%s\n", infilestk[++currfstk].fnm);
  598. X            yyin = infilestk[currfstk].fpt;
  599. X            nextreadact = Nra_normal;
  600. X        case Nra_normal:
  601. X            if(frareadrec())
  602. X            {
  603. X                /* EOF */;
  604. X                return 0;
  605. X            }
  606. X            break;
  607. X
  608. X        case Nra_end:  /* pop file and access previous */
  609. X            if(currfstk > 0)
  610. X            {
  611. X                fclose(yyin);
  612. X                yyin = infilestk[--currfstk].fpt;
  613. X                fprintf(intermedf, "X:%s\n",
  614. X                    infilestk[currfstk].fnm);
  615. X                if(frareadrec())
  616. X                {
  617. X                    /* EOF */;
  618. X                    return 0;
  619. X                }
  620. X                else
  621. X                {
  622. X                    nextreadact = Nra_normal;
  623. X                }
  624. X            }
  625. X            else
  626. X            {
  627. X                /* EOF */;
  628. X                return 0;
  629. X            }
  630. X            break;
  631. X        }
  632. X
  633. X        if(listflag)
  634. X        {
  635. X            fputs(finbuff, intermedf);
  636. X        }
  637. X        else
  638. X        {
  639. X            fputs("L:\n", intermedf);
  640. X        }
  641. X
  642. X        /* Scan a line */
  643. X
  644. X        frainptr = &finbuff[2];
  645. X
  646. X        currtok = intokcnt = 0;
  647. X        nexttokload = & scanqueue[0];
  648. X
  649. X        tptrstr = &tempstrpool[0];
  650. X        scanstate = 0;
  651. X        whichsym = Symopcode;
  652. X
  653. X        while( (nextchar = *frainptr++) != '\0' )
  654. X        {
  655. X            charset = chartrantab[nextchar & 0x7f];
  656. X            do {
  657. X                thisact =  & characttab [scanstate][charset];
  658. X
  659. X#if DEBUG
  660. X    if(isprint(nextchar))
  661. X        printf("%c    ", nextchar);
  662. X    else
  663. X        printf("0x%2.2x ", nextchar);
  664. X    printf("%-18s %-33s %-11s  %2.2d\n",
  665. X        statelab[scanstate],
  666. X        actlab[thisact -> action],
  667. X        thisact -> contin ? "Continue" : "Swallow",
  668. X        thisact -> nextstate);
  669. X#endif
  670. X
  671. X                switch(thisact -> action)
  672. X                {
  673. X                case 0: /* skip/no op */
  674. X                    break;
  675. X
  676. X                case 1: /* load EOL token */
  677. X                    nexttokload -> lvalv.longv = 0;
  678. X                    nexttokload -> tokv = EOL;
  679. X                    nexttokload -> errtype = Yetunprint;
  680. X                    nexttokload++;
  681. X                    intokcnt++; 
  682. X                    break;
  683. X
  684. X                case 2: /* start string */
  685. X                    thistokstart = tptrstr;
  686. X                    nexttokload -> textstrt = frainptr;
  687. X                    break;
  688. X
  689. X                case 3: /* process label */
  690. X                    {
  691. X            struct symel *tempsym;
  692. X
  693. X            *tptrstr++ = '\0';
  694. X            tempsym = symbentry(thistokstart, SYMBOL);
  695. X            if((tempsym -> seg) != SSG_RESV)
  696. X            {
  697. X                nexttokload -> tokv = LABEL;
  698. X                nexttokload -> errtype = Yetsymbol;
  699. X                nexttokload -> lvalv.symb = tempsym;
  700. X            }
  701. X            else
  702. X            {
  703. X                nexttokload -> tokv = tempsym -> tok;
  704. X                nexttokload -> errtype = Yetreserved;
  705. X                nexttokload -> lvalv.intv = tempsym -> value;
  706. X            }
  707. X            nexttokload -> textend = frainptr;
  708. X            nexttokload++;
  709. X            intokcnt++; 
  710. X                    }
  711. X                    break;
  712. X
  713. X                case 4: /* save string char */
  714. X                    *tptrstr++ = nextchar;
  715. X                    break;
  716. X
  717. X                case 5: /* load single char token */
  718. X                    nexttokload -> lvalv.longv = 0;
  719. X                    nexttokload -> tokv = nextchar;
  720. X                    nexttokload -> errtype = Yetprint;
  721. X                    nexttokload++;
  722. X                    intokcnt++; 
  723. X                    break;
  724. X
  725. X                case 6: /* load EQ token */
  726. X                    nexttokload -> lvalv.longv = 0;
  727. X                    nexttokload -> tokv = KEOP_EQ;
  728. X                    nexttokload -> errtype = Yetunprint;
  729. X                    nexttokload++;
  730. X                    intokcnt++;
  731. X                    break;
  732. X
  733. X                case 7: /* process symbol */
  734. X                    {
  735. X            register struct symel *symp;
  736. X            register char *ytp;
  737. X            int tempov;
  738. X
  739. X            *tptrstr++ = '\0';
  740. X            if(whichsym == Symopcode)
  741. X            {
  742. X                for(ytp = thistokstart; *ytp != '\0'; 
  743. X                    ytp++)
  744. X                {
  745. X                    if(islower(*ytp))
  746. X                    {
  747. X                        *ytp = toupper(*ytp);
  748. X                    }
  749. X                }
  750. X                nexttokload -> lvalv.intv 
  751. X                    = tempov = findop(thistokstart);
  752. X                nexttokload -> tokv = 
  753. X                    optab[tempov].token;
  754. X                nexttokload -> errtype = Yetopcode;
  755. X                whichsym = Symsym;
  756. X            }
  757. X            else
  758. X            {
  759. X                symp = symbentry(thistokstart,SYMBOL);
  760. X                if(symp -> seg != SSG_RESV)
  761. X                {
  762. X                    nexttokload -> lvalv.symb = symp;
  763. X                    nexttokload -> errtype = Yetsymbol;
  764. X                }
  765. X                else
  766. X                {
  767. X                    nexttokload -> lvalv.intv 
  768. X                        = symp->value;
  769. X                    nexttokload -> errtype = Yetreserved;
  770. X                }
  771. X
  772. X                nexttokload -> tokv = symp -> tok;
  773. X            }
  774. X
  775. X            nexttokload -> textend = frainptr;
  776. X            nexttokload++;
  777. X            intokcnt++;
  778. X                    }
  779. X                    break;
  780. X
  781. X                case 8: /* load $ token */
  782. X                    nexttokload -> lvalv.longv = 0;
  783. X                    nexttokload -> tokv = '$';
  784. X                    nexttokload -> errtype = Yetprint;
  785. X                    nexttokload++;
  786. X                    intokcnt++;
  787. X                    break;
  788. X
  789. X                case 9: /* setup for $hex */
  790. X                    consbase = 16;
  791. X                    consaccum = 0;
  792. X                    break;
  793. X
  794. X                case 10: /* accumulate 0-9 constant */
  795. X                    consaccum = (consaccum * consbase)
  796. X                        + (nextchar - '0');
  797. X                    break;
  798. X
  799. X                case 11: /* accumulate A-F constant  */
  800. X                    consaccum = (consaccum * consbase)
  801. X                        + (nextchar - 'A' + 10);
  802. X                    break;
  803. X
  804. X                case 12: /* accumulate a-f constant */
  805. X                    consaccum = (consaccum * consbase)
  806. X                        + (nextchar - 'a' + 10);
  807. X                    break;
  808. X
  809. X                case 13: /* load Constant token */
  810. X                    nexttokload -> lvalv.longv = 
  811. X                        consaccum;
  812. X                    nexttokload -> tokv = CONSTANT;
  813. X                    nexttokload -> errtype = Yetconstant;
  814. X                    nexttokload -> textend = frainptr;
  815. X                    nexttokload++;
  816. X                    intokcnt++;
  817. X                    break;
  818. X
  819. X                case 14: /* load @ token */
  820. X                    nexttokload -> lvalv.longv = 0;
  821. X                    nexttokload -> tokv = '@';
  822. X                    nexttokload -> errtype = Yetprint;
  823. X                    nexttokload++;
  824. X                    intokcnt++;
  825. X                    break;
  826. X
  827. X                case 15: /* setup for @octal */
  828. X                    consbase = 8;
  829. X                    consaccum = 0;
  830. X                    break;
  831. X
  832. X                case 16: /* setup for %binary */
  833. X                    consbase = 2;
  834. X                    consaccum = 0;
  835. X                    break;
  836. X
  837. X                case 17: /* load % token */
  838. X                    nexttokload -> lvalv.longv = 0;
  839. X                    nexttokload -> tokv = '%';
  840. X                    nexttokload -> errtype = Yetprint;
  841. X                    nexttokload++;
  842. X                    intokcnt++;
  843. X                    break;
  844. X
  845. X                case 18: /* load String token */
  846. X                    *tptrstr++  = '\0';
  847. X                    nexttokload -> lvalv.strng = 
  848. X                        thistokstart;
  849. X                    nexttokload -> tokv = STRING;
  850. X                    nexttokload -> errtype = Yetstring;
  851. X                    nexttokload -> textend = frainptr;
  852. X                    nexttokload++;
  853. X                    intokcnt++;
  854. X                    break;
  855. X
  856. X                case 19: /* load GE token */
  857. X                    nexttokload -> lvalv.longv = 0;
  858. X                    nexttokload -> tokv = KEOP_GE;
  859. X                    nexttokload -> errtype = Yetunprint;
  860. X                    nexttokload++;
  861. X                    intokcnt++;
  862. X                    break;
  863. X
  864. X                case 20: /* load GT token */
  865. X                    nexttokload -> lvalv.longv = 0;
  866. X                    nexttokload -> tokv = KEOP_GT;
  867. X                    nexttokload -> errtype = Yetunprint;
  868. X                    nexttokload++;
  869. X                    intokcnt++;
  870. X                    break;
  871. X
  872. X                case 21: /* load LE token */
  873. X                    nexttokload -> lvalv.longv = 0;
  874. X                    nexttokload -> tokv = KEOP_LE;
  875. X                    nexttokload -> errtype = Yetunprint;
  876. X                    nexttokload++;
  877. X                    intokcnt++;
  878. X                    break;
  879. X
  880. X                case 22: /* load NE token */
  881. X                    nexttokload -> lvalv.longv = 0;
  882. X                    nexttokload -> tokv = KEOP_NE;
  883. X                    nexttokload -> errtype = Yetunprint;
  884. X                    nexttokload++;
  885. X                    intokcnt++;
  886. X                    break;
  887. X
  888. X                case 23: /* load LT token */
  889. X                    nexttokload -> lvalv.longv = 0;
  890. X                    nexttokload -> tokv = KEOP_LT;
  891. X                    nexttokload -> errtype = Yetunprint;
  892. X                    nexttokload++;
  893. X                    intokcnt++;
  894. X                    break;
  895. X
  896. X                case 24: /* save numeric char 0-9 */
  897. X                    *tptrstr++ = nextchar - '0';
  898. X                    break;
  899. X
  900. X                case 25: /* save numeric char A-F */
  901. X                    *tptrstr++ = nextchar - 'A' + 10;
  902. X                    break;
  903. X
  904. X                case 26: /* save numeric char a-f */
  905. X                    *tptrstr++ = nextchar - 'a' + 10;
  906. X                    break;
  907. X
  908. X                case 27: /* convert numeric string base 2 */
  909. X                    {
  910. X            consaccum = 0;
  911. X            while(thistokstart < tptrstr)
  912. X            {
  913. X                consaccum = (consaccum * 2) + *thistokstart++;
  914. X            }
  915. X            nexttokload -> lvalv.longv = consaccum;
  916. X            nexttokload -> tokv = CONSTANT;
  917. X            nexttokload -> errtype = Yetconstant;
  918. X            nexttokload -> textend = frainptr;
  919. X            nexttokload++;
  920. X            intokcnt++;
  921. X                    }
  922. X                    break;
  923. X
  924. X                case 28: /* convert numeric string base 8 */
  925. X                    {
  926. X            consaccum = 0;
  927. X            while(thistokstart < tptrstr)
  928. X            {
  929. X                consaccum = (consaccum * 8) + *thistokstart++;
  930. X            }
  931. X            nexttokload -> lvalv.longv = consaccum;
  932. X            nexttokload -> tokv = CONSTANT;
  933. X            nexttokload -> errtype = Yetconstant;
  934. X            nexttokload -> textend = frainptr;
  935. X            nexttokload++;
  936. X            intokcnt++;
  937. X                    }
  938. X                    break;
  939. X
  940. X                case 29: /* convert numeric string base 10 */
  941. X                    {
  942. X            consaccum = 0;
  943. X            while(thistokstart < tptrstr)
  944. X            {
  945. X                consaccum = (consaccum * 10) + *thistokstart++;
  946. X            }
  947. X            nexttokload -> lvalv.longv = consaccum;
  948. X            nexttokload -> tokv = CONSTANT;
  949. X            nexttokload -> errtype = Yetconstant;
  950. X            nexttokload -> textend = frainptr;
  951. X            nexttokload++;
  952. X            intokcnt++;
  953. X                    }
  954. X                    break;
  955. X
  956. X                case 30: /* convert numeric string base 16 */
  957. X                    {
  958. X            consaccum = 0;
  959. X            while(thistokstart < tptrstr)
  960. X            {
  961. X                consaccum = (consaccum * 16) + *thistokstart++;
  962. X            }
  963. X            nexttokload -> lvalv.longv = consaccum;
  964. X            nexttokload -> tokv = CONSTANT;
  965. X            nexttokload -> errtype = Yetconstant;
  966. X            nexttokload -> textend = frainptr;
  967. X            nexttokload++;
  968. X            intokcnt++;
  969. X                    }
  970. X                    break;
  971. X
  972. X                case 31: /* save numeric 0xb */
  973. X                    *tptrstr++ = 0xb;
  974. X                    break;
  975. X
  976. X                case 32: /* save numeric 0xd */
  977. X                    *tptrstr++ = 0xd;
  978. X                    break;
  979. X
  980. X                case 33: /* set text start */
  981. X                    nexttokload -> textstrt = frainptr;
  982. X                    break;
  983. X                
  984. X                case 34: /* token choke */
  985. X                    nexttokload -> lvalv.longv = 0L;
  986. X                    nexttokload -> tokv = KTK_invalid;
  987. X                    nexttokload -> errtype = Yetinvalid;
  988. X                    nexttokload -> textend = frainptr;
  989. X                    nexttokload++;
  990. X                    intokcnt++;
  991. X                    break;
  992. X                }
  993. X
  994. X                scanstate = thisact -> nextstate;
  995. X
  996. X            }  while( thisact -> contin);
  997. X        }
  998. X
  999. X        if(intokcnt <= 0)
  1000. X        { /* no tokens in line (comment or whitespace overlength) */
  1001. X            scanqueue[0].tokv = EOL;
  1002. X            scanqueue[0].errtype = Yetunprint;
  1003. X            scanqueue[0].lvalv.longv = 0;
  1004. X            intokcnt = 1;
  1005. X        }
  1006. X
  1007. X        if(scanstate != 0)
  1008. X        { /* no EOL */
  1009. X            fraerror("Overlength/Unterminated Line");
  1010. X        }
  1011. X    }
  1012. X    lasttokfetch = &scanqueue[currtok++];
  1013. X    yylval = lasttokfetch -> lvalv;
  1014. X    return lasttokfetch -> tokv;
  1015. X}
  1016. X
  1017. X
  1018. Xyyerror(str)
  1019. X    char *str;
  1020. X/*    
  1021. X    description    first pass - output a parser error to intermediate file
  1022. X*/
  1023. X{
  1024. X    char * taglab;
  1025. X
  1026. X    switch(lasttokfetch -> errtype)
  1027. X    {
  1028. X    case Yetprint:
  1029. X        if( ! isprint(lasttokfetch -> tokv))
  1030. X        {
  1031. X            fprintf(intermedf, 
  1032. X                "E: ERROR - %s at/before character \"^%c\"\n",
  1033. X                str, PRINTCTRL(lasttokfetch -> tokv));
  1034. X        }
  1035. X        else
  1036. X        {
  1037. X            fprintf(intermedf, 
  1038. X                "E: ERROR - %s at/before character \"%c\"\n",
  1039. X                str, lasttokfetch -> tokv );
  1040. X        }
  1041. X        break;
  1042. X
  1043. X    case Yetsymbol: 
  1044. X    case Yetreserved: 
  1045. X    case Yetopcode: 
  1046. X    case Yetconstant: 
  1047. X        erryytextex(SYMBOL);
  1048. X        fprintf(intermedf, "E: ERROR - %s at/before token \"%s\" \n",
  1049. X            str, yytext);
  1050. X        break;
  1051. X
  1052. X    case Yetinvalid: 
  1053. X        erryytextex(SYMBOL);
  1054. X        fprintf(intermedf, "E: ERROR - %s at invalid token \"%s\" \n",
  1055. X            str, yytext);
  1056. X        break;
  1057. X
  1058. X    case Yetstring:
  1059. X        erryytextex(STRING);
  1060. X        fprintf(intermedf, "E: ERROR - %s at/before string %s \n",
  1061. X            str, yytext);
  1062. X        break;
  1063. X
  1064. X    case Yetunprint:
  1065. X        switch(lasttokfetch -> tokv)
  1066. X        {
  1067. X        case EOL:
  1068. X            taglab = "End of Line";
  1069. X            break;
  1070. X        case KEOP_EQ:
  1071. X            taglab = "\"=\"";
  1072. X            break;
  1073. X        case KEOP_GE:
  1074. X            taglab = "\">=\"";
  1075. X            break;
  1076. X        case KEOP_GT:
  1077. X            taglab = "\">\"";
  1078. X            break;
  1079. X        case KEOP_LE:
  1080. X            taglab = "\"<=\"";
  1081. X            break;
  1082. X        case KEOP_NE:
  1083. X            taglab = "\"<>\"";
  1084. X            break;
  1085. X        case KEOP_LT:
  1086. X            taglab = "\"<\"";
  1087. X            break;
  1088. X        default:
  1089. X            taglab = "Undeterminable Symbol";
  1090. X            break;
  1091. X        }
  1092. X        fprintf(intermedf, "E: ERROR - %s at/before %s\n",
  1093. X            str, taglab);
  1094. X        break;
  1095. X
  1096. X    default:
  1097. X        fprintf(intermedf, "E: ERROR - %s - undetermined yyerror type\n",
  1098. X            str);
  1099. X        break;
  1100. X    }
  1101. X
  1102. X    errorcnt++;
  1103. X}
  1104. SHAR_EOF
  1105. true || echo 'restore of fryylex.c failed'
  1106. fi
  1107. # ============= getopt.h ==============
  1108. if test -f 'getopt.h' -a X"$1" != X"-c"; then
  1109.     echo 'x - skipping getopt.h (File already exists)'
  1110. else
  1111. echo 'x - extracting getopt.h (Text)'
  1112. sed 's/^X//' << 'SHAR_EOF' > 'getopt.h' &&
  1113. X
  1114. X
  1115. X/*
  1116. XHEADER:     ;
  1117. XTITLE:         Frankenstein Cross Assemblers;
  1118. XVERSION:     2.0;
  1119. XDESCRIPTION: "    Reconfigurable Cross-assembler producing Intel (TM)
  1120. X        Hex format object records.  ";
  1121. XSYSTEM:     UNIX, MS-Dos ;
  1122. XFILENAME:     getopt.h;
  1123. XWARNINGS:     "This is some ancient code I found on a version 7 system
  1124. X        when I was running the original port.  Asking for help from
  1125. X        the original authors is not advised.  (Especially after
  1126. X        the hack job I did on it.  Mark Zenier.)  "  ;
  1127. XSEE-ALSO:     frasmain.c;
  1128. XAUTHORS:     Keith Bostic, Rich $alz;
  1129. X*/
  1130. X/*
  1131. X**  This is a public domain version of getopt(3).
  1132. X**  Bugs, fixes to:
  1133. X**        Keith Bostic
  1134. X**            ARPA: keith@seismo
  1135. X**            UUCP: seismo!keith
  1136. X**  Added NO_STDIO, opterr handling, Rich $alz (mirror!rs).
  1137. X
  1138. X  Framework Cross Assembler 
  1139. X    use strchr
  1140. X    remove NO_STDIO code
  1141. X    Mark Zenier     Specialized Systems Consultants, Inc.   
  1142. X*/
  1143. X
  1144. X/*
  1145. X**  Error macro.  Maybe we want stdio, maybe we don't.
  1146. X**  The (undocumented?) variable opterr tells us whether or not
  1147. X**  to print errors.
  1148. X*/
  1149. X
  1150. X#define tell(s)                                \
  1151. X    if (opterr)                            \
  1152. X        (void)fputs(*nargv, stderr),                \
  1153. X        (void)fputs(s,stderr),                    \
  1154. X        (void)fputc(optopt, stderr),                \
  1155. X        (void)fputc('\n', stderr)
  1156. X
  1157. X
  1158. X
  1159. X/* Global variables. */
  1160. Xstatic char     EMSG[] = "";
  1161. Xint         opterr = 1;        /* undocumented error-suppressor*/
  1162. Xint         optind = 1;        /* index into argv vector    */
  1163. Xint         optopt;        /* char checked for validity    */
  1164. Xchar        *optarg;        /* arg associated with option    */
  1165. X
  1166. X
  1167. Xgetopt(nargc, nargv, ostr)
  1168. X    int              nargc;
  1169. X    char        **nargv;
  1170. X    char         *ostr;
  1171. X{
  1172. X    static char         *place = EMSG;    /* option letter processing    */
  1173. X    register char     *oli;        /* option letter list index    */
  1174. X
  1175. X    if (!*place)            /* update scanning pointer    */
  1176. X    {
  1177. X    if (optind >= nargc || *(place = nargv[optind]) != '-' || !*++place)
  1178. X        return(EOF);
  1179. X    if (*place == '-')        /* found "--"            */
  1180. X    {
  1181. X        optind++;
  1182. X        return(EOF);
  1183. X    }
  1184. X    }
  1185. X    /* option letter okay? */
  1186. X    if ((optopt = *place++) == ':' || (oli = strchr(ostr, optopt)) == NULL)
  1187. X    {
  1188. X    if (!*place)
  1189. X        optind++;
  1190. X    tell(": illegal option -- ");
  1191. X    goto Bad;
  1192. X    }
  1193. X    if (*++oli != ':')            /* don't need argument        */
  1194. X    {
  1195. X    optarg = NULL;
  1196. X    if (!*place)
  1197. X        optind++;
  1198. X    }
  1199. X    else                /* need an argument        */
  1200. X    {
  1201. X    if (*place)
  1202. X        optarg = place;        /* no white space        */
  1203. X    else
  1204. X        if (nargc <= ++optind)
  1205. X        {
  1206. X        place = EMSG;
  1207. X        tell(": option requires an argument -- ");
  1208. X        goto Bad;
  1209. X        }
  1210. X        else
  1211. X        optarg = nargv[optind];    /* white space            */
  1212. X    place = EMSG;
  1213. X    optind++;
  1214. X    }
  1215. X    return(optopt);            /* dump back option letter    */
  1216. XBad:
  1217. X    return('?');
  1218. X}
  1219. X
  1220. SHAR_EOF
  1221. true || echo 'restore of getopt.h failed'
  1222. fi
  1223. # ============= makefile.dos ==============
  1224. if test -f 'makefile.dos' -a X"$1" != X"-c"; then
  1225.     echo 'x - skipping makefile.dos (File already exists)'
  1226. else
  1227. echo 'x - extracting makefile.dos (Text)'
  1228. sed 's/^X//' << 'SHAR_EOF' > 'makefile.dos' &&
  1229. X#
  1230. X# HEADER:    ;
  1231. X# TITLE:    Frankenstein Cross Assemblers;
  1232. X# VERSION:     2.0;
  1233. X# SYSTEM:    MS-DOS;
  1234. X# FILENAME:    makefile (dos);
  1235. X# DESCRIPTION: "Reconfigurable Cross-assembler producing Intel (TM)
  1236. X#        Hex format object records.  ";
  1237. X# KEYWORDS:     cross-assemblers, 1805, 2650, 6301, 6502, 6805, 6809, 
  1238. X#        6811, tms7000, 8048, 8051, 8096, z8, z80;
  1239. X# WARNINGS:    "the bison simple parser, simple.prs in the version
  1240. X#        used, must be accessable.
  1241. X#
  1242. X#        The version of bison used produces output files named
  1243. X#        {name}.c and {name}.h as opposed to the original
  1244. X#        {name}.tab.[ch].
  1245. X#    
  1246. X#        This software is in the public domain.  
  1247. X#        Any prior copyright claims are relinquished.  
  1248. X#    
  1249. X#        This software is distributed with no warranty whatever.  
  1250. X#        The author takes no responsibility for the consequences 
  1251. X#        of its use.
  1252. X#    
  1253. X#        Yacc (or Bison) required to compile."  ;
  1254. X# AUTHORS:    Mark Zenier;
  1255. X# COMPILERS:    Turbo C v 1.5, Bison (Cug disk 285, January 1989);
  1256. X#
  1257. X#    usage
  1258. X#        make -DTARGET=as1805
  1259. X#
  1260. X#
  1261. X#    Conditional Compilation Flags
  1262. X#
  1263. X#    DOSTMP        use the current directory for temporary intermediate
  1264. X#            file
  1265. X#    NOGETOPT    use the getopt.h file
  1266. X#    USEINDEX    redefine the strchr() library function to use
  1267. X#            the older equivalent name index()
  1268. X#    NOSTRING    use internal definitions if the <string.h> include
  1269. X#            file does not exist
  1270. X#
  1271. X
  1272. XCFLAGS = 
  1273. XYACCLEXLIB =
  1274. XLEXNEEDS =
  1275. XMAINNEEDS = -DDOSTMP -DNOGETOPT
  1276. XMAINDEPENDS = getopt.h
  1277. X
  1278. X
  1279. X$(TARGET) : frasmain.obj frapsub.obj fryylex.obj $(TARGET).obj fraosub.obj 
  1280. X    tcc $(CFLAGS) -e$(TARGET) frasmain.obj frapsub.obj\
  1281. X        fraosub.obj fryylex.obj $(TARGET).obj $(YACCLEXLIB)
  1282. X    del fraytok.h
  1283. X
  1284. Xfrasmain.obj : frasmain.c  frasmdat.h $(MAINDEPENDS)
  1285. X    tcc $(CFLAGS) $(MAINNEEDS) -c frasmain.c
  1286. X
  1287. Xfryylex.obj : fryylex.c fraytok.h  frasmdat.h
  1288. X    tcc $(CFLAGS) $(LEXNEEDS) -c fryylex.c
  1289. X
  1290. X$(TARGET).c $(TARGET).h : $(TARGET).y
  1291. X    bison -d $(TARGET).y
  1292. X
  1293. Xfraytok.h : $(TARGET).h
  1294. X    copy $(TARGET).h fraytok.h
  1295. X
  1296. X$(TARGET).obj : $(TARGET).c  frasmdat.h fragcon.h
  1297. X    tcc $(CFLAGS) -c $(TARGET).c
  1298. X
  1299. Xfrapsub.obj : frapsub.c fragcon.h frasmdat.h fraeuni.h fraebin.h
  1300. X    tcc $(CFLAGS) -c frapsub.c
  1301. X
  1302. Xfraosub.obj : fraosub.c  frasmdat.h fragcon.h fraeuni.h fraebin.h
  1303. X    tcc $(CFLAGS) -c fraosub.c
  1304. X
  1305. SHAR_EOF
  1306. true || echo 'restore of makefile.dos failed'
  1307. fi
  1308. # ============= makeone.bat ==============
  1309. if test -f 'makeone.bat' -a X"$1" != X"-c"; then
  1310.     echo 'x - skipping makeone.bat (File already exists)'
  1311. else
  1312. echo 'x - extracting makeone.bat (Text)'
  1313. sed 's/^X//' << 'SHAR_EOF' > 'makeone.bat' &&
  1314. Xmake -DTARGET=%1
  1315. X%1 -l test.out %1.tst
  1316. Xfc test.out %1.tut
  1317. SHAR_EOF
  1318. true || echo 'restore of makeone.bat failed'
  1319. fi
  1320. exit 0
  1321.