DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T c

⟦215d46457⟧ TextFile

    Length: 66008 (0x101d8)
    Types: TextFile
    Names: »c++2latex.c«

Derivation

└─⟦52210d11f⟧ Bits:30007239 EUUGD2: TeX 3 1992-12
    └─⟦f92554e5b⟧ »utils/C++2LaTeX-1.1-PL5.tar.Z« 
        └─⟦4dcd60fcf⟧ 
            └─⟦this⟧ »C++2LaTeX/c++2latex.c« 

TextFile

/* A lexical scanner generated by flex */

/* scanner skeleton version:
 * $Header: /usr/fsys/odin/a/vern/flex/RCS/flex.skel,v 2.16 90/08/03 14:09:36 vern Exp $
 */

#define FLEX_SCANNER

#include <stdio.h>


/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
#ifdef c_plusplus
#ifndef __cplusplus
#define __cplusplus
#endif
#endif


#ifdef __cplusplus

#include <stdlib.h>
#include <osfcn.h>

/* use prototypes in function declarations */
#define YY_USE_PROTOS

/* the "const" storage-class-modifier is valid */
#define YY_USE_CONST

#else	/* ! __cplusplus */

#ifdef __STDC__

#ifdef __GNUC__
#include <stddef.h>
void *malloc( size_t );
void free( void* );
#else
#include <stdlib.h>
#endif	/* __GNUC__ */

#define YY_USE_PROTOS
#define YY_USE_CONST

#endif	/* __STDC__ */
#endif	/* ! __cplusplus */


#ifdef __TURBOC__
#define YY_USE_CONST
#endif


#ifndef YY_USE_CONST
#define const
#endif


#ifdef YY_USE_PROTOS
#define YY_PROTO(proto) proto
#else
#define YY_PROTO(proto) ()
/* we can't get here if it's an ANSI C compiler, or a C++ compiler,
 * so it's got to be a K&R compiler, and therefore there's no standard
 * place from which to include these definitions
 */
char *malloc();
int free();
int read();
#endif


/* amount of stuff to slurp up with each read */
#ifndef YY_READ_BUF_SIZE
#define YY_READ_BUF_SIZE 8192
#endif

/* returned upon end-of-file */
#define YY_END_TOK 0

/* copy whatever the last rule matched to the standard output */

/* cast to (char *) is because for 8-bit chars, yytext is (unsigned char *) */
/* this used to be an fputs(), but since the string might contain NUL's,
 * we now use fwrite()
 */
#define ECHO (void) fwrite( (char *) yytext, yyleng, 1, yyout )

/* gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
 * is returned in "result".
 */
#define YY_INPUT(buf,result,max_size) \
	if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \
	    YY_FATAL_ERROR( "read() in flex scanner failed" );
#define YY_NULL 0

/* no semi-colon after return; correct usage is to write "yyterminate();" -
 * we don't want an extra ';' after the "return" because that will cause
 * some compilers to complain about unreachable statements.
 */
#define yyterminate() return ( YY_NULL )

/* report a fatal error */

/* The funky do-while is used to turn this macro definition into
 * a single C statement (which needs a semi-colon terminator).
 * This avoids problems with code like:
 *
 * 	if ( something_happens )
 *		YY_FATAL_ERROR( "oops, the something happened" );
 *	else
 *		everything_okay();
 *
 * Prior to using the do-while the compiler would get upset at the
 * "else" because it interpreted the "if" statement as being all
 * done when it reached the ';' after the YY_FATAL_ERROR() call.
 */

#define YY_FATAL_ERROR(msg) \
	do \
		{ \
		(void) fputs( msg, stderr ); \
		(void) putc( '\n', stderr ); \
		exit( 1 ); \
		} \
	while ( 0 )

/* default yywrap function - always treat EOF as an EOF */
#define yywrap() 1

/* enter a start condition.  This macro really ought to take a parameter,
 * but we do it the disgusting crufty way forced on us by the ()-less
 * definition of BEGIN
 */
#define BEGIN yy_start = 1 + 2 *

/* action number for EOF rule of a given start state */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)

/* special action meaning "start processing a new file" */
#define YY_NEW_FILE \
	do \
		{ \
		yy_init_buffer( yy_current_buffer, yyin ); \
		yy_load_buffer_state(); \
		} \
	while ( 0 )

/* default declaration of generated scanner - a define so the user can
 * easily add parameters
 */
#define YY_DECL int yylex YY_PROTO(( void )) 

/* code executed at the end of each rule */
#define YY_BREAK break;

#define YY_END_OF_BUFFER_CHAR 0

#ifndef YY_BUF_SIZE
#define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of default input buffer */
#endif

typedef struct yy_buffer_state *YY_BUFFER_STATE;

#define YY_CHAR char
# line 1 "c++2latex.l"
#define INITIAL 0
/*
 *  This is a flex input file but should be edited in -*-C-*- mode
 *
 *  C++2LaTeX: Produce prettyprinted LaTeX files from  C++ or C sources.
 *  Copyright (C) 1990 Norbert Kiesel
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 1, or (at your option)
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  Norbert Kiesel     
 *  RWTH Aachen / Institut f. Informatik III
 *  Ahornstr. 55
 *  D-5100 Aachen
 *  West Germany  
 *
 *  Phone:  +49 241 80-7266
 *  EUNET:  norbert@rwthi3.uucp
 *  USENET: ...!mcvax!unido!rwthi3!norbert
 *  X.400:  norbert@rwthi3.informatik.rwth-aachen.de
 *
 *  Please contact me for any bugs you find in this code or any
 *  improvements! I'd also be very happy to get feedback where and
 *  how frequently this program is used (just drop a little mail :-).
 */
#define STRING 1
#define BCOMMENT 2
#define INCLUDE 3
#define CPLUSPLUS 4
# line 41 "c++2latex.l"
#define KEY	printf ("{\\%s %s}", keyword_font, yytext)
#define CPP	printf ("{\\%s \\%s}", cpp_font, yytext)
#define SYM(x)	printf ("$\\%s$", x)
#define OUT(x)	printf ("%s", x)
#define SUB(x)	substitute(x)
#define IND	indent(yytext)
#define INIT	BEGIN (cplusplus_mode ? CPLUSPLUS : INITIAL);

#include <stdio.h>

#ifdef ANSI_C
  #ifdef C_PLUSPLUS
    #error ANSI_C and C_PLUSPLUS are mutually exclusive
  #else
    int cplusplus_mode = 0;
  #endif
#else /* CPLUSPLUS or default */
  int cplusplus_mode = 1;
#endif

int complete_file = 0;
int header = 0;
int tabtotab = 8;
int piped = 0;
int want_index = 0;
char * font_size = "11";
char * indentation = "0.5em";
char * comment_font = "it";
char * keyword_font = "bf";
char * header_font = "sl";
char * cpp_font = "tt";
char * string_font = "tt";
void substitute(const char *);
void indent(const char *);
void newpage(int);
void usage(const char *);
# line 79 "c++2latex.l"

/* done after the current pattern has been matched and before the
 * corresponding action - sets up yytext
 */
#define YY_DO_BEFORE_ACTION \
	yytext = yy_bp; \
	yyleng = yy_cp - yy_bp; \
	yy_hold_char = *yy_cp; \
	*yy_cp = '\0'; \
	yy_c_buf_p = yy_cp;

#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2

/* return all but the first 'n' matched characters back to the input stream */
#define yyless(n) \
	do \
		{ \
		/* undo effects of setting up yytext */ \
		*yy_cp = yy_hold_char; \
		yy_c_buf_p = yy_cp = yy_bp + n; \
		YY_DO_BEFORE_ACTION; /* set up yytext again */ \
		} \
	while ( 0 )

#define unput(c) yyunput( c, yytext )


struct yy_buffer_state
    {
    FILE *yy_input_file;

    YY_CHAR *yy_ch_buf;		/* input buffer */
    YY_CHAR *yy_buf_pos;	/* current position in input buffer */

    /* size of input buffer in bytes, not including room for EOB characters*/
    int yy_buf_size;	

    /* number of characters read into yy_ch_buf, not including EOB characters */
    int yy_n_chars;

    int yy_eof_status;		/* whether we've seen an EOF on this buffer */
#define EOF_NOT_SEEN 0
    /* "pending" happens when the EOF has been seen but there's still
     * some text process
     */
#define EOF_PENDING 1
#define EOF_DONE 2
    };

static YY_BUFFER_STATE yy_current_buffer;

/* we provide macros for accessing buffer states in case in the
 * future we want to put the buffer states in a more general
 * "scanner state"
 */
#define YY_CURRENT_BUFFER yy_current_buffer


/* yy_hold_char holds the character lost when yytext is formed */
static YY_CHAR yy_hold_char;

static int yy_n_chars;		/* number of characters read into yy_ch_buf */



#ifndef YY_USER_ACTION
#define YY_USER_ACTION
#endif

#ifndef YY_USER_INIT
#define YY_USER_INIT
#endif

extern YY_CHAR *yytext;
extern int yyleng;
extern FILE *yyin, *yyout;

YY_CHAR *yytext;
int yyleng;

FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;

