home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume28 / notation / part02 < prev    next >
Encoding:
Text File  |  1992-02-13  |  58.0 KB  |  2,201 lines

  1. Newsgroups: comp.sources.misc
  2. From: hthomas@ph.tn.tudelft.nl (Henry Thomas)
  3. Subject:  v28i037:  notation - chess preprocessor v3.9, Part02/04
  4. Message-ID: <1992Feb11.204726.9098@sparky.imd.sterling.com>
  5. X-Md4-Signature: e9767adb49564b826c4f481a004a0551
  6. Date: Tue, 11 Feb 1992 20:47:26 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: hthomas@ph.tn.tudelft.nl (Henry Thomas)
  10. Posting-number: Volume 28, Issue 37
  11. Archive-name: notation/part02
  12. Environment: UNIX
  13. Supersedes: notation: Volume20, Issue 52-55
  14.  
  15. #! /bin/sh
  16. # into a shell via "sh file" or similar.  To overwrite existing files,
  17. # type "sh file -c".
  18. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  19. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  20. # Contents:  drivers.c lexer.c notation.hlp
  21. # Wrapped by kent@sparky on Tue Feb 11 14:22:45 1992
  22. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  23. echo If this archive is complete, you will see the following message:
  24. echo '          "shar: End of archive 2 (of 4)."'
  25. if test -f 'drivers.c' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'drivers.c'\"
  27. else
  28.   echo shar: Extracting \"'drivers.c'\" \(20741 characters\)
  29.   sed "s/^X//" >'drivers.c' <<'END_OF_FILE'
  30. X/*
  31. X  Notation program
  32. X  @(#)drivers.c    3.9 (C) Henry Thomas    Release 3     Dated 12/10/91
  33. X */
  34. X
  35. X#ifdef __STDC__
  36. X#include <stdlib.h>
  37. X#endif
  38. X#include<stdio.h>
  39. X
  40. X#include <ctype.h>
  41. X#include "chesstype.h"
  42. X#include "notation.h"
  43. X#include "drivers.h"
  44. X
  45. X/* postscript characters translation table
  46. X   one entry per piece
  47. X   each entry has four fields:
  48. X   - white piece on white case
  49. X   - white piece on black case
  50. X   - black piece on ...
  51. X   ..
  52. X */
  53. X#define PSINDEX(a,b) ((((a)==WHITE)?0:2)+(((b)%2)?0:1))
  54. X
  55. Xstatic char * postscript_table[][4] = {
  56. X  { " ", "x",     " ", "x"     }, /* void */
  57. X  { "k", "\\373", "K", "\\360" }, /* king */
  58. X  { "q", "\\317", "Q", "\\316" }, /* queen */
  59. X  { "r", "\\250", "R", "\\345" }, /* rook */
  60. X  { "b", "\\272", "B", "\\365" }, /* bishop */
  61. X  { "n", "\\265", "N", "\\366" }, /* knight */
  62. X  { "p", "\\271", "P", "\\270" }  /* pawn */
  63. X};
  64. X
  65. X/* TeX table for using the chess figure in board design */
  66. Xstatic char * texboard_table[][4] = {
  67. X  /*   W/W      W/B      B/W      B/B */
  68. X  { " ", "*", " ", "*" }, /* void */
  69. X  { "K", "K", "k", "k" }, /* king */
  70. X  { "Q", "Q", "q", "q" }, /* queen */
  71. X  { "R", "R", "r", "r" }, /* rook */
  72. X  { "B", "B", "b", "b" }, /* bishop */
  73. X  { "N", "N", "n", "n" }, /* knight */
  74. X  { "P", "P", "p", "p" }  /* pawn */
  75. X};
  76. X
  77. X/* TeX table for using the chess figures in move description */
  78. X/* P.T. macros render this table useless as english symbols 
  79. X   are active char in analysis mode
  80. X   */
  81. Xstatic char * latex_table[] = {
  82. X  "", /* null */
  83. X/*  "{\\Fig K}", "{\\Fig Q}", "{\\Fig R}", "{\\Fig B}", "{\\Fig N}",  "" */
  84. X  "K", "Q", "R", "B", "N",  "" 
  85. X    /* last entry = pawn; not represented, otherwise "{\\Fig P}" */
  86. X};
  87. X
  88. X/* various tex symbols */
  89. Xstatic char FigDash[] = "\\FigDash";
  90. Xstatic char FigCapt[] = "*"; /* "*" is an active char with P.T. macros */
  91. Xstatic char FigDots[] = ":"; /* ":" is an active char for "..." */
  92. Xstatic char FigDot[] = "\\FigDot";
  93. X
  94. X#define G_ROQUE  "O-O-O" 
  95. X#define P_ROQUE  "O-O" 
  96. X
  97. X/* variation symbols */
  98. Xstatic char varsymb[][2] = { { '[', ']' }, { '(', ')' } };
  99. X
  100. Xstatic char * com_tex[] = {
  101. X#define CHESSSYMB(LET,LASC,SASC,TEX,PS,ENG,FRA) TEX,
  102. X#include "chesssymb.def"
  103. X ""
  104. X };
  105. X#undef CHESSSYMB
  106. X
  107. Xstatic char * com_ps[] = {
  108. X#define CHESSSYMB(LET,LASC,SASC,TEX,PS,ENG,FRA) PS,
  109. X#include "chesssymb.def"
  110. X ""
  111. X };
  112. X#undef CHESSSYMB
  113. X
  114. Xstatic FILE * ftmp ;
  115. X
  116. X
  117. X/* ---------------- output functions ---------------- */
  118. X
  119. X/* convert a roque in term of king's move */
  120. X#ifdef __STDC__
  121. Xstatic int roque_to_move(depl *m)
  122. X#else
  123. Xstatic int roque_to_move(m)
  124. X     depl * m;
  125. X#endif
  126. X{
  127. X
  128. X  m->piece = KING;
  129. X  m->fromcol   = 5;
  130. X  if (m->type == GRANDROQUE)  
  131. X    m->tocol = 3;
  132. X  else
  133. X    m->tocol = 7;
  134. X
  135. X  if (m->whiteturn)
  136. X    m->fromlig = m->tolig = 1;
  137. X  else
  138. X    m->fromlig = m->tolig = 8;
  139. X
  140. X  return(TRUE);
  141. X}
  142. X
  143. X/* (kind of) buffering of output */
  144. X#ifdef __STDC__
  145. Xstatic void init_buffer(format *d, int side)
  146. X#else
  147. Xstatic void init_buffer(d,side)
  148. X     format * d;
  149. X     int side ;
  150. X#endif
  151. X{
  152. X  switch (d->type) {
  153. X  case D_ASCII:
  154. X    if (side != BLACK) (void) sprintf(d->white_buffer,"...");
  155. X    if (side != WHITE) (void) sprintf(d->black_buffer,"   ");
  156. X    break;
  157. X  case D_TEX:
  158. X    if (side != BLACK) (void) sprintf(d->white_buffer,"%s",FigDots);
  159. X    if (side != WHITE) (void) sprintf(d->black_buffer,"~");
  160. X    break;
  161. X  default:
  162. X    if (side != BLACK) d->white_buffer[0] = '\0' ;
  163. X    if (side != WHITE) d->black_buffer[0] = '\0' ;
  164. X    break;
  165. X  }
  166. X}
  167. X
  168. X/* this procedure is responsible for PRINTING the move */
  169. X#ifdef __STDC__
  170. Xstatic void flush_buffer(format *d)
  171. X#else
  172. Xstatic void flush_buffer(d)
  173. X     format * d;
  174. X#endif
  175. X{
  176. X  
  177. X  /* if we have been interupted (by a comment, a board display etc...
  178. X     if the move is black
  179. X     we display <movenumber> ... <blackmove>
  180. X     */
  181. X  if ((d->interrupt == TRUE) && (d->iswhiteturn == FALSE)) {
  182. X    switch (d->type) {
  183. X    case D_TEX:
  184. X      (void) fprintf(d->outfile,
  185. X             "%s %s %s\n", 
  186. X             d->move_buffer,FigDots,d->black_buffer);
  187. X      break;
  188. X    case D_GNU:
  189. X    case D_XCHESS:
  190. X      /* no special case for GNU */
  191. X      (void) fprintf(d->outfile,"\t%s\n",d->black_buffer);
  192. X      break;    
  193. X    default:
  194. X      (void) fprintf(d->outfile,"\n%3s.%9s%9s", 
  195. X             d->move_buffer,"...",d->black_buffer);
  196. X      break;
  197. X    }
  198. X    d->interrupt = FALSE ;
  199. X  } else {
  200. X  /* else (no interrupt)
  201. X     we display either white or black move 
  202. X     */
  203. X    switch (d->type) {
  204. X    case D_TEX:
  205. X      if (d->iswhiteturn)
  206. X    (void) fprintf(d->outfile,"%s %s", d->move_buffer,d->white_buffer);
  207. X      else
  208. X    (void) fprintf(d->outfile," %s\n",d->black_buffer);
  209. X      break;
  210. X    case D_XCHESS:
  211. X      if (d->iswhiteturn)
  212. X    (void) fprintf(d->outfile,"%3s.", d->move_buffer);
  213. X    case D_GNU:
  214. X      if (d->iswhiteturn)
  215. X    (void) fprintf(d->outfile,"\t%s",d-> white_buffer);
  216. X      else
  217. X    (void) fprintf(d->outfile,"\t%s\n",d->black_buffer);
  218. X      break;    
  219. X    default:
  220. X      if (d->iswhiteturn)
  221. X    (void) fprintf(d->outfile,"\n%3s.%9s", d->move_buffer,d->white_buffer);
  222. X      else
  223. X    (void) fprintf(d->outfile,"%9s", d->black_buffer);
  224. X      break;
  225. X    }
  226. X  } /* end printing */
  227. X
  228. X  /* reset buffer */
  229. X  if (! d->iswhiteturn)
  230. X    init_buffer(d,VOID);
  231. X  d->interrupt = FALSE;
  232. X}
  233. X
  234. X/* a generic parametrised driver for move output
  235. X   */
  236. X#ifdef __STDC__
  237. Xstatic void output_move_generic(format *dr, depl *d)
  238. X#else
  239. Xstatic void output_move_generic(dr,d)
  240. X     format * dr;
  241. X     depl *d;
  242. X#endif
  243. X{
  244. X  char ligne[128] ;
  245. X  char themove[128] ;
  246. X  char thepiece[16]  ;
  247. X  char debcol[16];
  248. X  char frommove[16]  ;
  249. X  char tomove[16] ;
  250. X  char captsymb[16] ;
  251. X  char lie[16] ;
  252. X  char prom[16];
  253. X
  254. X  int ambigue = FALSE ;
  255. X  int ambigueline, ambiguecols;
  256. X
  257. X  ligne[0] = themove[0] = thepiece[0] = debcol[0]  = '\0';
  258. X  frommove[0] = tomove[0] = lie[0] = prom[0] = '\0' ;
  259. X
  260. X  if (dr->type == D_TEX) 
  261. X    (void) sprintf(captsymb,"%s", FigCapt);
  262. X  else
  263. X    (void) sprintf(captsymb,"%s", "x" );
  264. X
  265. X  if (dr->type == D_TEX) {
  266. X    (void) sprintf (dr->move_buffer,"\\mn{%d}",d->move);
  267. X  } else 
  268. X    (void) sprintf (dr->move_buffer,"%d",d->move);
  269. X
  270. X  if ((d->type == PETITROQUE) && !dr->roque_alg)
  271. X    (void) sprintf (themove,"%s",P_ROQUE);
  272. X  if ((d->type == GRANDROQUE) && !dr->roque_alg)
  273. X    (void) sprintf (themove,"%s",G_ROQUE);
  274. X  if (dr->roque_alg && 
  275. X      ((d->type == GRANDROQUE) || (d->type == PETITROQUE)))
  276. X    (void) roque_to_move(d);
  277. X
  278. X  if (dr-> roque_alg || 
  279. X      ((d->type != GRANDROQUE) && (d->type != PETITROQUE))) {
  280. X
  281. X    /* we check here for ambiguous move */
  282. X    if ((d->type != GRANDROQUE) && (d->type != PETITROQUE)) {
  283. X      ambigue = ambiguity (d, &ambigueline, &ambiguecols );
  284. X      /* if ( (ambigue ) && (d->piece != PAWN ))
  285. X       * (void) fprintf (stderr,"output ambiguity at move %d %d",
  286. X       * d->move,d->whiteturn); 
  287. X       */
  288. X    }
  289. X
  290. X    themove[0] = '\0' ;
  291. X    if ((dr->output_move_format == SHORTENED) 
  292. X    && (d->type == PRISE) && (d->piece == PAWN))
  293. X      (void) sprintf (debcol, "%c",coltoletter(d->fromcol));
  294. X
  295. X    if (dr->print_piece)
  296. X      if (d->piece != PAWN || dr->print_pawn) {
  297. X        if (dr->type == D_TEX )
  298. X          (void) sprintf(thepiece,"%s",latex_table[d->piece]);
  299. X        else
  300. X          (void) sprintf(thepiece,"%c",dr->out_table[d->piece]);
  301. X      }
  302. X
  303. X    if ((dr->output_move_format == ALGEBRAIC))
  304. X      (void)sprintf(frommove,"%c%c",
  305. X            coltoletter(d->fromcol),ligtoletter(d->fromlig));
  306. X    if ( ambigue && dr->print_liaison ) {
  307. X      /* is the ambiguity on lines ? -> print col */
  308. X      if (ambigueline && !ambiguecols)
  309. X    (void)sprintf(frommove,"%c", coltoletter(d->fromcol));
  310. X      /* is the ambiguity on lines ? -> print lig */
  311. X      if (ambiguecols && !ambigueline)
  312. X    (void)sprintf(frommove,"%c", ligtoletter(d->fromlig));     
  313. X      /* unable to find where is ambiguity ? print all */
  314. X      /* ( I doubt this case ever occurs ... ) */
  315. X      if ( ambigueline && ambiguecols) 
  316. X    (void)sprintf(frommove,"%c%c",
  317. X              coltoletter(d->fromcol),ligtoletter(d->fromlig));
  318. X      debcol[0] = '\0' ;
  319. X    }
  320. X
  321. X    if (d->promotion) {
  322. X      if (dr->print_liaison) {
  323. X        if (dr->type == D_TEX )
  324. X          (void) sprintf(prom,"=%s ",latex_table[d->promotion]);
  325. X          else
  326. X            (void) sprintf(prom,"=%c",dr->out_table[d->promotion]);
  327. X      } else /* xchess - gnu output */
  328. X    (void) sprintf(prom,"%c",dr->out_table[d->promotion]);
  329. X    }
  330. X          
  331. X    if (dr->print_liaison) {
  332. X      if ((d->type == PRISE) || (d->type == PROM_ET_PRISE) 
  333. X      || (d->type == EN_PASSANT) )
  334. X    (void) sprintf(lie,"%s",captsymb);
  335. X      else
  336. X    if ((dr->output_move_format == ALGEBRAIC))
  337. X      (void) sprintf(lie,"%c",'-');
  338. X    }
  339. X    
  340. X    (void) sprintf(tomove,"%c%c",coltoletter(d->tocol),ligtoletter(d->tolig));
  341. X
  342. X    (void) sprintf (themove,"%s%s%s%s%s%s",
  343. X            thepiece,debcol,frommove,lie, tomove,prom);
  344. X  }
  345. X
  346. X  if (d->whiteturn)
  347. X    (void) sprintf (dr->white_buffer, "%s",themove);
  348. X  else
  349. X    (void) sprintf (dr->black_buffer, "%s",themove);
  350. X
  351. X  dr->iswhiteturn = d->whiteturn; 
  352. X
  353. X  /*fprintf(dr->outfile, "=%d=%d= ",d->move,d->whiteturn);*/
  354. X  flush_buffer(dr); 
  355. X}
  356. X
  357. X/* variation handler */
  358. X#ifdef __STDC__
  359. Xstatic void output_variation_generic (format *dr, int inout)
  360. X#else
  361. Xstatic void output_variation_generic (dr,inout)
  362. X     format * dr;
  363. X     int inout;
  364. X#endif
  365. X{
  366. X  char symbol;
  367. X
  368. X  if (dr->variation > 1)
  369. X    symbol = varsymb[1][inout];
  370. X  else
  371. X    symbol = varsymb[0][inout];
  372. X    
  373. X  switch (dr->type) {
  374. X  case D_TEX:
  375. X    /* we must boldface the brackets for level 1 */
  376. X    if (dr->variation == 1 ) {
  377. X      /*(void) fprintf(dr->outfile, " {\\bf %c} ",symbol);*/
  378. X      if (inout == 0 )
  379. X        (void) fprintf(dr->outfile, "%%\n\\begin{Variation}%%\n ");
  380. X      else
  381. X        (void) fprintf(dr->outfile, "\\end{Variation} %%\n");
  382. X    } else
  383. X      (void) fprintf(dr->outfile, " %c ",symbol); 
  384. X    break;
  385. X  default:
  386. X    (void) fprintf(dr->outfile, "  %c",symbol);
  387. X    break;
  388. X  };
  389. X}
  390. X
  391. X#ifdef __STDC__
  392. Xstatic void output_text_generic(format *dr, int type, char *string, int code)
  393. X#else
  394. Xstatic void output_text_generic(dr, type, string, code)
  395. X     format *dr ;
  396. X     int type;
  397. X     char * string;
  398. X     int code;
  399. X#endif
  400. X{
  401. X  switch (type) {
  402. X  case T_COMMENT:
  403. X    if (com_short[code] != '\0' )
  404. X      (void) fprintf(dr->outfile," %s ",com_short[code]);
  405. X    else
  406. X      (void) fprintf(dr->outfile," %s ",com_long[code]);
  407. X      break;
  408. X  case T_TEXT:
  409. X    (void) fprintf(dr->outfile," %s ",string);
  410. X    break;
  411. X  case T_TITLE:
  412. X    (void) fprintf(dr->outfile,"\n  %s\n",string);
  413. X    break;
  414. X  case T_SUBTITLE:
  415. X    (void) fprintf(dr->outfile,"    %s\n",string);
  416. X    break;
  417. X  case T_SCORE:
  418. X    (void) fprintf(dr->outfile,"  %s\n",string);
  419. X  default:
  420. X    break;
  421. X  }
  422. X}
  423. X
  424. X
  425. X/* ---------------- ascii driver ----------  */
  426. X#ifdef __STDC__
  427. Xstatic void output_init_ascii(format *dr) 
  428. X#else
  429. Xstatic void output_init_ascii(dr) 
  430. Xformat *dr;
  431. X#endif
  432. X{}
  433. X    
  434. X#ifdef __STDC__
  435. Xstatic void output_board_ascii(format *dr,game *g)
  436. X#else
  437. Xstatic void output_board_ascii(dr,g)
  438. X     format * dr;
  439. X     game * g;
  440. X#endif
  441. X{
  442. X  register int i,j;
  443. X
  444. X  dr->interrupt = TRUE;
  445. X
  446. X  (void) fprintf(dr->outfile,"\n\n");
  447. X  for (i=8 ; i >=1 ; i--) {
  448. X    if (dr->coordinates)
  449. X      (void) fprintf(dr->outfile,"%d ",i);
  450. X    (void) fputc('|',dr->outfile);
  451. X    for (j=1 ; j<9 ; j++) {
  452. X      if (g->board[i][j] != VOID) {
  453. X    if (g->color[i][j] == WHITE) 
  454. X     (void) fputc(dr->out_table[g->board[i][j]], dr->outfile);
  455. X    else 
  456. X      (void) fputc(tolower(dr->out_table[g->board[i][j]]),dr->outfile);
  457. X      } else
  458. X    (void) fputc ( ((i+j)% 2)?' ':'/', dr->outfile);
  459. X      (void) fputc('|', dr->outfile);
  460. X    }
  461. X    (void) fputc('\n', dr->outfile);
  462. X  }
  463. X  if (dr->coordinates)
  464. X    (void) fprintf(dr->outfile,"   a b c d e f g h\n");
  465. X  (void) fprintf(dr->outfile,"\n");
  466. X}
  467. X
  468. X/* ---------------- postscript --------- */
  469. X
  470. X#ifdef __STDC__
  471. Xstatic void output_board_ps(format *dr,game *g)
  472. X#else
  473. Xstatic void output_board_ps(dr,g)
  474. X     format *dr;
  475. X     game * g;
  476. X#endif
  477. X{
  478. X  register int i,j;
  479. X  register int c;
  480. X  char chaine[MAXTOKLEN];
  481. X
  482. X  /* header file */
  483. X  (void) strcpy(chaine,LIB_DIR);
  484. X  if ((ftmp = fopen(strcat(chaine,PS_HEADER),"r")) == NULL)
  485. X    message((stderr,"Can't open ps header file.\n"));
  486. X  else {
  487. X    while ((c = getc(ftmp)) != EOF)
  488. X      (void) fputc(c,dr->outfile);
  489. X    (void) fclose(ftmp);
  490. X  }
  491. X
  492. X  (void) fprintf(dr->outfile,"( ________) 72 714 T\n");
  493. X  for (i=8 ; i >=1 ; i--) {
  494. X    (void) fprintf(dr->outfile,"(/");
  495. X    for (j=1 ; j<9 ; j++) {
  496. X    (void) fprintf(dr->outfile,"%s",
  497. X           postscript_table[g->board[i][j]][PSINDEX(g->color[i][j],(i+j))]);
  498. X    }
  499. X    (void) fprintf(dr->outfile,"\\\\) 72 %d T\n",474 + (i-1)*30);
  500. X  }
  501. X  (void) fprintf(dr->outfile,"( --------) 72 444 T\n");
  502. X
  503. X  /* footer file */
  504. X  (void) strcpy(chaine,LIB_DIR);
  505. X  if ((ftmp = fopen(strcat(chaine,PS_FOOTER),"r")) == NULL)
  506. X    message((stderr,"Can't open ps footer file.\n"));
  507. X  else {
  508. X    while ((c = getc(ftmp)) != EOF)
  509. X      (void) fputc(c,dr->outfile);
  510. X    (void) fclose(ftmp);
  511. X  }
  512. X}
  513. X
  514. X/* ---------------- nroff --------------- */
  515. X#ifdef __STDC__
  516. Xstatic void output_init_roff(format *dr)
  517. X#else
  518. Xstatic void output_init_roff(dr)
  519. X     format *dr;
  520. X#endif
  521. X{
  522. X}
  523. X
  524. X#ifdef __STDC__
  525. Xstatic void output_board_roff(format *dr,game *g)
  526. X#else
  527. Xstatic void output_board_roff(dr, g)
  528. X     format *dr;
  529. X     game * g;
  530. X#endif
  531. X{
  532. X  register int i,j;
  533. X
  534. X  dr->interrupt = TRUE;
  535. X
  536. X  (void) fprintf(dr->outfile,".br\n");
  537. X  for (i=8 ; i >=1 ; i--) {
  538. X    (void) fprintf(dr->outfile,".ce\n  ");
  539. X    for (j=1 ; j<9 ; j++) {
  540. X      if (g->board[i][j] != VOID) {
  541. X    if (g->color[i][j] == WHITE) 
  542. X     (void) fputc(dr->out_table[g->board[i][j]], dr->outfile);
  543. X    else 
  544. X      (void) fputc(tolower(dr->out_table[g->board[i][j]]),dr->outfile);
  545. X      } else
  546. X    /*(void) fputc ( ((i+j)% 2)?' ':'/', dr->outfile);*/
  547. X    (void) fprintf(dr->outfile,".");
  548. X    }
  549. X    (void) fprintf(dr->outfile,"\n.br\n");
  550. X  }
  551. X  (void) fprintf(dr->outfile,"\n");
  552. X}
  553. X
  554. X/* ---------------- tex -------------------- */
  555. X#ifdef __STDC__
  556. Xstatic void output_init_tex(format *dr)
  557. X#else
  558. Xstatic void output_init_tex(dr)
  559. X     format *dr;
  560. X#endif
  561. X{
  562. X  register int c;
  563. X
  564. X  /* header text */
  565. X  fprintf(dr->outfile, "%% This file generated by the Notation program\n");
  566. X  fprintf(dr->outfile, "%% @ Henry Thomas 1991\n");
  567. X  fprintf(dr->outfile, "\\documentstyle[twocolumn,chess]{article}\n");
  568. X  fprintf(dr->outfile, "\\input{notation.tex}\n");
  569. X  fprintf(dr->outfile, "\n");
  570. X  fprintf(dr->outfile, "\\begin{document}\n");
  571. X  fprintf(dr->outfile, "\n");
  572. X  fprintf(dr->outfile, "\\begin{Mainline}{}{}\n");
  573. X}
  574. X
  575. X#ifdef __STDC__
  576. Xstatic void output_text_tex(format *dr, int type, char * string, int code)
  577. X#else
  578. Xstatic void output_text_tex(dr, type, string, code)
  579. X     format *dr ;
  580. X     int type;
  581. X     char * string;
  582. X     int code;
  583. X#endif
  584. X{
  585. X  if (type != T_COMMENT)
  586. X    (void) fprintf(dr->outfile, " \\nochess");
  587. X
  588. X  switch (type) {
  589. X  case T_COMMENT:
  590. X    if (com_tex[code] != '\0' )
  591. X      (void) fprintf(dr->outfile,"%s\\ ",com_tex[code]);
  592. X    else
  593. X      (void) fprintf(dr->outfile,"%s\\ ",com_short[code]);
  594. X      break;
  595. X  case T_TEXT:
  596. X    (void) fprintf(dr->outfile," %s ",string);
  597. X    break;
  598. X  case T_TITLE:
  599. X    (void) fprintf(dr->outfile,"\n\\ChessTitle{%s}\n",string);
  600. X    break;
  601. X  case T_SUBTITLE:
  602. X    (void) fprintf(dr->outfile,"\n\\ChessSubTitle{%s}\n",string);
  603. X    break;
  604. X  case T_SCORE:
  605. X    (void) fprintf(dr->outfile,"\n\\ChessScore{%s}\n",string);
  606. X  default:
  607. X    break;
  608. X  };
  609. X  if (type != T_COMMENT)
  610. X    (void) fprintf(dr->outfile, "\\endnochess ");
  611. X}
  612. X
  613. X#ifdef __STDC__
  614. Xstatic void output_board_tex(format *dr,game *g)
  615. X#else
  616. Xstatic void output_board_tex(dr,g)
  617. X     format *dr;
  618. X     game * g;
  619. X#endif
  620. X{
  621. X  register int i,j;
  622. X
  623. X  dr->interrupt = TRUE;
  624. X
  625. X  (void) fprintf(dr->outfile,"\n\n\\begin{diagram}\n");
  626. X  (void)fprintf(dr->outfile,"\\board");
  627. X  for (i=8 ; i >=1 ; i--) {
  628. X    (void) fprintf(dr->outfile,"\t{");
  629. X    for (j=1 ; j < 9 ; j++) {
  630. X    (void) fprintf(dr->outfile,"%s",
  631. X           texboard_table[g->board[i][j]][PSINDEX(g->color[i][j],(i+j))]);
  632. X    }
  633. X    (void) fprintf(dr->outfile,"}\n");
  634. X  }
  635. X  (void) fprintf(dr->outfile,"\\end{diagram}\n\n");
  636. X}
  637. X
  638. X#ifdef __STDC__
  639. Xstatic void output_end_tex(format *dr)
  640. X#else
  641. Xstatic void output_end_tex(dr)
  642. X     format *dr;
  643. X#endif
  644. X{ 
  645. X  (void) fprintf(dr->outfile, "\n\\end{Mainline}\n");
  646. X  (void) fprintf(dr->outfile, " \n\n\n\\end{document}\n");
  647. X}
  648. X
  649. X/* ------------------ gnu - xchess ---------- */
  650. X
  651. X#ifdef __STDC__
  652. Xstatic void output_init_gnu(format *dr)
  653. X#else
  654. Xstatic void output_init_gnu(dr)
  655. X     format *dr;
  656. X#endif
  657. X{
  658. X  (void) fprintf(dr->outfile, "X Chess -- Mon Dec 10 11:47:18 MET 1990\n");
  659. X  (void) fprintf(dr->outfile,"\tGame played on dummkopft.irisa.fr:0.0\n");
  660. X  (void) fprintf(dr->outfile,"\talgebraic\n");
  661. X}
  662. X
  663. X/* ---------------- driver handler ---------- */
  664. X/* dummy driver */
  665. X#ifdef __STDC__
  666. Xstatic void null_driver(void) {}
  667. X#else
  668. Xstatic void null_driver() {}
  669. X#endif
  670. X
  671. X/* the drivers */
  672. X#ifdef __STDC__
  673. Xvoid output_init(format *dr)
  674. X#else
  675. Xvoid output_init(dr)
  676. X     format *dr ;
  677. X#endif
  678. X{
  679. X  if (dr->print_headers)
  680. X    dr->out_init(dr);
  681. X}
  682. X
  683. X#ifdef __STDC__
  684. Xvoid output_move(format *dr,depl *d)
  685. X#else
  686. Xvoid output_move(dr,d)
  687. X     format *dr ;
  688. X     depl *d;
  689. X#endif
  690. X{
  691. X  if (! (((dr->type == D_GNU) || (dr->type == D_XCHESS))
  692. X    && (dr->variation > 0)))
  693. X    dr->out_move(dr,d);
  694. X}
  695. X
  696. X#ifdef __STDC__
  697. Xvoid output_variation(format *dr, int inout)
  698. X#else
  699. Xvoid output_variation(dr, inout)
  700. X     format *dr ;
  701. X     int inout;
  702. X#endif
  703. X{
  704. X  dr->out_variation(dr,inout);
  705. X}
  706. X
  707. X#ifdef __STDC__
  708. Xvoid output_text(format *dr, int type, char *string, int code)
  709. X#else
  710. Xvoid output_text(dr, type, string, code)
  711. X     format *dr ;
  712. X     int type;
  713. X     char * string;
  714. X     int code;
  715. X#endif
  716. X{
  717. X  if ((dr->type != D_GNU) && (dr->type != D_XCHESS))
  718. X    dr->out_text(dr, type, string, code);
  719. X}
  720. X
  721. X#ifdef __STDC__
  722. Xvoid output_board(format *dr, game *g)
  723. X#else
  724. Xvoid output_board(dr,g)
  725. X     format *dr ;
  726. X     game *g ;
  727. X#endif
  728. X{
  729. X  dr->out_board(dr,g);
  730. X}
  731. X
  732. X#ifdef __STDC__
  733. Xvoid output_end(format *dr)
  734. X#else
  735. Xvoid output_end(dr)
  736. X     format *dr ;
  737. X#endif
  738. X{
  739. X  if (dr->print_headers)
  740. X    dr->out_end(dr);
  741. X  (void) fprintf(dr->outfile,"\n");
  742. X}
  743. X
  744. X
  745. X#ifdef __STDC__
  746. Xformat * new_driver(void)
  747. X#else
  748. Xformat * new_driver()
  749. X#endif
  750. X{
  751. X  format * tmp;
  752. X  int i; 
  753. X
  754. X  tmp = (format *) malloc (sizeof(format));
  755. X  ALLOCP(tmp);
  756. X  for (i=0; i < ((sizeof (format))/ sizeof (int)) ; i++)
  757. X    ((int *) tmp)[i] = 0;
  758. X  tmp->output_move_format = SHORTENED;
  759. X  tmp->print_headers = TRUE;
  760. X  return(tmp);
  761. X}
  762. X
  763. X#ifdef __STDC__
  764. Xvoid init_driver(format *dr,int driver)
  765. X#else
  766. Xvoid init_driver(dr,driver)
  767. X     format * dr;
  768. X     int driver;
  769. X#endif
  770. X{
  771. X  dr->type = driver ;
  772. X
  773. X  init_buffer(dr, VOID);
  774. X  switch (dr->type) {
  775. X  case D_ASCII:
  776. X    dr->print_move = TRUE;
  777. X    dr->print_piece = TRUE;
  778. X    dr->print_pawn = FALSE;
  779. X    dr->roque_alg = FALSE;
  780. X    dr->print_liaison = TRUE;
  781. X    dr->out_init = output_init_ascii;
  782. X    dr->out_move = output_move_generic;
  783. X    dr->out_variation = output_variation_generic;
  784. X    dr->out_text = output_text_generic;
  785. X    dr->out_board = output_board_ascii;
  786. X    dr->out_end = null_driver;
  787. X    break;
  788. X  case D_POST:
  789. X    dr->out_init = null_driver;
  790. X    dr->out_move = null_driver;
  791. X    dr->out_variation = null_driver;
  792. X    dr->out_text = null_driver;
  793. X    dr->out_board = output_board_ps;
  794. X    dr->out_end = null_driver;
  795. X    break;
  796. X  case D_TEX:
  797. X    dr->print_move = TRUE;
  798. X    dr->print_piece = TRUE;
  799. X    dr->print_pawn = FALSE;
  800. X    dr->roque_alg = FALSE;
  801. X    dr->print_liaison = TRUE;
  802. X    dr->out_init = output_init_tex;
  803. X    dr->out_move = output_move_generic;
  804. X    dr->out_variation = output_variation_generic;
  805. X    dr->out_text = output_text_tex;
  806. X    dr->out_board = output_board_tex;
  807. X    dr->out_end = output_end_tex;
  808. X    break;
  809. X  case D_ROFF:
  810. X    dr->print_move = TRUE;
  811. X    dr->print_piece = TRUE;
  812. X    dr->print_pawn = FALSE;
  813. X    dr->roque_alg = FALSE;
  814. X    dr->print_liaison = TRUE;
  815. X    dr->out_init = output_init_roff;
  816. X    dr->out_move = output_move_generic;
  817. X    dr->out_variation = output_variation_generic;
  818. X    dr->out_text = output_text_generic;
  819. X    dr->out_board = output_board_roff;
  820. X    dr->out_end = null_driver;
  821. X    break;
  822. X  case D_XCHESS:
  823. X    dr->output_move_format = ALGEBRAIC;
  824. X    dr->print_move = TRUE;
  825. X    dr->print_piece = FALSE;
  826. X    dr->print_pawn = FALSE;
  827. X    dr->roque_alg = TRUE;
  828. X    dr->print_liaison = FALSE;
  829. X    dr->out_init = output_init_gnu;
  830. X    dr->out_move = output_move_generic;
  831. X    dr->out_variation = null_driver;
  832. X    dr->out_text = null_driver;
  833. X    dr->out_board = null_driver;
  834. X    dr->out_end = null_driver;
  835. X    break;
  836. X  case D_GNU:
  837. X    dr->output_move_format = ALGEBRAIC;
  838. X    dr->print_move = FALSE;
  839. X    dr->print_piece = FALSE;
  840. X    dr->print_pawn = FALSE;
  841. X    dr->roque_alg = TRUE;
  842. X    dr->print_liaison = FALSE;
  843. X    dr->out_init = null_driver;
  844. X    dr->out_move = output_move_generic;
  845. X    dr->out_variation = null_driver;
  846. X    dr->out_text = null_driver;
  847. X    dr->out_board = null_driver;
  848. X    dr->out_end = null_driver;
  849. X    break;
  850. X  default:
  851. X    error((stderr,"unknown driver"));
  852. X    break;
  853. X  }
  854. X  if (dr->only_board)
  855. X    dr->out_move = null_driver ;
  856. X
  857. X  dr->variation = 0;
  858. X  dr->iswhiteturn = FALSE ;
  859. X  dr->interrupt = FALSE;
  860. X}
  861. END_OF_FILE
  862.   if test 20741 -ne `wc -c <'drivers.c'`; then
  863.     echo shar: \"'drivers.c'\" unpacked with wrong size!
  864.   fi
  865.   # end of 'drivers.c'
  866. fi
  867. if test -f 'lexer.c' -a "${1}" != "-c" ; then 
  868.   echo shar: Will not clobber existing file \"'lexer.c'\"
  869. else
  870.   echo shar: Extracting \"'lexer.c'\" \(32987 characters\)
  871.   sed "s/^X//" >'lexer.c' <<'END_OF_FILE'
  872. X/* A lexical scanner generated by flex */
  873. X
  874. X/* scanner skeleton version:
  875. X * $Header: /usr/fsys/odin/a/vern/flex/RCS/flex.skel,v 2.16 90/08/03 14:09:36 vern Exp $
  876. X */
  877. X
  878. X#define FLEX_SCANNER
  879. X
  880. X#include <stdio.h>
  881. X
  882. X
  883. X/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
  884. X#ifdef c_plusplus
  885. X#ifndef __cplusplus
  886. X#define __cplusplus
  887. X#endif
  888. X#endif
  889. X
  890. X
  891. X#ifdef __cplusplus
  892. X
  893. X#include <stdlib.h>
  894. X#include <osfcn.h>
  895. X
  896. X/* use prototypes in function declarations */
  897. X#define YY_USE_PROTOS
  898. X
  899. X/* the "const" storage-class-modifier is valid */
  900. X#define YY_USE_CONST
  901. X
  902. X#else    /* ! __cplusplus */
  903. X
  904. X#ifdef __STDC__
  905. X
  906. X#ifdef __GNUC__
  907. X#include <stddef.h>
  908. Xvoid *malloc( size_t );
  909. Xvoid free( void* );
  910. X#else
  911. X#include <stdlib.h>
  912. X#endif    /* __GNUC__ */
  913. X
  914. X#define YY_USE_PROTOS
  915. X#define YY_USE_CONST
  916. X
  917. X#endif    /* __STDC__ */
  918. X#endif    /* ! __cplusplus */
  919. X
  920. X
  921. X#ifdef __TURBOC__
  922. X#define YY_USE_CONST
  923. X#endif
  924. X
  925. X
  926. X#ifndef YY_USE_CONST
  927. X#define const
  928. X#endif
  929. X
  930. X
  931. X#ifdef YY_USE_PROTOS
  932. X#define YY_PROTO(proto) proto
  933. X#else
  934. X#define YY_PROTO(proto) ()
  935. X/* we can't get here if it's an ANSI C compiler, or a C++ compiler,
  936. X * so it's got to be a K&R compiler, and therefore there's no standard
  937. X * place from which to include these definitions
  938. X */
  939. Xchar *malloc();
  940. Xint free();
  941. Xint read();
  942. X#endif
  943. X
  944. X
  945. X/* amount of stuff to slurp up with each read */
  946. X#ifndef YY_READ_BUF_SIZE
  947. X#define YY_READ_BUF_SIZE 8192
  948. X#endif
  949. X
  950. X/* returned upon end-of-file */
  951. X#define YY_END_TOK 0
  952. X
  953. X/* copy whatever the last rule matched to the standard output */
  954. X
  955. X/* cast to (char *) is because for 8-bit chars, yytext is (unsigned char *) */
  956. X/* this used to be an fputs(), but since the string might contain NUL's,
  957. X * we now use fwrite()
  958. X */
  959. X#define ECHO (void) fwrite( (char *) yytext, yyleng, 1, yyout )
  960. X
  961. X/* gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
  962. X * is returned in "result".
  963. X */
  964. X#define YY_INPUT(buf,result,max_size) \
  965. X    if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \
  966. X        YY_FATAL_ERROR( "read() in flex scanner failed" );
  967. X#define YY_NULL 0
  968. X
  969. X/* no semi-colon after return; correct usage is to write "yyterminate();" -
  970. X * we don't want an extra ';' after the "return" because that will cause
  971. X * some compilers to complain about unreachable statements.
  972. X */
  973. X#define yyterminate() return ( YY_NULL )
  974. X
  975. X/* report a fatal error */
  976. X
  977. X/* The funky do-while is used to turn this macro definition into
  978. X * a single C statement (which needs a semi-colon terminator).
  979. X * This avoids problems with code like:
  980. X *
  981. X *     if ( something_happens )
  982. X *        YY_FATAL_ERROR( "oops, the something happened" );
  983. X *    else
  984. X *        everything_okay();
  985. X *
  986. X * Prior to using the do-while the compiler would get upset at the
  987. X * "else" because it interpreted the "if" statement as being all
  988. X * done when it reached the ';' after the YY_FATAL_ERROR() call.
  989. X */
  990. X
  991. X#define YY_FATAL_ERROR(msg) \
  992. X    do \
  993. X        { \
  994. X        (void) fputs( msg, stderr ); \
  995. X        (void) putc( '\n', stderr ); \
  996. X        exit( 1 ); \
  997. X        } \
  998. X    while ( 0 )
  999. X
  1000. X/* default yywrap function - always treat EOF as an EOF */
  1001. X#define yywrap() 1
  1002. X
  1003. X/* enter a start condition.  This macro really ought to take a parameter,
  1004. X * but we do it the disgusting crufty way forced on us by the ()-less
  1005. X * definition of BEGIN
  1006. X */
  1007. X#define BEGIN yy_start = 1 + 2 *
  1008. X
  1009. X/* action number for EOF rule of a given start state */
  1010. X#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
  1011. X
  1012. X/* special action meaning "start processing a new file" */
  1013. X#define YY_NEW_FILE \
  1014. X    do \
  1015. X        { \
  1016. X        yy_init_buffer( yy_current_buffer, yyin ); \
  1017. X        yy_load_buffer_state(); \
  1018. X        } \
  1019. X    while ( 0 )
  1020. X
  1021. X/* default declaration of generated scanner - a define so the user can
  1022. X * easily add parameters
  1023. X */
  1024. X#define YY_DECL int yylex YY_PROTO(( void )) 
  1025. X
  1026. X/* code executed at the end of each rule */
  1027. X#define YY_BREAK break;
  1028. X
  1029. X#define YY_END_OF_BUFFER_CHAR 0
  1030. X
  1031. X#ifndef YY_BUF_SIZE
  1032. X#define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of default input buffer */
  1033. X#endif
  1034. X
  1035. Xtypedef struct yy_buffer_state *YY_BUFFER_STATE;
  1036. X
  1037. X#define YY_CHAR char
  1038. X# line 1 "lexer.l"
  1039. X#define INITIAL 0
  1040. X/* DO NOT REMOVE THIS LINE                      */
  1041. X/*                                              */
  1042. X/* Notation program                             */
  1043. X/* @(#)lexer.l    3.9 (C) Henry Thomas   Release 3     Dated 12/10/91 */
  1044. X/*                                              */
  1045. X# line 7 "lexer.l"
  1046. X#include <stdio.h>
  1047. X
  1048. X#include "chesstype.h"
  1049. X#include"notation.h"
  1050. X
  1051. X#define NCURLINE 1024
  1052. Xchar curline [NCURLINE] ;
  1053. X
  1054. X#define LARGE_BUF 4096
  1055. Xstatic char commbuf[LARGE_BUF];
  1056. X
  1057. Xint column = 0;
  1058. Xint lineno = 1;
  1059. X
  1060. X#ifdef __STDC__
  1061. Xextern void count(void);
  1062. Xextern char * comment(int closing);
  1063. X#else
  1064. Xextern void count();
  1065. Xextern char * comment();
  1066. X#endif
  1067. X
  1068. X# line 34 "lexer.l"
  1069. X
  1070. X/* done after the current pattern has been matched and before the
  1071. X * corresponding action - sets up yytext
  1072. X */
  1073. X#define YY_DO_BEFORE_ACTION \
  1074. X    yytext = yy_bp; \
  1075. X    yyleng = yy_cp - yy_bp; \
  1076. X    yy_hold_char = *yy_cp; \
  1077. X    *yy_cp = '\0'; \
  1078. X    yy_c_buf_p = yy_cp;
  1079. X
  1080. X#define EOB_ACT_CONTINUE_SCAN 0
  1081. X#define EOB_ACT_END_OF_FILE 1
  1082. X#define EOB_ACT_LAST_MATCH 2
  1083. X
  1084. X/* return all but the first 'n' matched characters back to the input stream */
  1085. X#define yyless(n) \
  1086. X    do \
  1087. X        { \
  1088. X        /* undo effects of setting up yytext */ \
  1089. X        *yy_cp = yy_hold_char; \
  1090. X        yy_c_buf_p = yy_cp = yy_bp + n; \
  1091. X        YY_DO_BEFORE_ACTION; /* set up yytext again */ \
  1092. X        } \
  1093. X    while ( 0 )
  1094. X
  1095. X#define unput(c) yyunput( c, yytext )
  1096. X
  1097. X
  1098. Xstruct yy_buffer_state
  1099. X    {
  1100. X    FILE *yy_input_file;
  1101. X
  1102. X    YY_CHAR *yy_ch_buf;        /* input buffer */
  1103. X    YY_CHAR *yy_buf_pos;    /* current position in input buffer */
  1104. X
  1105. X    /* size of input buffer in bytes, not including room for EOB characters*/
  1106. X    int yy_buf_size;    
  1107. X
  1108. X    /* number of characters read into yy_ch_buf, not including EOB characters */
  1109. X    int yy_n_chars;
  1110. X
  1111. X    int yy_eof_status;        /* whether we've seen an EOF on this buffer */
  1112. X#define EOF_NOT_SEEN 0
  1113. X    /* "pending" happens when the EOF has been seen but there's still
  1114. X     * some text process
  1115. X     */
  1116. X#define EOF_PENDING 1
  1117. X#define EOF_DONE 2
  1118. X    };
  1119. X
  1120. Xstatic YY_BUFFER_STATE yy_current_buffer;
  1121. X
  1122. X/* we provide macros for accessing buffer states in case in the
  1123. X * future we want to put the buffer states in a more general
  1124. X * "scanner state"
  1125. X */
  1126. X#define YY_CURRENT_BUFFER yy_current_buffer
  1127. X
  1128. X
  1129. X/* yy_hold_char holds the character lost when yytext is formed */
  1130. Xstatic YY_CHAR yy_hold_char;
  1131. X
  1132. Xstatic int yy_n_chars;        /* number of characters read into yy_ch_buf */
  1133. X
  1134. X
  1135. X
  1136. X#ifndef YY_USER_ACTION
  1137. X#define YY_USER_ACTION
  1138. X#endif
  1139. X
  1140. X#ifndef YY_USER_INIT
  1141. X#define YY_USER_INIT
  1142. X#endif
  1143. X
  1144. Xextern YY_CHAR *yytext;
  1145. Xextern int yyleng;
  1146. Xextern FILE *yyin, *yyout;
  1147. X
  1148. XYY_CHAR *yytext;
  1149. Xint yyleng;
  1150. X
  1151. XFILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
  1152. X
  1153. X#define YY_END_OF_BUFFER 32
  1154. Xtypedef int yy_state_type;
  1155. Xstatic const short int yy_accept[83] =
  1156. X    {   0,
  1157. X        0,    0,   32,   30,   29,   29,    8,    7,   30,    7,
  1158. X       25,   28,    7,    2,    2,   30,   30,   30,   30,   24,
  1159. X       30,   30,   30,   30,   26,   27,    6,    5,    5,    0,
  1160. X       13,    0,    0,    0,    0,    0,    2,    1,    2,    1,
  1161. X       18,   23,    0,    0,    0,    0,    1,    0,   14,    3,
  1162. X        0,    0,   20,    0,    0,    0,    1,    4,    0,   10,
  1163. X        9,   11,    3,    0,    1,    1,   22,    1,    0,    1,
  1164. X       12,    3,    3,    3,    0,   19,    0,   17,   21,   20,
  1165. X       15,    0
  1166. X    } ;
  1167. X
  1168. Xstatic const YY_CHAR yy_ec[128] =
  1169. X    {   0,
  1170. X        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
  1171. X        2,    2,    1,    1,    1,    1,    1,    1,    1,    1,
  1172. X        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  1173. X        1,    2,    4,    1,    5,    6,    1,    7,    1,    8,
  1174. X        9,   10,   11,   12,   13,   14,   15,   16,   17,   17,
  1175. X       17,   17,   17,   17,   17,   17,   18,    1,   12,    7,
  1176. X       19,    7,    4,   20,   21,   21,   21,   21,   21,   21,
  1177. X       21,   21,   21,   21,   21,   21,   21,   21,   22,   21,
  1178. X       21,   21,   21,   21,   21,   21,   21,   23,   21,   21,
  1179. X       24,    7,   25,   26,    7,    1,   27,   27,   28,   27,
  1180. X
  1181. X       29,   27,   27,   27,   27,   27,   27,   27,   27,   27,
  1182. X       30,   31,   27,   27,   27,   32,   27,   27,   27,   33,
  1183. X       27,   27,   34,    7,   35,    7,    1
  1184. X    } ;
  1185. X
  1186. Xstatic const YY_CHAR yy_meta[36] =
  1187. X    {   0,
  1188. X        1,    1,    1,    1,    2,    1,    2,    1,    1,    2,
  1189. X        2,    1,    3,    1,    2,    1,    4,    1,    2,    1,
  1190. X        1,    1,    5,    1,    1,    6,    7,    7,    7,    7,
  1191. X        7,    7,    7,    1,    1
  1192. X    } ;
  1193. X
  1194. Xstatic const short int yy_base[90] =
  1195. X    {   0,
  1196. X        0,    0,  154,  246,  246,  246,   32,   42,    0,   37,
  1197. X       30,  246,   42,   63,   46,  127,   65,   86,   71,   40,
  1198. X       73,  107,  128,   74,  246,  246,  246,    0,    0,    0,
  1199. X      246,  143,  140,  123,  114,   73,  246,  149,  109,  156,
  1200. X      246,   32,   88,    0,    0,  152,  167,  104,  246,  171,
  1201. X      111,   81,   93,  105,   86,   62,  182,  246,    0,  246,
  1202. X      246,  246,  154,  180,  189,  246,  246,  198,  197,   66,
  1203. X      246,  125,  246,    0,   68,  246,   37,  246,  246,  246,
  1204. X      246,  246,   52,  223,  228,  233,  239,   47,   31
  1205. X    } ;
  1206. X
  1207. Xstatic const short int yy_def[90] =
  1208. X    {   0,
  1209. X       82,    1,   82,   82,   82,   82,   82,   82,   83,    8,
  1210. X       82,   82,    8,   82,   82,   84,   85,   82,   85,   82,
  1211. X       86,   82,   82,   86,   82,   82,   82,   87,   87,   88,
  1212. X       82,   82,   82,   82,   82,   82,   82,   82,   82,   82,
  1213. X       82,   84,   86,   24,   24,   43,   24,   82,   82,   24,
  1214. X       43,   82,   82,   82,   82,   82,   82,   82,   89,   82,
  1215. X       82,   82,   82,   82,   82,   82,   82,   82,   43,   82,
  1216. X       82,   82,   82,   43,   82,   82,   82,   82,   82,   82,
  1217. X       82,    0,   82,   82,   82,   82,   82,   82,   82
  1218. X    } ;
  1219. X
  1220. Xstatic const short int yy_nxt[282] =
  1221. X    {   0,
  1222. X        4,    5,    6,    7,    8,    9,   10,   11,    4,   10,
  1223. X        8,   12,   13,   12,   10,   14,   15,   15,   10,   16,
  1224. X       17,   18,   19,   20,    4,   10,   21,   21,   22,   23,
  1225. X       21,   21,   24,   25,   26,   27,   27,   79,   31,   32,
  1226. X       82,   29,   27,   33,   27,   27,   28,   29,   29,   29,
  1227. X       48,   29,   28,   59,   28,   34,   29,   82,   30,   37,
  1228. X       29,   39,   39,   39,   49,   67,   81,   29,   35,   35,
  1229. X       35,   35,   35,   35,   35,   36,   37,   43,   38,   39,
  1230. X       39,   80,   63,   43,   40,   43,   43,   43,   40,   50,
  1231. X       50,   78,   40,   43,   40,   43,   43,   45,   46,   77,
  1232. X
  1233. X       82,   40,   40,   45,   82,   51,   51,   40,   43,   63,
  1234. X       82,   75,   44,   44,   44,   47,   44,   44,   45,   43,
  1235. X       52,   63,   37,   50,   39,   39,   39,   63,   71,   43,
  1236. X       63,   62,   76,   35,   35,   35,   35,   53,   54,   51,
  1237. X       46,   55,   56,   40,   50,   73,   73,   73,   61,   40,
  1238. X       43,   60,   41,   82,   35,   35,   35,   57,   35,   35,
  1239. X       51,   64,   37,   82,   65,   39,   39,   40,   64,   82,
  1240. X       66,   66,   72,   40,   73,   73,   73,   66,   66,   69,
  1241. X       82,   68,   66,   82,   82,   66,   82,   82,   66,   72,
  1242. X       82,   73,   73,   74,   64,   66,   70,   66,   63,   82,
  1243. X
  1244. X       82,   66,   37,   66,   39,   39,   39,   82,   82,   66,
  1245. X       64,   66,   66,   66,   63,   82,   82,   82,   66,   66,
  1246. X       82,   82,   82,   82,   82,   82,   70,   66,   42,   42,
  1247. X       44,   82,   44,   82,   44,   35,   35,   35,   82,   35,
  1248. X       58,   58,   82,   82,   58,    3,   82,   82,   82,   82,
  1249. X       82,   82,   82,   82,   82,   82,   82,   82,   82,   82,
  1250. X       82,   82,   82,   82,   82,   82,   82,   82,   82,   82,
  1251. X       82,   82,   82,   82,   82,   82,   82,   82,   82,   82,
  1252. X       82
  1253. X    } ;
  1254. X
  1255. Xstatic const short int yy_chk[282] =
  1256. X    {   0,
  1257. X        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  1258. X        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  1259. X        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  1260. X        1,    1,    1,    1,    1,    7,    7,   89,   11,   11,
  1261. X       10,   10,    7,   11,    7,    8,    8,   10,    8,   10,
  1262. X       20,    8,    8,   88,    8,   11,    8,   42,   83,   15,
  1263. X        8,   15,   15,   15,   20,   42,   77,    8,   13,   13,
  1264. X       13,   13,   13,   13,   13,   14,   14,   17,   14,   14,
  1265. X       14,   75,   70,   19,   14,   21,   24,   17,   36,   21,
  1266. X       24,   56,   14,   19,   36,   21,   24,   17,   18,   55,
  1267. X
  1268. X       43,   18,   36,   19,   43,   21,   24,   18,   18,   53,
  1269. X       43,   52,   18,   18,   18,   18,   18,   18,   18,   22,
  1270. X       22,   54,   39,   22,   39,   39,   39,   51,   48,   22,
  1271. X       35,   34,   54,   22,   22,   22,   22,   22,   22,   22,
  1272. X       23,   23,   23,   23,   23,   72,   72,   72,   33,   23,
  1273. X       23,   32,   16,    3,   23,   23,   23,   23,   23,   23,
  1274. X       23,   38,   38,    0,   38,   38,   38,   46,   40,    0,
  1275. X       38,   40,   63,   46,   63,   63,   63,   40,   38,   47,
  1276. X        0,   46,   47,    0,    0,   40,    0,   50,   47,   50,
  1277. X        0,   50,   50,   50,   57,   64,   47,   57,   57,    0,
  1278. X
  1279. X        0,   64,   65,   57,   65,   65,   65,    0,    0,   64,
  1280. X       68,   57,   69,   68,   68,    0,    0,    0,   69,   68,
  1281. X        0,    0,    0,    0,    0,    0,   69,   68,   84,   84,
  1282. X       85,    0,   85,    0,   85,   86,   86,   86,    0,   86,
  1283. X       87,   87,    0,    0,   87,   82,   82,   82,   82,   82,
  1284. X       82,   82,   82,   82,   82,   82,   82,   82,   82,   82,
  1285. X       82,   82,   82,   82,   82,   82,   82,   82,   82,   82,
  1286. X       82,   82,   82,   82,   82,   82,   82,   82,   82,   82,
  1287. X       82
  1288. X    } ;
  1289. X
  1290. Xstatic yy_state_type yy_last_accepting_state;
  1291. Xstatic YY_CHAR *yy_last_accepting_cpos;
  1292. X
  1293. X/* the intent behind this definition is that it'll catch
  1294. X * any uses of REJECT which flex missed
  1295. X */
  1296. X#define REJECT reject_used_but_not_detected
  1297. X#define yymore() yymore_used_but_not_detected
  1298. X#define YY_MORE_ADJ 0
  1299. X
  1300. X/* these variables are all declared out here so that section 3 code can
  1301. X * manipulate them
  1302. X */
  1303. X/* points to current character in buffer */
  1304. Xstatic YY_CHAR *yy_c_buf_p = (YY_CHAR *) 0;
  1305. Xstatic int yy_init = 1;        /* whether we need to initialize */
  1306. Xstatic int yy_start = 0;    /* start state number */
  1307. X
  1308. X/* flag which is used to allow yywrap()'s to do buffer switches
  1309. X * instead of setting up a fresh yyin.  A bit of a hack ...
  1310. X */
  1311. Xstatic int yy_did_buffer_switch_on_eof;
  1312. X
  1313. Xstatic yy_state_type yy_get_previous_state YY_PROTO(( void ));
  1314. Xstatic yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
  1315. Xstatic int yy_get_next_buffer YY_PROTO(( void ));
  1316. Xstatic void yyunput YY_PROTO(( YY_CHAR c, YY_CHAR *buf_ptr ));
  1317. Xvoid yyrestart YY_PROTO(( FILE *input_file ));
  1318. Xvoid yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
  1319. Xvoid yy_load_buffer_state YY_PROTO(( void ));
  1320. XYY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
  1321. Xvoid yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
  1322. Xvoid yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
  1323. X
  1324. X#define yy_new_buffer yy_create_buffer
  1325. X
  1326. X#ifdef __cplusplus
  1327. Xstatic int yyinput YY_PROTO(( void ));
  1328. X#else
  1329. Xstatic int input YY_PROTO(( void ));
  1330. X#endif
  1331. X
  1332. XYY_DECL
  1333. X    {
  1334. X    register yy_state_type yy_current_state;
  1335. X    register YY_CHAR *yy_cp, *yy_bp;
  1336. X    register int yy_act;
  1337. X
  1338. X
  1339. X
  1340. X    if ( yy_init )
  1341. X    {
  1342. X    YY_USER_INIT;
  1343. X
  1344. X    if ( ! yy_start )
  1345. X        yy_start = 1;    /* first start state */
  1346. X
  1347. X    if ( ! yyin )
  1348. X        yyin = stdin;
  1349. X
  1350. X    if ( ! yyout )
  1351. X        yyout = stdout;
  1352. X
  1353. X    if ( yy_current_buffer )
  1354. X        yy_init_buffer( yy_current_buffer, yyin );
  1355. X    else
  1356. X        yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
  1357. X
  1358. X    yy_load_buffer_state();
  1359. X
  1360. X    yy_init = 0;
  1361. X    }
  1362. X
  1363. X    while ( 1 )        /* loops until end-of-file is reached */
  1364. X    {
  1365. X    yy_cp = yy_c_buf_p;
  1366. X
  1367. X    /* support of yytext */
  1368. X    *yy_cp = yy_hold_char;
  1369. X
  1370. X    /* yy_bp points to the position in yy_ch_buf of the start of the
  1371. X     * current run.
  1372. X     */
  1373. X    yy_bp = yy_cp;
  1374. X
  1375. X    yy_current_state = yy_start;
  1376. Xyy_match:
  1377. X    do
  1378. X        {
  1379. X        register YY_CHAR yy_c = yy_ec[*yy_cp];
  1380. X        if ( yy_accept[yy_current_state] )
  1381. X        {
  1382. X        yy_last_accepting_state = yy_current_state;
  1383. X        yy_last_accepting_cpos = yy_cp;
  1384. X        }
  1385. X        while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  1386. X        {
  1387. X        yy_current_state = yy_def[yy_current_state];
  1388. X        if ( yy_current_state >= 83 )
  1389. X            yy_c = yy_meta[yy_c];
  1390. X        }
  1391. X        yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  1392. X        ++yy_cp;
  1393. X        }
  1394. X    while ( yy_current_state != 82 );
  1395. X    yy_cp = yy_last_accepting_cpos;
  1396. X    yy_current_state = yy_last_accepting_state;
  1397. X
  1398. Xyy_find_action:
  1399. X    yy_act = yy_accept[yy_current_state];
  1400. X
  1401. X    YY_DO_BEFORE_ACTION;
  1402. X    YY_USER_ACTION;
  1403. X
  1404. Xdo_action:    /* this label is used only to access EOF actions */
  1405. X
  1406. X
  1407. X    switch ( yy_act )
  1408. X        {
  1409. X        case 0: /* must backtrack */
  1410. X        /* undo the effects of YY_DO_BEFORE_ACTION */
  1411. X        *yy_cp = yy_hold_char;
  1412. X        yy_cp = yy_last_accepting_cpos;
  1413. X        yy_current_state = yy_last_accepting_state;
  1414. X        goto yy_find_action;
  1415. X
  1416. Xcase 1:
  1417. X# line 35 "lexer.l"
  1418. X{ /* roque */ ; parse_roque(yytext); }
  1419. X    YY_BREAK
  1420. Xcase 2:
  1421. X# line 36 "lexer.l"
  1422. X{ /* move number */ parse_number(yytext); }
  1423. X    YY_BREAK
  1424. Xcase 3:
  1425. X# line 37 "lexer.l"
  1426. X{ /* move */  
  1427. X  (void) parse_move(yytext);
  1428. X  /*; fprintf(stderr,"%s, ",yytext);*/ 
  1429. X}
  1430. X    YY_BREAK
  1431. Xcase 4:
  1432. X# line 43 "lexer.l"
  1433. X{ /* comment */ ; 
  1434. X                parse_comment(yytext); }
  1435. X    YY_BREAK
  1436. Xcase 5:
  1437. X# line 45 "lexer.l"
  1438. X{ /* comment */ ; 
  1439. X                   parse_comment(yytext); }
  1440. X    YY_BREAK
  1441. Xcase 6:
  1442. X# line 47 "lexer.l"
  1443. X{ /* comment */ ; 
  1444. X                     parse_comment(yytext); }
  1445. X    YY_BREAK
  1446. Xcase 7:
  1447. X# line 49 "lexer.l"
  1448. X{ /* comment */ ; 
  1449. X               parse_comment(yytext); }
  1450. X    YY_BREAK
  1451. Xcase 8:
  1452. X# line 51 "lexer.l"
  1453. X{ /* comment */ ; parse_comment(yytext); }
  1454. X    YY_BREAK
  1455. Xcase 9:
  1456. X# line 52 "lexer.l"
  1457. X{ /* comment */ ; parse_comment(yytext); }
  1458. X    YY_BREAK
  1459. Xcase 10:
  1460. X# line 53 "lexer.l"
  1461. X{ /* comment */ ; parse_comment(yytext); }
  1462. X    YY_BREAK
  1463. Xcase 11:
  1464. X# line 54 "lexer.l"
  1465. X{ /* comment */ ; parse_comment(yytext); }
  1466. X    YY_BREAK
  1467. Xcase 12:
  1468. X# line 55 "lexer.l"
  1469. X{ /* comment */ ; parse_comment(yytext); }
  1470. X    YY_BREAK
  1471. Xcase 13:
  1472. X# line 56 "lexer.l"
  1473. X{ /* comment */ ; parse_comment(yytext); }
  1474. X    YY_BREAK
  1475. Xcase 14:
  1476. X# line 57 "lexer.l"
  1477. X{ /* comment */ ; parse_comment(yytext); }
  1478. X    YY_BREAK
  1479. Xcase 15:
  1480. X# line 58 "lexer.l"
  1481. X{ /* comment */ ; parse_comment(yytext); }
  1482. X    YY_BREAK
  1483. Xcase 16:
  1484. X# line 59 "lexer.l"
  1485. X{ /* comment */ ; parse_comment(yytext); }
  1486. X    YY_BREAK
  1487. Xcase 17:
  1488. X# line 60 "lexer.l"
  1489. X{ /* comment */ ; parse_comment(yytext); }
  1490. X    YY_BREAK
  1491. Xcase 18:
  1492. X# line 61 "lexer.l"
  1493. X{ /* comment */ ; parse_comment(yytext); }
  1494. X    YY_BREAK
  1495. Xcase 19:
  1496. X# line 62 "lexer.l"
  1497. X{ /* comment */ ; parse_comment("etc"); }
  1498. X    YY_BREAK
  1499. Xcase 20:
  1500. X# line 63 "lexer.l"
  1501. X{ /* comment */ ; parse_comment("ep"); }
  1502. X    YY_BREAK
  1503. Xcase 21:
  1504. X# line 64 "lexer.l"
  1505. X{ /* game comment */ ; parse_comment(yytext); }
  1506. X    YY_BREAK
  1507. Xcase 22:
  1508. X# line 65 "lexer.l"
  1509. X{ /* keyword with arg */ 
  1510. X  yytext[yyleng -1] = '\0' ;
  1511. X  parse_keyword(yytext, comment('}'));
  1512. X}
  1513. X    YY_BREAK
  1514. Xcase 23:
  1515. X# line 69 "lexer.l"
  1516. X{ /* keyword without arg */ 
  1517. X  parse_keyword(yytext,NULL); }
  1518. X    YY_BREAK
  1519. Xcase 24:
  1520. X# line 71 "lexer.l"
  1521. X{ parse_text(comment(']')); }
  1522. X    YY_BREAK
  1523. Xcase 25:
  1524. X# line 72 "lexer.l"
  1525. X{ parse_text(comment(')')); }
  1526. X    YY_BREAK
  1527. Xcase 26:
  1528. X# line 73 "lexer.l"
  1529. X{ /* enter variation */ ; enter_variation(); }
  1530. X    YY_BREAK
  1531. Xcase 27:
  1532. X# line 74 "lexer.l"
  1533. X{ /* close variation */ ; exit_variation(); }
  1534. X    YY_BREAK
  1535. Xcase 28:
  1536. X# line 75 "lexer.l"
  1537. X{ /* skip , ; */ ; }
  1538. X    YY_BREAK
  1539. Xcase 29:
  1540. X# line 76 "lexer.l"
  1541. X{ /* skip blanks */; }
  1542. X    YY_BREAK
  1543. Xcase 30:
  1544. X# line 77 "lexer.l"
  1545. X{ /* ignore bad characters */ (void) fprintf(stderr,"I don't understand: %s\n",yytext);}
  1546. X    YY_BREAK
  1547. Xcase 31:
  1548. X# line 78 "lexer.l"
  1549. XECHO;
  1550. X    YY_BREAK
  1551. Xcase YY_STATE_EOF(INITIAL):
  1552. X    yyterminate();
  1553. X
  1554. X        case YY_END_OF_BUFFER:
  1555. X        {
  1556. X        /* amount of text matched not including the EOB char */
  1557. X        int yy_amount_of_matched_text = yy_cp - yytext - 1;
  1558. X
  1559. X        /* undo the effects of YY_DO_BEFORE_ACTION */
  1560. X        *yy_cp = yy_hold_char;
  1561. X
  1562. X        /* note that here we test for yy_c_buf_p "<=" to the position
  1563. X         * of the first EOB in the buffer, since yy_c_buf_p will
  1564. X         * already have been incremented past the NUL character
  1565. X         * (since all states make transitions on EOB to the end-
  1566. X         * of-buffer state).  Contrast this with the test in yyinput().
  1567. X         */
  1568. X        if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  1569. X            /* this was really a NUL */
  1570. X            {
  1571. X            yy_state_type yy_next_state;
  1572. X
  1573. X            yy_c_buf_p = yytext + yy_amount_of_matched_text;
  1574. X
  1575. X            yy_current_state = yy_get_previous_state();
  1576. X
  1577. X            /* okay, we're now positioned to make the
  1578. X             * NUL transition.  We couldn't have
  1579. X             * yy_get_previous_state() go ahead and do it
  1580. X             * for us because it doesn't know how to deal
  1581. X             * with the possibility of jamming (and we
  1582. X             * don't want to build jamming into it because
  1583. X             * then it will run more slowly)
  1584. X             */
  1585. X
  1586. X            yy_next_state = yy_try_NUL_trans( yy_current_state );
  1587. X
  1588. X            yy_bp = yytext + YY_MORE_ADJ;
  1589. X
  1590. X            if ( yy_next_state )
  1591. X            {
  1592. X            /* consume the NUL */
  1593. X            yy_cp = ++yy_c_buf_p;
  1594. X            yy_current_state = yy_next_state;
  1595. X            goto yy_match;
  1596. X            }
  1597. X
  1598. X            else
  1599. X            {
  1600. X                yy_cp = yy_last_accepting_cpos;
  1601. X                yy_current_state = yy_last_accepting_state;
  1602. X            goto yy_find_action;
  1603. X            }
  1604. X            }
  1605. X
  1606. X        else switch ( yy_get_next_buffer() )
  1607. X            {
  1608. X            case EOB_ACT_END_OF_FILE:
  1609. X            {
  1610. X            yy_did_buffer_switch_on_eof = 0;
  1611. X
  1612. X            if ( yywrap() )
  1613. X                {
  1614. X                /* note: because we've taken care in
  1615. X                 * yy_get_next_buffer() to have set up yytext,
  1616. X                 * we can now set up yy_c_buf_p so that if some
  1617. X                 * total hoser (like flex itself) wants
  1618. X                 * to call the scanner after we return the
  1619. X                 * YY_NULL, it'll still work - another YY_NULL
  1620. X                 * will get returned.
  1621. X                 */
  1622. X                yy_c_buf_p = yytext + YY_MORE_ADJ;
  1623. X
  1624. X                yy_act = YY_STATE_EOF((yy_start - 1) / 2);
  1625. X                goto do_action;
  1626. X                }
  1627. X
  1628. X            else
  1629. X                {
  1630. X                if ( ! yy_did_buffer_switch_on_eof )
  1631. X                YY_NEW_FILE;
  1632. X                }
  1633. X            }
  1634. X            break;
  1635. X
  1636. X            case EOB_ACT_CONTINUE_SCAN:
  1637. X            yy_c_buf_p = yytext + yy_amount_of_matched_text;
  1638. X
  1639. X            yy_current_state = yy_get_previous_state();
  1640. X
  1641. X            yy_cp = yy_c_buf_p;
  1642. X            yy_bp = yytext + YY_MORE_ADJ;
  1643. X            goto yy_match;
  1644. X
  1645. X            case EOB_ACT_LAST_MATCH:
  1646. X            yy_c_buf_p =
  1647. X                &yy_current_buffer->yy_ch_buf[yy_n_chars];
  1648. X
  1649. X            yy_current_state = yy_get_previous_state();
  1650. X
  1651. X            yy_cp = yy_c_buf_p;
  1652. X            yy_bp = yytext + YY_MORE_ADJ;
  1653. X            goto yy_find_action;
  1654. X            }
  1655. X        break;
  1656. X        }
  1657. X
  1658. X        default:
  1659. X#ifdef FLEX_DEBUG
  1660. X        printf( "action # %d\n", yy_act );
  1661. X#endif
  1662. X        YY_FATAL_ERROR(
  1663. X            "fatal flex scanner internal error--no action found" );
  1664. X        }
  1665. X    }
  1666. X    }
  1667. X
  1668. X
  1669. X/* yy_get_next_buffer - try to read in a new buffer
  1670. X *
  1671. X * synopsis
  1672. X *     int yy_get_next_buffer();
  1673. X *     
  1674. X * returns a code representing an action
  1675. X *     EOB_ACT_LAST_MATCH - 
  1676. X *     EOB_ACT_CONTINUE_SCAN - continue scanning from current position
  1677. X *     EOB_ACT_END_OF_FILE - end of file
  1678. X */
  1679. X
  1680. Xstatic int yy_get_next_buffer()
  1681. X
  1682. X    {
  1683. X    register YY_CHAR *dest = yy_current_buffer->yy_ch_buf;
  1684. X    register YY_CHAR *source = yytext - 1; /* copy prev. char, too */
  1685. X    register int number_to_move, i;
  1686. X    int ret_val;
  1687. X
  1688. X    if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
  1689. X    YY_FATAL_ERROR(
  1690. X        "fatal flex scanner internal error--end of buffer missed" );
  1691. X
  1692. X    /* try to read more data */
  1693. X
  1694. X    /* first move last chars to start of buffer */
  1695. X    number_to_move = yy_c_buf_p - yytext;
  1696. X
  1697. X    for ( i = 0; i < number_to_move; ++i )
  1698. X    *(dest++) = *(source++);
  1699. X
  1700. X    if ( yy_current_buffer->yy_eof_status != EOF_NOT_SEEN )
  1701. X    /* don't do the read, it's not guaranteed to return an EOF,
  1702. X     * just force an EOF
  1703. X     */
  1704. X    yy_n_chars = 0;
  1705. X
  1706. X    else
  1707. X    {
  1708. X    int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1;
  1709. X
  1710. X    if ( num_to_read > YY_READ_BUF_SIZE )
  1711. X        num_to_read = YY_READ_BUF_SIZE;
  1712. X
  1713. X    else if ( num_to_read <= 0 )
  1714. X        YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" );
  1715. X
  1716. X    /* read in more data */
  1717. X    YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
  1718. X          yy_n_chars, num_to_read );
  1719. X    }
  1720. X
  1721. X    if ( yy_n_chars == 0 )
  1722. X    {
  1723. X    if ( number_to_move == 1 )
  1724. X        {
  1725. X        ret_val = EOB_ACT_END_OF_FILE;
  1726. X        yy_current_buffer->yy_eof_status = EOF_DONE;
  1727. X        }
  1728. X
  1729. X    else
  1730. X        {
  1731. X        ret_val = EOB_ACT_LAST_MATCH;
  1732. X        yy_current_buffer->yy_eof_status = EOF_PENDING;
  1733. X        }
  1734. X    }
  1735. X
  1736. X    else
  1737. X    ret_val = EOB_ACT_CONTINUE_SCAN;
  1738. X
  1739. X    yy_n_chars += number_to_move;
  1740. X    yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
  1741. X    yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
  1742. X
  1743. X    /* yytext begins at the second character in yy_ch_buf; the first
  1744. X     * character is the one which preceded it before reading in the latest
  1745. X     * buffer; it needs to be kept around in case it's a newline, so
  1746. X     * yy_get_previous_state() will have with '^' rules active
  1747. X     */
  1748. X
  1749. X    yytext = &yy_current_buffer->yy_ch_buf[1];
  1750. X
  1751. X    return ( ret_val );
  1752. X    }
  1753. X
  1754. X
  1755. X/* yy_get_previous_state - get the state just before the EOB char was reached
  1756. X *
  1757. X * synopsis
  1758. X *     yy_state_type yy_get_previous_state();
  1759. X */
  1760. X
  1761. Xstatic yy_state_type yy_get_previous_state()
  1762. X
  1763. X    {
  1764. X    register yy_state_type yy_current_state;
  1765. X    register YY_CHAR *yy_cp;
  1766. X
  1767. X    yy_current_state = yy_start;
  1768. X
  1769. X    for ( yy_cp = yytext + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
  1770. X    {
  1771. X    register YY_CHAR yy_c = (*yy_cp ? yy_ec[*yy_cp] : 1);
  1772. X    if ( yy_accept[yy_current_state] )
  1773. X        {
  1774. X        yy_last_accepting_state = yy_current_state;
  1775. X        yy_last_accepting_cpos = yy_cp;
  1776. X        }
  1777. X    while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  1778. X        {
  1779. X        yy_current_state = yy_def[yy_current_state];
  1780. X        if ( yy_current_state >= 83 )
  1781. X        yy_c = yy_meta[yy_c];
  1782. X        }
  1783. X    yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  1784. X    }
  1785. X
  1786. X    return ( yy_current_state );
  1787. X    }
  1788. X
  1789. X
  1790. X/* yy_try_NUL_trans - try to make a transition on the NUL character
  1791. X *
  1792. X * synopsis
  1793. X *     next_state = yy_try_NUL_trans( current_state );
  1794. X */
  1795. X
  1796. X#ifdef YY_USE_PROTOS
  1797. Xstatic yy_state_type yy_try_NUL_trans( register yy_state_type yy_current_state )
  1798. X#else
  1799. Xstatic yy_state_type yy_try_NUL_trans( yy_current_state )
  1800. Xregister yy_state_type yy_current_state;
  1801. X#endif
  1802. X
  1803. X    {
  1804. X    register int yy_is_jam;
  1805. X    register YY_CHAR *yy_cp = yy_c_buf_p;
  1806. X
  1807. X    register YY_CHAR yy_c = 1;
  1808. X    if ( yy_accept[yy_current_state] )
  1809. X    {
  1810. X    yy_last_accepting_state = yy_current_state;
  1811. X    yy_last_accepting_cpos = yy_cp;
  1812. X    }
  1813. X    while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  1814. X    {
  1815. X    yy_current_state = yy_def[yy_current_state];
  1816. X    if ( yy_current_state >= 83 )
  1817. X        yy_c = yy_meta[yy_c];
  1818. X    }
  1819. X    yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  1820. X    yy_is_jam = (yy_current_state == 82);
  1821. X
  1822. X    return ( yy_is_jam ? 0 : yy_current_state );
  1823. X    }
  1824. X
  1825. X
  1826. X#ifdef YY_USE_PROTOS
  1827. Xstatic void yyunput( YY_CHAR c, register YY_CHAR *yy_bp )
  1828. X#else
  1829. Xstatic void yyunput( c, yy_bp )
  1830. XYY_CHAR c;
  1831. Xregister YY_CHAR *yy_bp;
  1832. X#endif
  1833. X
  1834. X    {
  1835. X    register YY_CHAR *yy_cp = yy_c_buf_p;
  1836. X
  1837. X    /* undo effects of setting up yytext */
  1838. X    *yy_cp = yy_hold_char;
  1839. X
  1840. X    if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  1841. X    { /* need to shift things up to make room */
  1842. X    register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */
  1843. X    register YY_CHAR *dest =
  1844. X        &yy_current_buffer->yy_ch_buf[yy_current_buffer->yy_buf_size + 2];
  1845. X    register YY_CHAR *source =
  1846. X        &yy_current_buffer->yy_ch_buf[number_to_move];
  1847. X
  1848. X    while ( source > yy_current_buffer->yy_ch_buf )
  1849. X        *--dest = *--source;
  1850. X
  1851. X    yy_cp += dest - source;
  1852. X    yy_bp += dest - source;
  1853. X    yy_n_chars = yy_current_buffer->yy_buf_size;
  1854. X
  1855. X    if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  1856. X        YY_FATAL_ERROR( "flex scanner push-back overflow" );
  1857. X    }
  1858. X
  1859. X    if ( yy_cp > yy_bp && yy_cp[-1] == '\n' )
  1860. X    yy_cp[-2] = '\n';
  1861. X
  1862. X    *--yy_cp = c;
  1863. X
  1864. X    /* note: the formal parameter *must* be called "yy_bp" for this
  1865. X     *       macro to now work correctly
  1866. X     */
  1867. X    YY_DO_BEFORE_ACTION; /* set up yytext again */
  1868. X    }
  1869. X
  1870. X
  1871. X#ifdef __cplusplus
  1872. Xstatic int yyinput()
  1873. X#else
  1874. Xstatic int input()
  1875. X#endif
  1876. X
  1877. X    {
  1878. X    int c;
  1879. X    YY_CHAR *yy_cp = yy_c_buf_p;
  1880. X
  1881. X    *yy_cp = yy_hold_char;
  1882. X
  1883. X    if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
  1884. X    {
  1885. X    /* yy_c_buf_p now points to the character we want to return.
  1886. X     * If this occurs *before* the EOB characters, then it's a
  1887. X     * valid NUL; if not, then we've hit the end of the buffer.
  1888. X     */
  1889. X    if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  1890. X        /* this was really a NUL */
  1891. X        *yy_c_buf_p = '\0';
  1892. X
  1893. X    else
  1894. X        { /* need more input */
  1895. X        yytext = yy_c_buf_p;
  1896. X        ++yy_c_buf_p;
  1897. X
  1898. X        switch ( yy_get_next_buffer() )
  1899. X        {
  1900. X        case EOB_ACT_END_OF_FILE:
  1901. X            {
  1902. X            if ( yywrap() )
  1903. X            {
  1904. X            yy_c_buf_p = yytext + YY_MORE_ADJ;
  1905. X            return ( EOF );
  1906. X            }
  1907. X
  1908. X            YY_NEW_FILE;
  1909. X
  1910. X#ifdef __cplusplus
  1911. X            return ( yyinput() );
  1912. X#else
  1913. X            return ( input() );
  1914. X#endif
  1915. X            }
  1916. X            break;
  1917. X
  1918. X        case EOB_ACT_CONTINUE_SCAN:
  1919. X            yy_c_buf_p = yytext + YY_MORE_ADJ;
  1920. X            break;
  1921. X
  1922. X        case EOB_ACT_LAST_MATCH:
  1923. X#ifdef __cplusplus
  1924. X            YY_FATAL_ERROR( "unexpected last match in yyinput()" );
  1925. X#else
  1926. X            YY_FATAL_ERROR( "unexpected last match in input()" );
  1927. X#endif
  1928. X        }
  1929. X        }
  1930. X    }
  1931. X
  1932. X    c = *yy_c_buf_p;
  1933. X    yy_hold_char = *++yy_c_buf_p;
  1934. X
  1935. X    return ( c );
  1936. X    }
  1937. X
  1938. X
  1939. X#ifdef YY_USE_PROTOS
  1940. Xvoid yyrestart( FILE *input_file )
  1941. X#else
  1942. Xvoid yyrestart( input_file )
  1943. XFILE *input_file;
  1944. X#endif
  1945. X
  1946. X    {
  1947. X    yy_init_buffer( yy_current_buffer, input_file );
  1948. X    yy_load_buffer_state();
  1949. X    }
  1950. X
  1951. X
  1952. X#ifdef YY_USE_PROTOS
  1953. Xvoid yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
  1954. X#else
  1955. Xvoid yy_switch_to_buffer( new_buffer )
  1956. XYY_BUFFER_STATE new_buffer;
  1957. X#endif
  1958. X
  1959. X    {
  1960. X    if ( yy_current_buffer == new_buffer )
  1961. X    return;
  1962. X
  1963. X    if ( yy_current_buffer )
  1964. X    {
  1965. X    /* flush out information for old buffer */
  1966. X    *yy_c_buf_p = yy_hold_char;
  1967. X    yy_current_buffer->yy_buf_pos = yy_c_buf_p;
  1968. X    yy_current_buffer->yy_n_chars = yy_n_chars;
  1969. X    }
  1970. X
  1971. X    yy_current_buffer = new_buffer;
  1972. X    yy_load_buffer_state();
  1973. X
  1974. X    /* we don't actually know whether we did this switch during
  1975. X     * EOF (yywrap()) processing, but the only time this flag
  1976. X     * is looked at is after yywrap() is called, so it's safe
  1977. X     * to go ahead and always set it.
  1978. X     */
  1979. X    yy_did_buffer_switch_on_eof = 1;
  1980. X    }
  1981. X
  1982. X
  1983. X#ifdef YY_USE_PROTOS
  1984. Xvoid yy_load_buffer_state( void )
  1985. X#else
  1986. Xvoid yy_load_buffer_state()
  1987. X#endif
  1988. X
  1989. X    {
  1990. X    yy_n_chars = yy_current_buffer->yy_n_chars;
  1991. X    yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
  1992. X    yyin = yy_current_buffer->yy_input_file;
  1993. X    yy_hold_char = *yy_c_buf_p;
  1994. X    }
  1995. X
  1996. X
  1997. X#ifdef YY_USE_PROTOS
  1998. XYY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
  1999. X#else
  2000. XYY_BUFFER_STATE yy_create_buffer( file, size )
  2001. XFILE *file;
  2002. Xint size;
  2003. X#endif
  2004. X
  2005. X    {
  2006. X    YY_BUFFER_STATE b;
  2007. X
  2008. X    b = (YY_BUFFER_STATE) malloc( sizeof( struct yy_buffer_state ) );
  2009. X
  2010. X    if ( ! b )
  2011. X    YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  2012. X
  2013. X    b->yy_buf_size = size;
  2014. X
  2015. X    /* yy_ch_buf has to be 2 characters longer than the size given because
  2016. X     * we need to put in 2 end-of-buffer characters.
  2017. X     */
  2018. X    b->yy_ch_buf = (YY_CHAR *) malloc( (unsigned) (b->yy_buf_size + 2) );
  2019. X
  2020. X    if ( ! b->yy_ch_buf )
  2021. X    YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  2022. X
  2023. X    yy_init_buffer( b, file );
  2024. X
  2025. X    return ( b );
  2026. X    }
  2027. X
  2028. X
  2029. X#ifdef YY_USE_PROTOS
  2030. Xvoid yy_delete_buffer( YY_BUFFER_STATE b )
  2031. X#else
  2032. Xvoid yy_delete_buffer( b )
  2033. XYY_BUFFER_STATE b;
  2034. X#endif
  2035. X
  2036. X    {
  2037. X    if ( b == yy_current_buffer )
  2038. X    yy_current_buffer = (YY_BUFFER_STATE) 0;
  2039. X
  2040. X    free( (char *) b->yy_ch_buf );
  2041. X    free( (char *) b );
  2042. X    }
  2043. X
  2044. X
  2045. X#ifdef YY_USE_PROTOS
  2046. Xvoid yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
  2047. X#else
  2048. Xvoid yy_init_buffer( b, file )
  2049. XYY_BUFFER_STATE b;
  2050. XFILE *file;
  2051. X#endif
  2052. X
  2053. X    {
  2054. X    b->yy_input_file = file;
  2055. X
  2056. X    /* we put in the '\n' and start reading from [1] so that an
  2057. X     * initial match-at-newline will be true.
  2058. X     */
  2059. X
  2060. X    b->yy_ch_buf[0] = '\n';
  2061. X    b->yy_n_chars = 1;
  2062. X
  2063. X    /* we always need two end-of-buffer characters.  The first causes
  2064. X     * a transition to the end-of-buffer state.  The second causes
  2065. X     * a jam in that state.
  2066. X     */
  2067. X    b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
  2068. X    b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR;
  2069. X
  2070. X    b->yy_buf_pos = &b->yy_ch_buf[1];
  2071. X
  2072. X    b->yy_eof_status = EOF_NOT_SEEN;
  2073. X    }
  2074. X# line 78 "lexer.l"
  2075. X
  2076. X
  2077. X#ifdef FLEX_SCANNER
  2078. X#undef yywrap
  2079. X#endif
  2080. X#ifdef __STDC__
  2081. Xint yywrap(void)
  2082. X#else
  2083. Xint yywrap()
  2084. X#endif
  2085. X{
  2086. X        return(1);
  2087. X}
  2088. X
  2089. X
  2090. X/* this procedure store comments in the text array commbuf
  2091. X   Escape char are allowed for putting the end-of-comment symbol
  2092. X   in the buffer
  2093. X   */
  2094. X#ifdef __STDC__
  2095. Xstatic char * comment(int closing)
  2096. X#else
  2097. Xstatic char * comment(closing)
  2098. X     char closing;
  2099. X#endif
  2100. X{
  2101. X  register char c;
  2102. X  register int i=0;
  2103. X
  2104. X  while ( ((c = input()) != closing)  && (c != 0) && (c != EOF)) {
  2105. X    commbuf[i] = c;
  2106. X    if (i <LARGE_BUF) i++ ;
  2107. X    
  2108. X    if (c == '\\') {
  2109. X      c = input() ;
  2110. X      if (c == closing)
  2111. X    commbuf[i-1] = c;
  2112. X      else
  2113. X    unput(c);
  2114. X    }
  2115. X  }
  2116. X  commbuf[i] = '\0' ;
  2117. X  return(commbuf);
  2118. X}
  2119. X
  2120. X#ifdef __STDC__
  2121. Xstatic void count(void)
  2122. X#else
  2123. Xstatic void count()
  2124. X#endif
  2125. X{
  2126. X  register int i;
  2127. X  register int k;
  2128. X
  2129. X  for (i = 0; yytext[i] != '\0'; i++) {
  2130. X    if (yytext[i] == '\n') {
  2131. X      column = 0;
  2132. X      for (k = 0 ; k< NCURLINE; k++) /*PANDORE*/
  2133. X        curline[k] = ' '; /*PANDORE*/
  2134. X      lineno++;
  2135. X    }
  2136. X    else if (yytext[i] == '\t') {
  2137. X      column += 8 - (column % 8);
  2138. X      curline[column] = yytext[i];
  2139. X    } else {
  2140. X      column++;
  2141. X      curline[column] = yytext[i];
  2142. X    }
  2143. X    curline[column+1]= '\0' ;
  2144. X  }
  2145. X  /*ECHO;*/
  2146. X}
  2147. END_OF_FILE
  2148.   if test 32987 -ne `wc -c <'lexer.c'`; then
  2149.     echo shar: \"'lexer.c'\" unpacked with wrong size!
  2150.   fi
  2151.   # end of 'lexer.c'
  2152. fi
  2153. if test -f 'notation.hlp' -a "${1}" != "-c" ; then 
  2154.   echo shar: Will not clobber existing file \"'notation.hlp'\"
  2155. else
  2156.   echo shar: Extracting \"'notation.hlp'\" \(1011 characters\)
  2157.   sed "s/^X//" >'notation.hlp' <<'END_OF_FILE'
  2158. XCommand line options: 
  2159. X<inputfile>    : specify the input file. If none, keyboard is assumed
  2160. X-a        : algebraic move notation output
  2161. X-s        : shortened move notation output
  2162. X-f <language>    : specify the chess symbol input language: french,
  2163. X    english, italian, spanish, german, dutch, czech, hungarian, polish,
  2164. X    romanian, FIDE. (for portuguese, use spanish)  
  2165. X-t <language>    : specify the chess symbol output language (same
  2166. Xoptions as input language).
  2167. X-o <outputfile>    : specify the output file. If none, screen is assumed
  2168. X-c <number>[,<number]    : specify the number of the moves to display
  2169. X    the board. if none, board is diplayed at end of file
  2170. X-e <number>     : display the board at the move number and then stops
  2171. X-b        : display only the board, not the moves
  2172. X-d <drivername>    : specify the output driver: ascii,postscript, tex
  2173. X(latex), roff, xchess (xchess save format), gnu (gnuan input format) 
  2174. X-i              : suppress headers/footer in output (useful
  2175. X        for tex/ps drivers)
  2176. X-h        : shows this help
  2177. X-v        : shows version number
  2178. END_OF_FILE
  2179.   if test 1011 -ne `wc -c <'notation.hlp'`; then
  2180.     echo shar: \"'notation.hlp'\" unpacked with wrong size!
  2181.   fi
  2182.   # end of 'notation.hlp'
  2183. fi
  2184. echo shar: End of archive 2 \(of 4\).
  2185. cp /dev/null ark2isdone
  2186. MISSING=""
  2187. for I in 1 2 3 4 ; do
  2188.     if test ! -f ark${I}isdone ; then
  2189.     MISSING="${MISSING} ${I}"
  2190.     fi
  2191. done
  2192. if test "${MISSING}" = "" ; then
  2193.     echo You have unpacked all 4 archives.
  2194.     rm -f ark[1-9]isdone
  2195. else
  2196.     echo You still must unpack the following archives:
  2197.     echo "        " ${MISSING}
  2198. fi
  2199. exit 0
  2200. exit 0 # Just in case...
  2201.