#define YY_END_OF_BUFFER 143
typedef int yy_state_type;
static const short int yy_accept[553] =
    {   0,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
      143,  142,  139,  141,  140,   98,  119,  142,   89,   88,
      142,  106,  107,   76,  100,   95,   99,   96,   80,  130,
      130,   93,   97,   81,   94,   82,   92,  112,  112,  108,
      142,  109,   77,  112,  112,  112,  112,  112,  112,  112,
      112,  112,  112,  112,  112,  112,  112,  112,   86,   78,
       87,   75,  138,  125,  123,  122,  125,  124,  117,  115,
      117,  116,   17,   15,   16,   17,   17,  111,   99,   96,
       80,   93,  111,  111,  111,  111,  111,  111,  111,  111,
      111,  111,  111,  111,  111,  111,  111,  111,  111,  111,

      111,  111,  139,  140,   67,    0,    0,    0,    0,    0,
        0,    0,   84,   83,   85,    0,    0,   70,  103,  104,
       90,  105,   62,    0,  126,  113,  101,  127,  130,  130,
        0,  130,    0,   63,   65,  102,   66,   64,  112,  119,
        0,  137,   73,  112,  112,  112,  112,  112,  112,   46,
      112,  112,  112,  112,  112,  112,   47,  112,  112,  112,
      112,  112,  112,  112,  112,  112,  112,  112,   74,   68,
      138,  121,  120,  124,  114,  116,   15,    0,   14,    0,
       13,  111,   62,   91,    0,  110,  111,  111,  111,  111,
      111,  111,  111,  111,   46,  111,  111,  111,  111,  111,

      111,  111,   47,  111,  111,  111,  111,  111,  111,  111,
      111,  111,  111,  111,  111,  111,  111,  111,  111,  111,
      111,    0,    0,    0,    0,    5,    0,    0,    0,    0,
      131,    0,  131,    0,    0,   69,    0,  126,  126,    0,
      127,  130,    0,  128,  136,   71,   72,  112,  112,  112,
      112,  112,  112,  112,  112,  112,  112,  112,   39,  112,
       20,  112,  112,  112,  112,  112,  112,  112,  112,  112,
      112,  112,  112,  112,  112,  112,   79,    0,  118,  111,
      111,  111,  111,  111,  111,  111,  111,  111,  111,  111,
      111,  111,   39,  111,  111,  111,   20,  111,   50,  111,

      111,  111,  111,  111,  111,  111,  111,  111,  111,  111,
      111,  111,  111,  111,  111,  111,  111,  111,  111,  111,
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
        0,  132,  133,    0,    0,    0,  128,  126,    0,  129,
      136,   18,  112,   26,   30,  112,  112,  112,  112,   23,
       27,  112,  112,   43,   24,  112,  112,  112,  112,  112,
      112,  112,  112,  112,  112,  112,   41,  112,  112,   18,
      111,   26,   30,  111,  111,  111,  111,  111,  111,   23,
       27,  111,  111,  111,   43,  111,   24,  111,  111,  111,
      111,  111,  111,  111,  111,  111,  111,  111,  111,  111,

       52,  111,  111,  111,  111,   41,  111,  111,    0,    8,
        9,    0,    0,    0,    0,    0,   12,    0,    0,    0,
      134,    0,   22,   34,  112,  112,  112,  112,   35,  112,
      112,   36,  112,  112,  112,  112,  112,  112,   33,  112,
      112,   49,   22,   54,   34,  111,  111,  111,  111,  111,
       35,  111,  111,  111,  111,  111,  111,  111,  111,  111,
       36,  111,  111,  111,  111,  111,  111,   33,  111,  111,
      111,   49,    0,   11,   10,    6,    0,    0,    0,    3,
      112,  112,   19,   31,  112,   32,   40,   44,   48,   21,
       25,  112,  112,  112,  111,  111,   51,   19,   31,   59,

       60,  111,  111,  111,  111,   55,  111,   32,   40,   44,
       48,   21,   25,  111,  111,  111,  111,    2,    7,    0,
        4,  112,   42,  112,   29,  112,  112,  111,   42,  111,
      111,   57,  111,  111,   29,  111,   58,  111,    1,   38,
       28,   37,   45,   38,   53,   61,  111,   28,   37,   45,
       56,    0
    } ;

static const YY_CHAR yy_ec[128] =
    {   0,
        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
        1,    4,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    5,    6,    7,    8,    9,   10,   11,   12,   13,
       14,   15,   16,   17,   18,   19,   20,   21,   22,   22,
       22,   22,   22,   22,   22,   23,   23,   24,   25,   26,
       27,   28,   29,   30,   31,   31,   31,   31,   32,   33,
       34,   34,   34,   34,   34,   35,   34,   34,   34,   34,
       34,   34,   34,   34,   36,   34,   34,   34,   34,   34,
       37,   38,   39,   40,   34,   30,   41,   42,   43,   44,

       45,   46,   47,   48,   49,   34,   50,   51,   52,   53,
       54,   55,   34,   56,   57,   58,   59,   60,   61,   62,
       63,   64,   65,   66,   67,   68,    1
    } ;

static const YY_CHAR yy_meta[69] =
    {   0,
        1,    1,    1,    1,    2,    2,    3,    2,    4,    2,
        2,    5,    2,    2,    2,    2,    2,    2,    2,    2,
        6,    6,    7,    2,    2,    2,    2,    2,    3,    2,
        7,    7,    7,    8,    8,    8,    2,    3,    2,    2,
        6,    6,    7,    7,    7,    6,    8,    8,    8,    8,
        8,    8,    9,    8,    8,    9,    8,    9,    8,    9,
        8,    9,    8,    8,    2,    2,    2,    2
    } ;

static const short int yy_base[567] =
    {   0,
        0,   67,   67,   73,   68,   79,   83,   90,  116,   94,
     1036, 1037,   96, 1037, 1032, 1007, 1037,  183, 1006,   62,
      994, 1037, 1037, 1004,   75, 1037,   85,   85,  171,  224,
      170, 1037, 1037,   88, 1003,  167, 1037,    0,  189, 1037,
     1026, 1037, 1001,  968,  970,  149,  154,  156,  159,  971,
      158,  970,  978,  175,  959,  968,  966,  971, 1037,  160,
     1037, 1037,  212, 1037, 1037, 1037,  232,  214, 1037, 1037,
      998,  220, 1037,  235, 1037, 1010,  988,    0,  223,  242,
      252,  991, 1005,  246,  203,  221,  243,  226,  245,  257,
      222,  259,  239,  264,  240,  272,  273,  278,  290,  280,

      292,  294,  312, 1037, 1037,  314,  968,  269,  277,  963,
      955,  957, 1037, 1037, 1037,  997,  322, 1037, 1037, 1037,
     1037, 1037, 1037,  989,  329, 1037, 1037,  355,  360,  391,
      381, 1037,    0,  980, 1037, 1037, 1037,  979,    0, 1037,
      967, 1037, 1037,  946,  958,  945,  960,  947,  953,  939,
      940,  937,  937,  940,  937,  934,    0,  933,  937,  257,
      935,  285,  265,  939,  932,   30,  286,  937, 1037, 1037,
      343, 1037, 1037,  352, 1037,  365,  366,  978, 1037,  956,
     1037,    0,  968, 1037,  979, 1037,  972,  331,  315,  363,
      357,  376,  338,  384,  385,  377,  398,  400,  301,  399,

      407,  406,  971,  409,  412,  413,  416,  423,  422,   68,
      415,  424,  419,  428,  430,  431,  420,  432,  429,  437,
      438,  933,  394,  934,  921,  401,  933,  922,  933,  929,
     1037,  960,  959,  470,    0, 1037,  477, 1037,  480,  488,
     1037, 1037,  495,  498,  487, 1037, 1037,  916,  928,  923,
      911,  391,  925,  923,  919,  911,  917,  920,    0,  906,
        0,  912,  909,  898,  900,  902,  909,  895,  893,  893,
      905,  895,  899,  903,  905,  894, 1037,  941, 1037,  443,
      487,  463,  468,  450,  485,  496,  505,  518,  520,  481,
      521,  523,  934,  525,  526,  527,  933,  530,  932,  531,

      532,  535,  536,  538,  542,  539,  540,  544,  545,  543,
      546,  548,  547,  554,  549,  553,  550,  563,  552,  558,
      891,  893,  893,  888,  882,  890,  890,  882,  887,  884,
      885, 1037, 1037,  557,  917,  552,  560, 1037,  563,  589,
     1037,    0,  878,    0,    0,  869,  877,  866,  873,    0,
        0,  867,  864,    0,    0,  864,  864,  861,  873,  863,
      867,  872,  871,  869,  859,  864,    0,  852,  864,  899,
      583,  898,  897,  559,  562,  591,  604,  606,  605,  896,
      895,  609,  608,  614,  894,  615,  893,  610,  618,  612,
      613,  621,  616,  619,  620,  617,  622,  623,  628,  634,

      892,  630,  626,  633,  625,  891,  627,  636,  846, 1037,
     1037,  852,  841,  850,  850,  835, 1037,  841,  846,  879,
     1037,  878,    0,    0,  836,  837,  842,  833,    0,  827,
      831,    0,  839,  836,  838,  822,  831,  833,    0,  824,
      827,    0,  866,  865,  864,  629,  632,  641,  643,  637,
      863,  645,  646,  635,  638,  639,  651,  652,  640,  648,
      862,  678,  650,  690,  691,  693,  694,  861,  695,  696,
      697,  860,  823, 1037, 1037, 1037,  821,  822,  824, 1037,
      805,  805,    0,    0,  817,    0,    0,    0,    0,    0,
        0,  815,  815,  791,  698,  700,  832,  829,  823,  817,

      742,  699,  701,  702,  703,  736,  705,  735,  734,  731,
      729,  727,  726,  706,  709,  704,  708, 1037, 1037,  689,
     1037,  687,    0,  672,    0,  683,  679,  711,  714,  707,
      716,  712,  717,  710,  461,  720,  454,  722, 1037,    0,
        0,    0,    0,  444,  347,  320,  721,  293,  211,  191,
       91, 1037,  767,  776,  785,  793,  797,  806,  815,  821,
      827,  834,  838,  845,  849,  852
    } ;

static const short int yy_def[567] =
    {   0,
      552,    1,  553,  553,  554,  554,  555,  555,  552,    9,
      552,  552,  552,  552,  552,  552,  552,  552,  552,  552,
      556,  552,  552,  552,  552,  552,  552,  552,  552,  552,
      552,  552,  552,  552,  552,  552,  552,  557,  557,  552,
      552,  552,  552,  557,  557,  557,  557,  557,  557,  557,
      557,  557,  557,  557,  557,  557,  557,  557,  552,  552,
      552,  552,  552,  552,  552,  552,  552,  552,  552,  552,
      552,  552,  552,  552,  552,  558,  559,  560,  552,  552,
      552,  552,  561,  561,  561,  561,  561,  561,  561,  561,
      561,  561,  561,  561,  561,  561,  561,  561,  561,  561,

      561,  561,  552,  552,  552,  552,  552,  552,  552,  552,
      552,  552,  552,  552,  552,  552,  562,  552,  552,  552,
      552,  552,  552,  552,  552,  552,  552,  552,  552,  552,
      552,  552,  563,  552,  552,  552,  552,  552,  557,  552,
      556,  552,  552,  557,  557,  557,  557,  557,  557,  557,
      557,  557,  557,  557,  557,  557,  557,  557,  557,  557,
      557,  557,  557,  557,  557,  557,  557,  557,  552,  552,
      552,  552,  552,  552,  552,  552,  552,  558,  552,  559,
      552,  560,  552,  552,  564,  552,  561,  561,  561,  561,
      561,  561,  561,  561,  561,  561,  561,  561,  561,  561,

      561,  561,  561,  561,  561,  561,  561,  561,  561,  561,
      561,  561,  561,  561,  561,  561,  561,  561,  561,  561,
      561,  552,  552,  552,  552,  552,  552,  552,  552,  552,
      552,  552,  552,  552,  565,  552,  552,  552,  552,  552,
      552,  552,  552,  552,  563,  552,  552,  557,  557,  557,
      557,  557,  557,  557,  557,  557,  557,  557,  557,  557,
      557,  557,  557,  557,  557,  557,  557,  557,  557,  557,
      557,  557,  557,  557,  557,  557,  552,  564,  552,  561,
      561,  561,  561,  561,  561,  561,  561,  561,  561,  561,
      561,  561,  561,  561,  561,  561,  561,  561,  561,  561,

      561,  561,  561,  561,  561,  561,  561,  561,  561,  561,
      561,  561,  561,  561,  561,  561,  561,  561,  561,  561,
      552,  552,  552,  552,  552,  552,  552,  552,  552,  552,
      552,  552,  552,  552,  566,  552,  552,  552,  552,  552,
      552,  557,  557,  557,  557,  557,  557,  557,  557,  557,
      557,  557,  557,  557,  557,  557,  557,  557,  557,  557,
      557,  557,  557,  557,  557,  557,  557,  557,  557,  561,
      561,  561,  561,  561,  561,  561,  561,  561,  561,  561,
      561,  561,  561,  561,  561,  561,  561,  561,  561,  561,
      561,  561,  561,  561,  561,  561,  561,  561,  561,  561,

      561,  561,  561,  561,  561,  561,  561,  561,  552,  552,
      552,  552,  552,  552,  552,  552,  552,  552,  552,  552,
      552,  552,  557,  557,  557,  557,  557,  557,  557,  557,
      557,  557,  557,  557,  557,  557,  557,  557,  557,  557,
      557,  557,  561,  561,  561,  561,  561,  561,  561,  561,
      561,  561,  561,  561,  561,  561,  561,  561,  561,  561,
      561,  561,  561,  561,  561,  561,  561,  561,  561,  561,
      561,  561,  552,  552,  552,  552,  552,  552,  552,  552,
      557,  557,  557,  557,  557,  557,  557,  557,  557,  557,
      557,  557,  557,  557,  561,  561,  561,  561,  561,  561,

      561,  561,  561,  561,  561,  561,  561,  561,  561,  561,
      561,  561,  561,  561,  561,  561,  561,  552,  552,  552,
      552,  557,  557,  557,  557,  557,  557,  561,  561,  561,
      561,  561,  561,  561,  561,  561,  561,  561,  552,  557,
      557,  557,  557,  561,  561,  561,  561,  561,  561,  561,
      561,    0,  552,  552,  552,  552,  552,  552,  552,  552,
      552,  552,  552,  552,  552,  552
    } ;

static const short int yy_nxt[1106] =
    {   0,
       12,   13,   14,   15,   13,   16,   17,   18,   12,   19,
       20,   21,   22,   23,   24,   25,   26,   27,   28,   29,
       30,   31,   31,   32,   33,   34,   35,   36,   37,   12,
       38,   38,   38,   38,   39,   38,   40,   41,   42,   43,
       44,   45,   46,   47,   48,   49,   50,   38,   51,   38,
       52,   38,   38,   38,   38,   53,   54,   55,   56,   57,
       58,   38,   38,   38,   59,   60,   61,   62,   63,   65,
       70,   63,  114,   66,   68,   65,  182,   68,  272,   66,
       72,   70,   71,   72,   74,   75,  273,   74,  115,   76,
      119,   74,   75,   71,   74,   63,   76,  103,   63,  182,

      103,  120,  121,  124,   67,  125,  125,  125,   77,  304,
       67,  122,  123,  134,  135,   77,   12,   13,   14,   15,
       13,   16,   17,   18,   78,   19,   20,   21,   22,   23,
       24,   25,   26,   79,   80,   81,   30,   31,   31,   82,
       33,   34,   35,   36,   37,   12,   83,   83,   83,   83,
       84,   83,   40,   41,   42,   43,   85,   86,   87,   88,
       89,   90,   91,   83,   92,   83,   93,   83,   94,   95,
       96,   97,   98,   99,  100,  101,  102,   83,   83,   83,
       59,   60,   61,   62,  106,  126,  169,  106,  128,  146,
      130,  130,  130,  137,  138,  140,  147,  127,  149,  182,

      141,  131,  148,  157,  132,  132,  151,  150,  152,  154,
      158,  182,  155,  171,  131,  174,  171,  153,  174,  182,
      132,  176,  161,  162,  176,  170,  107,  108,  132,  182,
      182,  109,  163,  110,  182,  164,  177,  111,  172,  177,
      121,  112,  128,  172,  129,  129,  130,  182,  182,  122,
      183,  182,  140,  182,  182,  131,  184,  141,  132,  132,
      124,  188,  125,  125,  125,  182,  126,  182,  131,  173,
      194,  185,  182,  172,  132,  202,  189,  172,  127,  195,
      182,  182,  132,  190,  172,  133,  182,  172,  182,  172,
      191,  172,  205,  192,  207,  196,  193,  197,  182,  208,

      182,  182,  182,  263,  203,  268,  198,  199,  206,  182,
      200,  204,  201,  103,  264,  106,  103,  211,  106,  223,
      269,  224,  226,  182,  225,  212,  213,  209,  182,  227,
      210,  266,  218,  233,  274,  214,  275,  216,  215,  182,
      219,  221,  234,  234,  171,  220,  182,  171,  267,  125,
      125,  125,  217,  174,  292,  182,  174,  107,  108,  281,
      237,  238,  109,  238,  110,  182,  176,  177,  111,  176,
      177,  182,  112,  237,  238,  239,  239,  239,  128,  238,
      129,  129,  130,  235,  182,  182,  240,  241,  280,  241,
      285,  131,  182,  182,  242,  242,  243,  283,  243,  240,

      241,  244,  244,  244,  131,  241,  182,  182,  182,  128,
      242,  130,  130,  130,  182,  182,  284,  182,  242,  282,
      182,  182,  131,  182,  182,  132,  132,  182,  182,  286,
      182,  182,  182,  289,  287,  131,  182,  182,  182,  182,
      182,  132,  322,  288,  326,  182,  182,  346,  347,  132,
      323,  182,  182,  327,  293,  294,  290,  291,  182,  296,
      300,  305,  182,  295,  298,  308,  297,  301,  310,  182,
      302,  182,  306,  299,  314,  303,  182,  307,  312,  313,
      315,  333,  309,  311,  317,  318,  320,  319,  316,  182,
      334,  334,  336,  182,  336,  182,  370,  337,  337,  337,

      239,  239,  239,  339,  182,  339,  374,  372,  340,  340,
      340,  131,  338,  182,  338,  244,  244,  244,  244,  244,
      244,  341,  341,  373,  131,  338,  182,  371,  182,  182,
      338,  182,  381,  182,  182,  182,  377,  341,  182,  182,
      182,  375,  376,  182,  182,  341,  182,  182,  182,  378,
      182,  182,  182,  182,  182,  182,  182,  182,  182,  379,
      182,  182,  182,  383,  380,  382,  182,  182,  333,  384,
      182,  182,  337,  337,  337,  386,  387,  420,  420,  385,
      337,  337,  337,  340,  340,  340,  388,  389,  392,  397,
      393,  182,  407,  391,  390,  395,  396,  394,  402,  182,

      398,  404,  403,  401,  399,  400,  406,  405,  408,  340,
      340,  340,  182,  182,  182,  444,  182,  182,  182,  445,
      182,  182,  182,  182,  182,  182,  182,  182,  182,  182,
      182,  182,  443,  182,  182,  182,  182,  182,  182,  446,
      182,  182,  182,  182,  182,  182,  182,  182,  182,  182,
      454,  182,  456,  182,  182,  449,  182,  457,  182,  182,
      182,  462,  447,  448,  450,  451,  452,  453,  455,  458,
      465,  464,  459,  467,  460,  463,  466,  461,  468,  469,
      472,  495,  496,  470,  471,  497,  182,  498,  500,  499,
      501,  503,  502,  505,  506,  510,  504,  507,  182,  182,

      508,  182,  182,  182,  182,  182,  182,  182,  182,  182,
      182,  182,  182,  182,  182,  182,  182,  182,  182,  182,
      182,  509,  182,  543,  182,  182,  542,  541,  182,  182,
      182,  540,  511,  539,  182,  182,  516,  182,  514,  182,
      513,  531,  182,  182,  182,  517,  532,  515,  512,  534,
      182,  535,  530,  536,  537,  544,  528,  529,  538,  546,
      533,  547,  545,  549,  551,  548,  550,   64,   64,   64,
       64,   64,   64,   64,   64,   64,   69,   69,   69,   69,
       69,   69,   69,   69,   69,   73,   73,   73,   73,   73,
       73,   73,   73,   73,  116,  116,  116,  116,  116,  116,

      116,  116,  139,  139,  139,  139,  178,  178,  178,  178,
      178,  178,  178,  178,  178,  180,  180,  180,  180,  180,
      180,  180,  180,  180,  182,  182,  182,  182,  182,  182,
      187,  182,  187,  187,  187,  187,  232,  182,  232,  232,
      182,  527,  232,  245,  245,  278,  278,  278,  278,  278,
      278,  278,  278,  278,  335,  335,  422,  422,  422,  526,
      525,  524,  523,  522,  521,  520,  519,  518,  182,  182,
      182,  182,  182,  182,  182,  494,  493,  492,  491,  490,
      489,  488,  487,  486,  485,  484,  483,  482,  481,  421,
      333,  480,  479,  478,  477,  476,  475,  474,  473,  182,

      182,  182,  182,  182,  182,  182,  182,  182,  442,  441,
      440,  439,  438,  437,  436,  435,  434,  433,  432,  431,
      430,  429,  428,  427,  426,  425,  424,  423,  421,  419,
      418,  417,  416,  415,  414,  413,  412,  411,  410,  409,
      182,  182,  182,  279,  369,  368,  367,  366,  365,  364,
      363,  362,  361,  360,  359,  358,  357,  356,  355,  354,
      353,  352,  351,  350,  349,  348,  345,  344,  343,  342,
      332,  332,  331,  330,  329,  328,  325,  324,  321,  182,
      182,  279,  277,  181,  179,  276,  271,  270,  265,  262,
      261,  260,  259,  258,  257,  256,  255,  254,  253,  252,

      251,  250,  249,  248,  117,  247,  246,  236,  231,  230,
      229,  228,  222,  182,  186,  181,  179,  175,  168,  167,
      166,  165,  160,  159,  156,  145,  144,  143,  142,  136,
      118,  117,  113,  105,  104,  552,   11,  552,  552,  552,
      552,  552,  552,  552,  552,  552,  552,  552,  552,  552,
      552,  552,  552,  552,  552,  552,  552,  552,  552,  552,
      552,  552,  552,  552,  552,  552,  552,  552,  552,  552,
      552,  552,  552,  552,  552,  552,  552,  552,  552,  552,
      552,  552,  552,  552,  552,  552,  552,  552,  552,  552,
      552,  552,  552,  552,  552,  552,  552,  552,  552,  552,

      552,  552,  552,  552,  552
    } ;

static const short int yy_chk[1106] =
    {   0,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
        5,    2,   20,    3,    4,    4,  210,    4,  166,    4,
        6,    6,    5,    6,    7,    7,  166,    7,   20,    7,
       25,    8,    8,    6,    8,   10,    8,   13,   10,  551,

       13,   25,   27,   28,    3,   28,   28,   28,    7,  210,
        4,   27,   27,   34,   34,    8,    9,    9,    9,    9,
        9,    9,    9,    9,    9,    9,    9,    9,    9,    9,
        9,    9,    9,    9,    9,    9,    9,    9,    9,    9,
        9,    9,    9,    9,    9,    9,    9,    9,    9,    9,
        9,    9,    9,    9,    9,    9,    9,    9,    9,    9,
        9,    9,    9,    9,    9,    9,    9,    9,    9,    9,
        9,    9,    9,    9,    9,    9,    9,    9,    9,    9,
        9,    9,    9,    9,   18,   29,   60,   18,   31,   46,
       31,   31,   31,   36,   36,   39,   46,   29,   47,  550,

       39,   31,   46,   51,   31,   31,   48,   47,   48,   49,
       51,   85,   49,   63,   31,   68,   63,   48,   68,  549,
       31,   72,   54,   54,   72,   60,   18,   18,   31,   86,
       91,   18,   54,   18,   88,   54,   74,   18,   67,   74,
       79,   18,   30,   67,   30,   30,   30,   93,   95,   79,
       79,   87,   84,   89,   84,   30,   80,   84,   30,   30,
       80,   85,   80,   80,   80,   90,   81,   92,   30,   67,
       88,   81,   94,   67,   30,   91,   86,   67,   81,   88,
       96,   97,   30,   87,   67,   30,   98,   67,  100,   67,
       87,   67,   93,   87,   95,   89,   87,   89,   99,   95,

      101,  548,  102,  160,   92,  163,   89,   90,   94,  199,
       90,   92,   90,  103,  160,  106,  103,   97,  106,  108,
      163,  108,  109,  189,  108,   98,   98,   96,  546,  109,
       96,  162,  100,  117,  167,   98,  167,   99,   98,  188,
      101,  102,  117,  117,  171,  101,  193,  171,  162,  125,
      125,  125,   99,  174,  199,  545,  174,  106,  106,  189,
      125,  125,  106,  125,  106,  191,  176,  177,  106,  176,
      177,  190,  106,  125,  125,  128,  128,  128,  129,  125,
      129,  129,  129,  117,  192,  196,  128,  128,  188,  128,
      193,  129,  194,  195,  129,  129,  131,  191,  131,  128,

      128,  131,  131,  131,  129,  128,  197,  200,  198,  130,
      129,  130,  130,  130,  202,  201,  192,  204,  129,  190,
      205,  206,  130,  211,  207,  130,  130,  213,  217,  194,
      209,  208,  212,  196,  194,  130,  214,  219,  215,  216,
      218,  130,  223,  195,  226,  220,  221,  252,  252,  130,
      223,  280,  544,  226,  200,  201,  197,  198,  284,  204,
      207,  211,  537,  202,  205,  213,  204,  208,  214,  535,
      209,  282,  211,  206,  217,  209,  283,  212,  215,  216,
      218,  234,  213,  214,  219,  220,  221,  220,  218,  290,
      234,  234,  237,  285,  237,  281,  280,  237,  237,  237,

      239,  239,  239,  240,  286,  240,  284,  282,  240,  240,
      240,  239,  239,  287,  239,  243,  243,  243,  244,  244,
      244,  245,  245,  283,  239,  239,  288,  281,  289,  291,
      239,  292,  290,  294,  295,  296,  286,  245,  298,  300,
      301,  285,  285,  302,  303,  245,  304,  306,  307,  287,
      305,  310,  308,  309,  311,  313,  312,  315,  317,  288,
      319,  316,  314,  292,  289,  291,  320,  374,  334,  294,
      375,  318,  336,  336,  336,  296,  298,  334,  334,  295,
      337,  337,  337,  339,  339,  339,  300,  301,  304,  309,
      305,  371,  319,  303,  302,  307,  308,  306,  314,  376,

      310,  316,  315,  313,  311,  312,  318,  317,  320,  340,
      340,  340,  377,  379,  378,  374,  383,  382,  388,  375,
      390,  391,  384,  386,  393,  396,  389,  394,  395,  392,
      397,  398,  371,  405,  403,  407,  399,  446,  402,  376,
      447,  404,  400,  454,  408,  450,  455,  456,  459,  448,
      388,  449,  390,  452,  453,  379,  460,  391,  463,  457,
      458,  396,  377,  378,  382,  383,  384,  386,  389,  392,
      399,  398,  393,  402,  394,  397,  400,  395,  403,  404,
      408,  446,  447,  405,  407,  448,  462,  449,  452,  450,
      453,  455,  454,  457,  458,  463,  456,  459,  464,  465,

      460,  466,  467,  469,  470,  471,  495,  502,  496,  503,
      504,  505,  516,  507,  514,  530,  517,  515,  534,  528,
      532,  462,  529,  527,  531,  533,  526,  524,  536,  547,
      538,  522,  464,  520,  513,  512,  470,  511,  467,  510,
      466,  503,  509,  508,  506,  471,  504,  469,  465,  507,
      501,  514,  502,  515,  516,  528,  495,  496,  517,  531,
      505,  533,  530,  536,  547,  534,  538,  553,  553,  553,
      553,  553,  553,  553,  553,  553,  554,  554,  554,  554,
      554,  554,  554,  554,  554,  555,  555,  555,  555,  555,
      555,  555,  555,  555,  556,  556,  556,  556,  556,  556,

      556,  556,  557,  557,  557,  557,  558,  558,  558,  558,
      558,  558,  558,  558,  558,  559,  559,  559,  559,  559,
      559,  559,  559,  559,  560,  500,  560,  560,  560,  560,
      561,  499,  561,  561,  561,  561,  562,  498,  562,  562,
      497,  494,  562,  563,  563,  564,  564,  564,  564,  564,
      564,  564,  564,  564,  565,  565,  566,  566,  566,  493,
      492,  485,  482,  481,  479,  478,  477,  473,  472,  468,
      461,  451,  445,  444,  443,  441,  440,  438,  437,  436,
      435,  434,  433,  431,  430,  428,  427,  426,  425,  422,
      420,  419,  418,  416,  415,  414,  413,  412,  409,  406,

      401,  387,  385,  381,  380,  373,  372,  370,  369,  368,
      366,  365,  364,  363,  362,  361,  360,  359,  358,  357,
      356,  353,  352,  349,  348,  347,  346,  343,  335,  331,
      330,  329,  328,  327,  326,  325,  324,  323,  322,  321,
      299,  297,  293,  278,  276,  275,  274,  273,  272,  271,
      270,  269,  268,  267,  266,  265,  264,  263,  262,  260,
      258,  257,  256,  255,  254,  253,  251,  250,  249,  248,
      233,  232,  230,  229,  228,  227,  225,  224,  222,  203,
      187,  185,  183,  180,  178,  168,  165,  164,  161,  159,
      158,  156,  155,  154,  153,  152,  151,  150,  149,  148,

      147,  146,  145,  144,  141,  138,  134,  124,  116,  112,
      111,  110,  107,   83,   82,   77,   76,   71,   58,   57,
       56,   55,   53,   52,   50,   45,   44,   43,   41,   35,
       24,   21,   19,   16,   15,   11,  552,  552,  552,  552,
      552,  552,  552,  552,  552,  552,  552,  552,  552,  552,
      552,  552,  552,  552,  552,  552,  552,  552,  552,  552,
      552,  552,  552,  552,  552,  552,  552,  552,  552,  552,
      552,  552,  552,  552,  552,  552,  552,  552,  552,  552,
      552,  552,  552,  552,  552,  552,  552,  552,  552,  552,
      552,  552,  552,  552,  552,  552,  552,  552,  552,  552,

      552,  552,  552,  552,  552
    } ;

static yy_state_type yy_last_accepting_state;
static YY_CHAR *yy_last_accepting_cpos;

/* the intent behind this definition is that it'll catch
 * any uses of REJECT which flex missed
 */
#define REJECT reject_used_but_not_detected
#define yymore() yymore_used_but_not_detected
#define YY_MORE_ADJ 0

/* these variables are all declared out here so that section 3 code can
 * manipulate them
 */
/* points to current character in buffer */
static YY_CHAR *yy_c_buf_p = (YY_CHAR *) 0;
static int yy_init = 1;		/* whether we need to initialize */
static int yy_start = 0;	/* start state number */

/* flag which is used to allow yywrap()'s to do buffer switches
 * instead of setting up a fresh yyin.  A bit of a hack ...
 */
static int yy_did_buffer_switch_on_eof;

static yy_state_type yy_get_previous_state YY_PROTO(( void ));
static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
static int yy_get_next_buffer YY_PROTO(( void ));
static void yyunput YY_PROTO(( YY_CHAR c, YY_CHAR *buf_ptr ));
void yyrestart YY_PROTO(( FILE *input_file ));
void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
void yy_load_buffer_state YY_PROTO(( void ));
YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));

#define yy_new_buffer yy_create_buffer

#ifdef __cplusplus
static int yyinput YY_PROTO(( void ));
#else
static int input YY_PROTO(( void ));
#endif

YY_DECL
    {
    register yy_state_type yy_current_state;
    register YY_CHAR *yy_cp, *yy_bp;
    register int yy_act;



	INIT;


    if ( yy_init )
	{
	YY_USER_INIT;

	if ( ! yy_start )
	    yy_start = 1;	/* first start state */

	if ( ! yyin )
	    yyin = stdin;

	if ( ! yyout )
	    yyout = stdout;

	if ( yy_current_buffer )
	    yy_init_buffer( yy_current_buffer, yyin );
	else
	    yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );

	yy_load_buffer_state();

	yy_init = 0;
	}

    while ( 1 )		/* loops until end-of-file is reached */
	{
	yy_cp = yy_c_buf_p;

	/* support of yytext */
	*yy_cp = yy_hold_char;

	/* yy_bp points to the position in yy_ch_buf of the start of the
	 * current run.
	 */
	yy_bp = yy_cp;

	yy_current_state = yy_start;
	if ( yy_bp[-1] == '\n' )
	    ++yy_current_state;
yy_match:
	do
	    {
	    register YY_CHAR yy_c = yy_ec[*yy_cp];
	    if ( yy_accept[yy_current_state] )
		{
		yy_last_accepting_state = yy_current_state;
		yy_last_accepting_cpos = yy_cp;
		}
	    while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
		{
		yy_current_state = yy_def[yy_current_state];
		if ( yy_current_state >= 553 )
		    yy_c = yy_meta[yy_c];
		}
	    yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
	    ++yy_cp;
	    }
	while ( yy_current_state != 552 );
	yy_cp = yy_last_accepting_cpos;
	yy_current_state = yy_last_accepting_state;

yy_find_action:
	yy_act = yy_accept[yy_current_state];

	YY_DO_BEFORE_ACTION;
	YY_USER_ACTION;

do_action:	/* this label is used only to access EOF actions */


	switch ( yy_act )
	    {
	    case 0: /* must backtrack */
	    /* undo the effects of YY_DO_BEFORE_ACTION */
	    *yy_cp = yy_hold_char;
	    yy_cp = yy_last_accepting_cpos;
	    yy_current_state = yy_last_accepting_state;
	    goto yy_find_action;

case 1:
# line 83 "c++2latex.l"
{ CPP; BEGIN (INCLUDE); }
	YY_BREAK
case 2:
# line 85 "c++2latex.l"
case 3:
# line 86 "c++2latex.l"
case 4:
# line 87 "c++2latex.l"
case 5:
# line 88 "c++2latex.l"
case 6:
# line 89 "c++2latex.l"
case 7:
# line 90 "c++2latex.l"
case 8:
# line 91 "c++2latex.l"
case 9:
# line 92 "c++2latex.l"
case 10:
# line 93 "c++2latex.l"
case 11:
# line 94 "c++2latex.l"
case 12:
# line 94 "c++2latex.l"
CPP;
	YY_BREAK
case 13:
*yy_cp = yy_hold_char; /* undo effects of setting up yytext */
yy_c_buf_p = yy_cp -= 1;
YY_DO_BEFORE_ACTION; /* set up yytext again */
# line 97 "c++2latex.l"
{ OUT ("$<${\\"); OUT (string_font);
			  OUT ("{}"); SUB (yytext+1); OUT ("}$>$");
			  if (want_index) {
                            OUT ("\\index{"); SUB(yytext+1); OUT ("}"); }
			  input(); INIT; }
	YY_BREAK
case 14:
*yy_cp = yy_hold_char; /* undo effects of setting up yytext */
yy_c_buf_p = yy_cp -= 1;
YY_DO_BEFORE_ACTION; /* set up yytext again */
# line 102 "c++2latex.l"
{ OUT ("\"{\\"); OUT (string_font);
			  OUT ("{}"); SUB (yytext+1); OUT ("}\"");
			  if (want_index) {
                            OUT ("\\index{"); SUB(yytext+1); OUT ("}"); }
			  input(); INIT; }
	YY_BREAK
case 15:
# line 107 "c++2latex.l"
ECHO;
	YY_BREAK
case 16:
# line 108 "c++2latex.l"
OUT ("\\mbox{}\\\\\n");
	YY_BREAK
case 17:
# line 109 "c++2latex.l"
{ yyless (0); INIT; }
	YY_BREAK
case 18:
# line 112 "c++2latex.l"
case 19:
# line 113 "c++2latex.l"
case 20:
# line 114 "c++2latex.l"
case 21:
# line 115 "c++2latex.l"
case 22:
# line 116 "c++2latex.l"
case 23:
# line 117 "c++2latex.l"
case 24:
# line 118 "c++2latex.l"
case 25:
# line 119 "c++2latex.l"
case 26:
# line 120 "c++2latex.l"
case 27:
# line 121 "c++2latex.l"
case 28:
# line 122 "c++2latex.l"
case 29:
# line 123 "c++2latex.l"
case 30:
# line 124 "c++2latex.l"
case 31:
# line 125 "c++2latex.l"
case 32:
# line 126 "c++2latex.l"
case 33:
# line 127 "c++2latex.l"
case 34:
# line 128 "c++2latex.l"
case 35:
# line 129 "c++2latex.l"
case 36:
# line 130 "c++2latex.l"
case 37:
# line 131 "c++2latex.l"
case 38:
# line 132 "c++2latex.l"
case 39:
# line 133 "c++2latex.l"
case 40:
# line 134 "c++2latex.l"
case 41:
# line 135 "c++2latex.l"
case 42:
# line 136 "c++2latex.l"
case 43:
# line 137 "c++2latex.l"
case 44:
# line 138 "c++2latex.l"
case 45:
# line 139 "c++2latex.l"
case 46:
# line 140 "c++2latex.l"
case 47:
# line 141 "c++2latex.l"
case 48:
# line 142 "c++2latex.l"
case 49:
# line 143 "c++2latex.l"
case 50:
# line 144 "c++2latex.l"
case 51:
# line 145 "c++2latex.l"
case 52:
# line 146 "c++2latex.l"
case 53:
# line 147 "c++2latex.l"
case 54:
# line 148 "c++2latex.l"
case 55:
# line 149 "c++2latex.l"
case 56:
# line 150 "c++2latex.l"
case 57:
# line 151 "c++2latex.l"
case 58:
# line 152 "c++2latex.l"
case 59:
# line 153 "c++2latex.l"
case 60:
# line 154 "c++2latex.l"
case 61:
# line 154 "c++2latex.l"
KEY;
	YY_BREAK
case 62:
# line 155 "c++2latex.l"
SYM ("rightarrow");
	YY_BREAK
case 63:
# line 156 "c++2latex.l"
SYM ("ll");
	YY_BREAK
case 64:
# line 157 "c++2latex.l"
SYM ("gg");
	YY_BREAK
case 65:
# line 158 "c++2latex.l"
SYM ("leq");
	YY_BREAK
case 66:
# line 159 "c++2latex.l"
SYM ("geq");
	YY_BREAK
case 67:
# line 160 "c++2latex.l"
SYM ("neq");
	YY_BREAK
case 68:
# line 161 "c++2latex.l"
SYM ("mid\\mid");
	YY_BREAK
case 69:
# line 162 "c++2latex.l"
SYM ("ldots");
	YY_BREAK
case 70:
# line 163 "c++2latex.l"
SYM ("ast=");
	YY_BREAK
case 71:
# line 164 "c++2latex.l"
SYM ("ll=");
	YY_BREAK
case 72:
# line 165 "c++2latex.l"
SYM ("gg=");
	YY_BREAK
case 73:
# line 166 "c++2latex.l"
SYM ("vee=");
	YY_BREAK
case 74:
# line 167 "c++2latex.l"
SYM ("mid=");
	YY_BREAK
case 75:
# line 168 "c++2latex.l"
SYM ("sim");
	YY_BREAK
case 76:
# line 169 "c++2latex.l"
SYM ("ast");
	YY_BREAK
case 77:
# line 170 "c++2latex.l"
SYM ("wedge");
	YY_BREAK
case 78:
# line 171 "c++2latex.l"
SYM ("mid");
	YY_BREAK
case 79:
# line 172 "c++2latex.l"
SYM ("rightarrow\\ast");
	YY_BREAK
case 80:
# line 173 "c++2latex.l"
OUT ("$/$");
	YY_BREAK
case 81:
# line 174 "c++2latex.l"
OUT ("$<$");
	YY_BREAK
case 82:
# line 175 "c++2latex.l"
OUT ("$>$");
	YY_BREAK
case 83:
# line 176 "c++2latex.l"
OUT ("\\&\\&");
	YY_BREAK
case 84:
# line 177 "c++2latex.l"
OUT ("\\%=");
	YY_BREAK
case 85:
# line 178 "c++2latex.l"
OUT ("\\&=");
	YY_BREAK
case 86:
# line 179 "c++2latex.l"
OUT ("\\{");
	YY_BREAK
case 87:
# line 180 "c++2latex.l"
OUT ("\\}");
	YY_BREAK
case 88:
# line 181 "c++2latex.l"
OUT ("\\&");
	YY_BREAK
case 89:
# line 182 "c++2latex.l"
OUT ("\\%");
	YY_BREAK
case 90:
# line 183 "c++2latex.l"
OUT ("-{}-");
	YY_BREAK
case 91:
# line 184 "c++2latex.l"
OUT (".$\\ast$");
	YY_BREAK
case 92:
# line 186 "c++2latex.l"
case 93:
# line 187 "c++2latex.l"
case 94:
# line 188 "c++2latex.l"
case 95:
# line 189 "c++2latex.l"
case 96:
# line 190 "c++2latex.l"
case 97:
# line 191 "c++2latex.l"
case 98:
# line 192 "c++2latex.l"
case 99:
# line 193 "c++2latex.l"
case 100:
# line 194 "c++2latex.l"
case 101:
# line 195 "c++2latex.l"
case 102:
# line 196 "c++2latex.l"
case 103:
# line 197 "c++2latex.l"
case 104:
# line 198 "c++2latex.l"
case 105:
# line 199 "c++2latex.l"
case 106:
# line 200 "c++2latex.l"
case 107:
# line 201 "c++2latex.l"
case 108:
# line 202 "c++2latex.l"
case 109:
# line 203 "c++2latex.l"
case 110:
# line 203 "c++2latex.l"
ECHO;
	YY_BREAK
case 111:
# line 206 "c++2latex.l"
case 112:
# line 206 "c++2latex.l"
{ SUB (yytext);
					  if (want_index) {
					    OUT ("\\index{"); SUB(yytext);
					    OUT("}"); } }
	YY_BREAK
case 113:
# line 211 "c++2latex.l"
{ BEGIN (BCOMMENT); OUT ("{$/\\ast$\\");
				  OUT (comment_font); OUT ("{}"); }
	YY_BREAK
case 114:
# line 213 "c++2latex.l"
{ INIT; OUT ("$\\ast/$}"); }
	YY_BREAK
case 115:
# line 214 "c++2latex.l"
OUT ("\\mbox{}\\\\\n");
	YY_BREAK
case 116:
# line 215 "c++2latex.l"
IND;
	YY_BREAK
case 117:
# line 216 "c++2latex.l"
SUB (yytext);
	YY_BREAK
case 118:
*yy_cp = yy_hold_char; /* undo effects of setting up yytext */
yy_c_buf_p = yy_cp -= 1;
YY_DO_BEFORE_ACTION; /* set up yytext again */
# line 218 "c++2latex.l"
{ OUT ("{$//$\\"); 
				  OUT (comment_font); OUT ("{}");
			          SUB (yytext + 2);
				  OUT ("}\\mbox{}\\\\\n"); }
	YY_BREAK
case 119:
# line 223 "c++2latex.l"
{ BEGIN (STRING); OUT ("{\\");
				  OUT (string_font); OUT ("\""); }
	YY_BREAK
case 120:
# line 225 "c++2latex.l"
OUT ("$\\backslash\\backslash$");
	YY_BREAK
case 121:
# line 226 "c++2latex.l"
{ OUT ("$\\backslash$"); SUB (yytext+1); }
	YY_BREAK
case 122:
# line 227 "c++2latex.l"
{ INIT; OUT ("\"}"); }
	YY_BREAK
case 123:
# line 228 "c++2latex.l"
OUT ("\\mbox{}\\\\\n");
	YY_BREAK
case 124:
# line 229 "c++2latex.l"
IND;
	YY_BREAK
case 125:
# line 230 "c++2latex.l"
SUB (yytext);
	YY_BREAK
case 126:
# line 233 "c++2latex.l"
case 127:
# line 234 "c++2latex.l"
case 128:
# line 235 "c++2latex.l"
case 129:
# line 235 "c++2latex.l"
ECHO;
	YY_BREAK
case 130:
# line 237 "c++2latex.l"
ECHO;
	YY_BREAK
case 131:
# line 240 "c++2latex.l"
case 132:
# line 241 "c++2latex.l"
case 133:
# line 242 "c++2latex.l"
case 134:
# line 242 "c++2latex.l"
SUB (yytext);
	YY_BREAK
case 135:
# line 244 "c++2latex.l"
ECHO;
	YY_BREAK
case 136:
# line 246 "c++2latex.l"
ECHO;
	YY_BREAK
case 137:
# line 248 "c++2latex.l"
OUT ("$\\backslash$\\\\\n");
	YY_BREAK
case 138:
# line 249 "c++2latex.l"
IND;
	YY_BREAK
case 139:
# line 250 "c++2latex.l"
ECHO;
	YY_BREAK
case 140:
# line 251 "c++2latex.l"
OUT ("\\newpage\n");
	YY_BREAK
case 141:
# line 252 "c++2latex.l"
OUT ("\\mbox{}\\\\\n");
	YY_BREAK
case 142:
# line 254 "c++2latex.l"
ECHO;
	YY_BREAK
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(STRING):
case YY_STATE_EOF(BCOMMENT):
case YY_STATE_EOF(INCLUDE):
case YY_STATE_EOF(CPLUSPLUS):
    yyterminate();

	    case YY_END_OF_BUFFER:
		{
		/* amount of text matched not including the EOB char */
		int yy_amount_of_matched_text = yy_cp - yytext - 1;

		/* undo the effects of YY_DO_BEFORE_ACTION */
		*yy_cp = yy_hold_char;

		/* note that here we test for yy_c_buf_p "<=" to the position
		 * of the first EOB in the buffer, since yy_c_buf_p will
		 * already have been incremented past the NUL character
		 * (since all states make transitions on EOB to the end-
		 * of-buffer state).  Contrast this with the test in yyinput().
		 */
		if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
		    /* this was really a NUL */
		    {
		    yy_state_type yy_next_state;

		    yy_c_buf_p = yytext + yy_amount_of_matched_text;

		    yy_current_state = yy_get_previous_state();

		    /* okay, we're now positioned to make the
		     * NUL transition.  We couldn't have
		     * yy_get_previous_state() go ahead and do it
		     * for us because it doesn't know how to deal
		     * with the possibility of jamming (and we
		     * don't want to build jamming into it because
		     * then it will run more slowly)
		     */

		    yy_next_state = yy_try_NUL_trans( yy_current_state );

		    yy_bp = yytext + YY_MORE_ADJ;

		    if ( yy_next_state )
			{
			/* consume the NUL */
			yy_cp = ++yy_c_buf_p;
			yy_current_state = yy_next_state;
			goto yy_match;
			}

		    else
			{
			    yy_cp = yy_last_accepting_cpos;
			    yy_current_state = yy_last_accepting_state;
			goto yy_find_action;
			}
		    }

		else switch ( yy_get_next_buffer() )
		    {
		    case EOB_ACT_END_OF_FILE:
			{
			yy_did_buffer_switch_on_eof = 0;

			if ( yywrap() )
			    {
			    /* note: because we've taken care in
			     * yy_get_next_buffer() to have set up yytext,
			     * we can now set up yy_c_buf_p so that if some
			     * total hoser (like flex itself) wants
			     * to call the scanner after we return the
			     * YY_NULL, it'll still work - another YY_NULL
			     * will get returned.
			     */
			    yy_c_buf_p = yytext + YY_MORE_ADJ;

			    yy_act = YY_STATE_EOF((yy_start - 1) / 2);
			    goto do_action;
			    }

			else
			    {
			    if ( ! yy_did_buffer_switch_on_eof )
				YY_NEW_FILE;
			    }
			}
			break;

		    case EOB_ACT_CONTINUE_SCAN:
			yy_c_buf_p = yytext + yy_amount_of_matched_text;

			yy_current_state = yy_get_previous_state();

			yy_cp = yy_c_buf_p;
			yy_bp = yytext + YY_MORE_ADJ;
			goto yy_match;

		    case EOB_ACT_LAST_MATCH:
			yy_c_buf_p =
			    &yy_current_buffer->yy_ch_buf[yy_n_chars];

			yy_current_state = yy_get_previous_state();

			yy_cp = yy_c_buf_p;
			yy_bp = yytext + YY_MORE_ADJ;
			goto yy_find_action;
		    }
		break;
		}

	    default:
#ifdef FLEX_DEBUG
		printf( "action # %d\n", yy_act );
#endif
		YY_FATAL_ERROR(
			"fatal flex scanner internal error--no action found" );
	    }
	}
    }


/* yy_get_next_buffer - try to read in a new buffer
 *
 * synopsis
 *     int yy_get_next_buffer();
 *     
 * returns a code representing an action
 *     EOB_ACT_LAST_MATCH - 
 *     EOB_ACT_CONTINUE_SCAN - continue scanning from current position
 *     EOB_ACT_END_OF_FILE - end of file
 */

static int yy_get_next_buffer()

    {
    register YY_CHAR *dest = yy_current_buffer->yy_ch_buf;
    register YY_CHAR *source = yytext - 1; /* copy prev. char, too */
    register int number_to_move, i;
    int ret_val;

    if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
	YY_FATAL_ERROR(
		"fatal flex scanner internal error--end of buffer missed" );

    /* try to read more data */

    /* first move last chars to start of buffer */
    number_to_move = yy_c_buf_p - yytext;

    for ( i = 0; i < number_to_move; ++i )
	*(dest++) = *(source++);

    if ( yy_current_buffer->yy_eof_status != EOF_NOT_SEEN )
	/* don't do the read, it's not guaranteed to return an EOF,
	 * just force an EOF
	 */
	yy_n_chars = 0;

    else
	{
	int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1;

	if ( num_to_read > YY_READ_BUF_SIZE )
	    num_to_read = YY_READ_BUF_SIZE;

	else if ( num_to_read <= 0 )
	    YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" );

	/* read in more data */
	YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
		  yy_n_chars, num_to_read );
	}

    if ( yy_n_chars == 0 )
	{
	if ( number_to_move == 1 )
	    {
	    ret_val = EOB_ACT_END_OF_FILE;
	    yy_current_buffer->yy_eof_status = EOF_DONE;
	    }

	else
	    {
	    ret_val = EOB_ACT_LAST_MATCH;
	    yy_current_buffer->yy_eof_status = EOF_PENDING;
	    }
	}

    else
	ret_val = EOB_ACT_CONTINUE_SCAN;

    yy_n_chars += number_to_move;
    yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
    yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;

    /* yytext begins at the second character in yy_ch_buf; the first
     * character is the one which preceded it before reading in the latest
     * buffer; it needs to be kept around in case it's a newline, so
     * yy_get_previous_state() will have with '^' rules active
     */

    yytext = &yy_current_buffer->yy_ch_buf[1];

    return ( ret_val );
    }


/* yy_get_previous_state - get the state just before the EOB char was reached
 *
 * synopsis
 *     yy_state_type yy_get_previous_state();
 */

static yy_state_type yy_get_previous_state()

    {
    register yy_state_type yy_current_state;
    register YY_CHAR *yy_cp;

    register YY_CHAR *yy_bp = yytext;

    yy_current_state = yy_start;
    if ( yy_bp[-1] == '\n' )
	++yy_current_state;

    for ( yy_cp = yytext + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
	{
	register YY_CHAR yy_c = (*yy_cp ? yy_ec[*yy_cp] : 1);
	if ( yy_accept[yy_current_state] )
	    {
	    yy_last_accepting_state = yy_current_state;
	    yy_last_accepting_cpos = yy_cp;
	    }
	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
	    {
	    yy_current_state = yy_def[yy_current_state];
	    if ( yy_current_state >= 553 )
		yy_c = yy_meta[yy_c];
	    }
	yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
	}

    return ( yy_current_state );
    }


/* yy_try_NUL_trans - try to make a transition on the NUL character
 *
 * synopsis
 *     next_state = yy_try_NUL_trans( current_state );
 */

#ifdef YY_USE_PROTOS
static yy_state_type yy_try_NUL_trans( register yy_state_type yy_current_state )
#else
static yy_state_type yy_try_NUL_trans( yy_current_state )
register yy_state_type yy_current_state;
#endif

    {
    register int yy_is_jam;
    register YY_CHAR *yy_cp = yy_c_buf_p;

    register YY_CHAR yy_c = 1;
    if ( yy_accept[yy_current_state] )
	{
	yy_last_accepting_state = yy_current_state;
	yy_last_accepting_cpos = yy_cp;
	}
    while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
	{
	yy_current_state = yy_def[yy_current_state];
	if ( yy_current_state >= 553 )
	    yy_c = yy_meta[yy_c];
	}
    yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
    yy_is_jam = (yy_current_state == 552);

    return ( yy_is_jam ? 0 : yy_current_state );
    }


#ifdef YY_USE_PROTOS
static void yyunput( YY_CHAR c, register YY_CHAR *yy_bp )
#else
static void yyunput( c, yy_bp )
YY_CHAR c;
register YY_CHAR *yy_bp;
#endif

    {
    register YY_CHAR *yy_cp = yy_c_buf_p;

    /* undo effects of setting up yytext */
    *yy_cp = yy_hold_char;

    if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
	{ /* need to shift things up to make room */
	register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */
	register YY_CHAR *dest =
	    &yy_current_buffer->yy_ch_buf[yy_current_buffer->yy_buf_size + 2];
	register YY_CHAR *source =
	    &yy_current_buffer->yy_ch_buf[number_to_move];

	while ( source > yy_current_buffer->yy_ch_buf )
	    *--dest = *--source;

	yy_cp += dest - source;
	yy_bp += dest - source;
	yy_n_chars = yy_current_buffer->yy_buf_size;

	if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
	    YY_FATAL_ERROR( "flex scanner push-back overflow" );
	}

    if ( yy_cp > yy_bp && yy_cp[-1] == '\n' )
	yy_cp[-2] = '\n';

    *--yy_cp = c;

    /* note: the formal parameter *must* be called "yy_bp" for this
     *       macro to now work correctly
     */
    YY_DO_BEFORE_ACTION; /* set up yytext again */
    }


#ifdef __cplusplus
static int yyinput()
#else
static int input()
#endif

    {
    int c;
    YY_CHAR *yy_cp = yy_c_buf_p;

    *yy_cp = yy_hold_char;

    if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
	{
	/* yy_c_buf_p now points to the character we want to return.
	 * If this occurs *before* the EOB characters, then it's a
	 * valid NUL; if not, then we've hit the end of the buffer.
	 */
	if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
	    /* this was really a NUL */
	    *yy_c_buf_p = '\0';

	else
	    { /* need more input */
	    yytext = yy_c_buf_p;
	    ++yy_c_buf_p;

	    switch ( yy_get_next_buffer() )
		{
		case EOB_ACT_END_OF_FILE:
		    {
		    if ( yywrap() )
			{
			yy_c_buf_p = yytext + YY_MORE_ADJ;
			return ( EOF );
			}

		    YY_NEW_FILE;

#ifdef __cplusplus
		    return ( yyinput() );
#else
		    return ( input() );
#endif
		    }
		    break;

		case EOB_ACT_CONTINUE_SCAN:
		    yy_c_buf_p = yytext + YY_MORE_ADJ;
		    break;

		case EOB_ACT_LAST_MATCH:
#ifdef __cplusplus
		    YY_FATAL_ERROR( "unexpected last match in yyinput()" );
#else
		    YY_FATAL_ERROR( "unexpected last match in input()" );
#endif
		}
	    }
	}

    c = *yy_c_buf_p;
    yy_hold_char = *++yy_c_buf_p;

    return ( c );
    }


#ifdef YY_USE_PROTOS
void yyrestart( FILE *input_file )
#else
void yyrestart( input_file )
FILE *input_file;
#endif

    {
    yy_init_buffer( yy_current_buffer, input_file );
    yy_load_buffer_state();
    }


#ifdef YY_USE_PROTOS
void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
#else
void yy_switch_to_buffer( new_buffer )
YY_BUFFER_STATE new_buffer;
#endif

    {
    if ( yy_current_buffer == new_buffer )
	return;

    if ( yy_current_buffer )
	{
	/* flush out information for old buffer */
	*yy_c_buf_p = yy_hold_char;
	yy_current_buffer->yy_buf_pos = yy_c_buf_p;
	yy_current_buffer->yy_n_chars = yy_n_chars;
	}

    yy_current_buffer = new_buffer;
    yy_load_buffer_state();

    /* we don't actually know whether we did this switch during
     * EOF (yywrap()) processing, but the only time this flag
     * is looked at is after yywrap() is called, so it's safe
     * to go ahead and always set it.
     */
    yy_did_buffer_switch_on_eof = 1;
    }


#ifdef YY_USE_PROTOS
void yy_load_buffer_state( void )
#else
void yy_load_buffer_state()
#endif

    {
    yy_n_chars = yy_current_buffer->yy_n_chars;
    yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
    yyin = yy_current_buffer->yy_input_file;
    yy_hold_char = *yy_c_buf_p;
    }


#ifdef YY_USE_PROTOS
YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
#else
YY_BUFFER_STATE yy_create_buffer( file, size )
FILE *file;
int size;
#endif

    {
    YY_BUFFER_STATE b;

    b = (YY_BUFFER_STATE) malloc( sizeof( struct yy_buffer_state ) );

    if ( ! b )
	YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );

    b->yy_buf_size = size;

    /* yy_ch_buf has to be 2 characters longer than the size given because
     * we need to put in 2 end-of-buffer characters.
     */
    b->yy_ch_buf = (YY_CHAR *) malloc( (unsigned) (b->yy_buf_size + 2) );

    if ( ! b->yy_ch_buf )
	YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );

    yy_init_buffer( b, file );

    return ( b );
    }


#ifdef YY_USE_PROTOS
void yy_delete_buffer( YY_BUFFER_STATE b )
#else
void yy_delete_buffer( b )
YY_BUFFER_STATE b;
#endif

    {
    if ( b == yy_current_buffer )
	yy_current_buffer = (YY_BUFFER_STATE) 0;

    free( (char *) b->yy_ch_buf );
    free( (char *) b );
    }


#ifdef YY_USE_PROTOS
void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
#else
void yy_init_buffer( b, file )
YY_BUFFER_STATE b;
FILE *file;
#endif

    {
    b->yy_input_file = file;

    /* we put in the '\n' and start reading from [1] so that an
     * initial match-at-newline will be true.
     */

    b->yy_ch_buf[0] = '\n';
    b->yy_n_chars = 1;

    /* we always need two end-of-buffer characters.  The first causes
     * a transition to the end-of-buffer state.  The second causes
     * a jam in that state.
     */
    b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
    b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR;

    b->yy_buf_pos = &b->yy_ch_buf[1];

    b->yy_eof_status = EOF_NOT_SEEN;
    }
# line 254 "c++2latex.l"


void substitute (const char * input)
{
  while (*input)
    {
      switch (*input)
	{
	case '_':
	case '&':
	case '#':
	case '$':
	case '%':
	case '{':
	case '}':
	  printf ("\\%c", *input);
	  break;
	case '+':
	case '=':
	case '<':
	case '>':
	  printf ("$%c$", *input);
	  break;
	case '*':
	  printf ("$\\ast$");
	  break;
	case '|':
	  printf ("$\\mid$");
	  break;
	case '\\':
	  printf ("$\\backslash$");
	  break;
	case '^':
	  printf ("$\\wedge$");
	  break;
	case '~':
	  printf ("$\\sim$");
	  break;
	default:
	  printf ("%c", *input);
	  break;
	}
      input++;
    }
}

void
indent(const char * blanks)
{
  int i;
  
  i = 0;
  while (*blanks)
    {
      if (*blanks == ' ')
	{
	  i++;
	}
      else			/* *blanks == '\t' */
	{
	  while (++i % tabtotab) ;
	}
      blanks++;
    }
  printf ("\\hspace*{%d\\indentation}", i);
}

#include "getopt.h"
#include <string.h>
#include <fcntl.h>
#include <ctype.h>
#include <time.h>

extern char * version_string;

static struct option opts[] =
{
  {"ansi-c", 0, 0, 'a'},
  {"c-plusplus", 0, 0, 'p'},
  {"complete-file", 0, 0, 'c'},
  {"font-size", 1, 0, 's'},
  {"indentation", 1, 0, 'i'},
  {"header", 0, 0, 'h'},
  {"piped", 0, 0, 't'},
  {"output", 1, 0, 'o'},
  {"tabstop", 1, 0, 'T'},
  {"comment-font", 1, 0, 'C'},
  {"string-font", 1, 0, 'S'},
  {"keyword-font", 1, 0, 'K'},
  {"header-font", 1, 0, 'H'},
  {"cpp-font", 1, 0, 'P'},
  {"version", 0, 0, 'V'},
  {"index", 0, 0, 'x'},
  {0, 0, 0, 0}
};


main (int argc, char** argv)
{
  int c;
  int index;
  int i;
  int has_filename;
  char * input_name;
  char * output_name;
  char * program_name;
  long now;
  char * today;

  input_name = "Standard Input";
  output_name = 0;

  now = time(0);
  today = ctime(&now);

  now = time(0);
  today = ctime(&now);

  program_name = strrchr (argv[0], '/');
  if (program_name == NULL)	/* no pathname */
    {
      program_name = argv[0];
    }
  else
    {
      program_name++;
    }
  
#ifdef USE_NAME 
#if defined(ANSI_C) || defined(C_PLUSPLUS)
#error USE_NAME, ANSI_C and C_PLUSPLUS are mutually exclusive
#else
  /* simple heuristic: '+' in name means C++ */
  cplusplus_mode = (strchr (program_name, '+') != 0);
#endif
#endif
  
  while ((c = getopt_long (argc, argv,
			   "acpo:s:i:thT:C:H:S:K:P:Vx", opts, &index))
	 != EOF)
    {
      if (c == 0)		/* Long option */
	{
	  c = opts[index].val;
	}
      switch (c)
	{
	case 'a':
	  cplusplus_mode = 0;
	  break;
	case 'p':
	  cplusplus_mode = 1;
	  break;
	case 'c':
	  complete_file = 1;
	  break;
	case 'o':
	  if (piped)
	    {
	      fprintf (stderr,
		       "%s: Can't use {-t,+pipe} and {-o,+output} together\n",
		       program_name);
	      exit(5);
	    }
	  output_name = optarg;
	  break;
	case 's':
	  font_size = optarg;
	  break;
	case 'i':
	  indentation = optarg;
	  break;
	case 'T':
	  tabtotab = atoi(optarg);
	  break;
	    case 't':
	      if (output_name != 0)
	    {
	      fprintf (stderr,
		       "%s: Can't use {-t,+pipe} and {-o,+output} together\n",
		       program_name);
	      exit(5);
	    }
	  piped = 1;
	  break;
	case 'h':
	  header = 1;
	  complete_file = 1;	/* header implies complete-file */
	  break;
	case 'C':
	  comment_font = optarg;
	  break;
	case 'H':
	  header_font = optarg;
	  break;
	case 'P':
	  cpp_font = optarg;
	  break;
	case 'S':
	  string_font = optarg;
	  break;
	case 'K':
	  keyword_font = optarg;
	  break;
	case 'V':
	  fprintf (stderr, "%s\n", version_string);
	  break;
        case 'x':
          want_index = 1;
          break;
	default:
	  usage(program_name);
	}
    }
  has_filename = (argc - optind == 1);
  if (has_filename)		/* last argument is input file name */
    {
      input_name = argv[optind];
      if (freopen (input_name, "r", stdin) == NULL)
	{
	  fprintf (stderr, "%s: Can't open `%s' for reading\n",
		   program_name, input_name);
	  exit (2);
	}
    }
  if ((output_name == 0) && !piped)
    {
      char * tmp;
      if (has_filename)
	{
	  char * point;
	  
	  point = strrchr (input_name, '/');
	  if (point == 0)	/* plain filename */
	    {
	      point = input_name;
	    }
	  else
	    {
	      point++;
	    }
	  tmp = malloc (strlen (point) + 1);
	  if (tmp == 0)
	    {
	      fprintf (stderr, "%s: Virtual memory exhausted\n", program_name);
	      exit (3);
	    }
	  strcpy (tmp, point);
	  point = strrchr (tmp, '.');
	  if (point != 0)
	    {
	      *point = '\0';
	    }
	}
      else
	{
	  tmp = program_name;
	}
      output_name = malloc (strlen (tmp) + 4);
      if (output_name == 0)
	{
	  fprintf (stderr, "%s: Virtual memory exhausted\n", program_name);
	  exit (3);
	}
      strcpy (output_name, tmp);
      strcat (output_name, ".tex");
    }
  if (!piped)
    {
      if (freopen (output_name, "w", stdout) == NULL)
	{
	  fprintf (stderr, "%s: Can't open `%s' for writing\n",
		   program_name, output_name);
	  exit (4);
	}
    }
  printf ("\
%%\n\
%% This file was automatically produced at %.24s by\n\
%% %s", today, program_name);
  for (i = 1; i < argc; i++)
    {
      printf(" %s", argv[i]);
    }
  if (!has_filename)
    {
      printf(" (from Standard Input)");
    }
  printf("\n%%\n");
  if (complete_file)
    {
      if (header)
	{
	  if (strcmp (font_size, "10") == 0)
	    {
	      printf ("\\documentstyle[fancyheadings]{article}\n");
	    }
	  else
	    {
	      printf ("\\documentstyle[%spt,fancyheadings]{article}\n",
		      font_size);
	    }
	}
      else
	{
	  if (strcmp (font_size, "10") == 0)
	    {
	      printf ("\\documentstyle{article}\n");
	    }
	  else
	    {
	      printf ("\\documentstyle[%spt]{article}\n", font_size);
	    }
	}
      printf ("\\setlength{\\textwidth}{15cm}\n");
      printf ("\\setlength{\\textheight}{22.5cm}\n");
      printf ("\\setlength{\\hoffset}{-2cm}\n");
      printf ("\\setlength{\\voffset}{-2cm}\n");
      if (want_index)
        printf("\\makeindex\n");
      if (header)
	{
	  printf ("\\chead{\\%s Produced from ", header_font);
	  substitute(input_name);
	  printf (" at %.24s}\n", today);
	  printf ("\\cfoot{\\rm\\thepage}\n");
	  printf ("\\addtolength{\\headheight}{14pt}\n");
	  printf ("\\pagestyle{fancy}\n");
	}
      printf ("\\begin{document}\n");
    }
  printf ("\\expandafter\\ifx\\csname indentation\\endcsname\\relax%\n");
  printf ("\\newlength{\\indentation}\\fi\n");
  printf ("\\setlength{\\indentation}{%s}\n", indentation);
  printf ("\\begin{flushleft}\n");
  yylex();
  printf ("\\end{flushleft}\n");
  if (complete_file)
    {
      printf ("\\end{document}\n");
    }
  exit(0);
}

void
usage(const char * name)
{
  fprintf (stderr, "%s\n", version_string);
  fprintf (stderr, "\
Usage: %s [-a] [-c] [-h] [-i length] [-o path] [-p] [-s size] [-t]\n\
       [-C font][-H font] [-K font] [-P font] [-S font] [-T wide] [-V] [-x]\n\
       [+ansi-c] [+complete-file] [+header] [+indentation length]\n\
       [+output path] [+c-plusplus] [+font-size size] [+pipe]\n\
       [+comment-font font] [+keyword-font font] [+cpp-font font]\n\
       [+header-font font] [+string-font font] [+tabstop wide]\n\
       [+version] [+index] [path]\n", name);
  exit (1);
}