
/*  A Bison parser, made from grammar.y with Bison version GNU Bison version 1.21
  */

#define YYBISON 1  /* Identify Bison output.  */

#define	TXT	258
#define	NUMBER	259
#define	CLEFT	260
#define	BEAT	261
#define	BAR	262
#define	EOL	263
#define	METERFRAC	264
#define	METER	265
#define	STARTFS	266
#define	ENDFS	267
#define	EMB	268
#define	EMBP	269
#define	BEAM	270
#define	THEME	271
#define	TIME	272
#define	DOT	273
#define	TRIPLET	274
#define	TIE	275
#define	TIEBEAT	276
#define	TIEALA	277
#define	TIEDBL	278
#define	TIECLEFT	279
#define	TIEXBAR	280
#define	TIELRBAR	281
#define	TIEDBAR	282

#line 5 "grammar.y"


#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "tokensDat.h"
#define MAXLEN 1000
#define YYSTYPE char *

/* uncomment the following line for use with DropUNIX on the MAC */
/* #define MAC */

#ifdef MAC
#define alloca malloc
#endif

/* _WIN32 definition added for use with MS VC++ compiler. */
#ifdef _WIN32
#include <malloc.h>
#endif


int firstline=1, ntext=0, page, tiepend=0, tiearmed=0, lbhead;
size_t prelen, nn;
char num[2],den[2];
char *insert(char *, char *);
char *inserts(char*, char *, char *); 
char *insertt(char*, char *, char *); 
char *inserttie(char*, char *);
char *inserttrip(char*, char*);
char *insertthtrip(char*, char*);
char *insertetn(char *);
char *shorten( char *);

/* FILE *yyout = stderr; */  /* directs unrecognized input to stderr.
                                some loaders don't like this. */
int  i;


#ifndef YYLTYPE
typedef
  struct yyltype
    {
      int timestamp;
      int first_line;
      int first_column;
      int last_line;
      int last_column;
      char *text;
   }
  yyltype;

#define YYLTYPE yyltype
#endif

#ifndef YYSTYPE
#define YYSTYPE int
#endif
#ifndef YYDEBUG
#define YYDEBUG 1
#endif

#include <stdio.h>

#ifndef __cplusplus
#ifndef __STDC__
#define const
#endif
#endif



#define	YYFINAL		111
#define	YYFLAG		-32768
#define	YYNTBASE	28

#define YYTRANSLATE(x) ((unsigned)(x) <= 282 ? yytranslate[x] : 43)

static const char yytranslate[] = {     0,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
     6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
    16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
    26,    27
};

#if YYDEBUG != 0
static const short yyprhs[] = {     0,
     0,     1,     4,     7,    11,    13,    16,    20,    22,    25,
    28,    31,    35,    39,    42,    45,    48,    51,    55,    58,
    61,    64,    68,    71,    74,    78,    82,    86,    90,    95,
    99,   102,   106,   109,   113,   117,   121,   125,   130,   134,
   137,   141,   144,   147,   150,   154,   158,   162,   166,   171,
   175,   177,   180,   184,   186,   188,   190,   194,   198,   201,
   204,   209,   213,   219,   224,   231,   237,   244,   250,   255,
   259,   265,   270,   276,   281,   284,   286,   288,   290,   292,
   295,   297,   300,   303,   306,   308,   310,   314,   316
};

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

#endif

#if YYDEBUG != 0
static const short yyrline[] = { 0,
    55,    56,    59,    65,    72,    75,    81,    89,    95,    98,
   107,   109,   126,   143,   160,   162,   164,   169,   176,   177,
   180,   182,   186,   190,   194,   196,   201,   203,   207,   211,
   217,   220,   225,   230,   233,   239,   241,   245,   250,   257,
   259,   263,   267,   272,   276,   278,   282,   284,   288,   292,
   299,   300,   301,   306,   307,   308,   309,   314,   317,   320,
   324,   327,   330,   335,   340,   345,   350,   355,   360,   370,
   380,   390,   400,   410,   420,   425,   426,   427,   428,   446,
   450,   451,   452,   453,   456,   462,   477,   485,   488
};

static const char * const yytname[] = {   "$","error","$illegal.","TXT","NUMBER",
"CLEFT","BEAT","BAR","EOL","METERFRAC","METER","STARTFS","ENDFS","EMB","EMBP",
"BEAM","THEME","TIME","DOT","TRIPLET","TIE","TIEBEAT","TIEALA","TIEDBL","TIECLEFT",
"TIEXBAR","TIELRBAR","TIEDBAR","input","line","bline","ebar","ebarc","mbar",
"bcont","element","theme","btheme","emb","tiebeat","tline","text","number",""
};
#endif

static const short yyr1[] = {     0,
    28,    28,    29,    29,    29,    30,    30,    30,    30,    30,
    30,    30,    30,    30,    30,    30,    30,    30,    30,    30,
    31,    31,    31,    31,    31,    31,    31,    31,    31,    31,
    32,    32,    32,    32,    32,    32,    32,    32,    32,    33,
    33,    33,    33,    33,    33,    33,    33,    33,    33,    33,
    34,    34,    34,    35,    35,    35,    35,    36,    36,    36,
    37,    37,    37,    37,    37,    37,    37,    37,    37,    37,
    37,    37,    37,    37,    37,    38,    38,    38,    38,    38,
    39,    39,    39,    39,    40,    40,    40,    41,    42
};

static const short yyr2[] = {     0,
     0,     2,     2,     3,     1,     2,     3,     1,     2,     2,
     2,     3,     3,     2,     2,     2,     2,     3,     2,     2,
     2,     3,     2,     2,     3,     3,     3,     3,     4,     3,
     2,     3,     2,     3,     3,     3,     3,     4,     3,     2,
     3,     2,     2,     2,     3,     3,     3,     3,     4,     3,
     1,     2,     3,     1,     1,     1,     3,     3,     2,     2,
     4,     3,     5,     4,     6,     5,     6,     5,     4,     3,
     5,     4,     5,     4,     2,     1,     1,     1,     1,     2,
     1,     2,     2,     2,     1,     1,     3,     1,     1
};

static const short yydefact[] = {     1,
     0,    88,    89,     8,     2,     0,     5,    85,    86,    20,
    11,    10,     9,    14,    19,    77,    76,     0,    15,    81,
     3,     6,    17,     0,    51,    54,    55,    56,    16,     0,
    83,    12,    13,     0,    59,    82,    79,    78,     4,     7,
    18,    31,     0,    40,    21,     0,    23,    24,    33,    42,
    44,    43,    52,    55,     0,    60,     0,    75,     0,     0,
    80,    84,    87,    62,    58,    34,    45,    25,    27,    36,
    47,    32,    41,    22,    53,    55,     0,    35,    46,    26,
    28,    37,    48,     0,    70,     0,    39,    57,    50,    30,
     0,    61,     0,    38,    49,    29,    64,    69,     0,    74,
     0,    72,    63,    68,    73,    66,    71,    67,    65,     0,
     0
};

static const short yydefgoto[] = {     1,
     5,     6,    21,    22,    23,    24,    25,    26,    27,    28,
    29,     7,     8,     9
};

static const short yypact[] = {-32768,
   173,-32768,-32768,-32768,-32768,    92,-32768,    11,-32768,    -5,
     9,-32768,-32768,    57,    70,-32768,-32768,   -10,    16,-32768,
    74,-32768,-32768,    47,-32768,     4,   155,   168,    23,    11,
-32768,-32768,-32768,    15,    21,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,   109,-32768,-32768,     5,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,   155,   125,-32768,    31,-32768,    28,   137,
   168,-32768,-32768,    33,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,   155,   149,-32768,-32768,-32768,
-32768,-32768,-32768,    30,    38,    94,-32768,-32768,-32768,-32768,
   111,-32768,    29,-32768,-32768,-32768,    39,-32768,    59,    71,
    60,    73,-32768,    82,-32768,    89,-32768,-32768,-32768,   110,
-32768
};

static const short yypgoto[] = {-32768,
-32768,-32768,   -19,   -18,   -17,-32768,   -16,-32768,   -15,   -27,
    91,-32768,    -2,-32768
};


#define	YYLAST		182


static const short yytable[] = {    60,
    61,    39,    40,    41,    34,    30,    35,    53,    54,    72,
    36,    73,    74,     2,    31,    37,    38,    16,    17,    32,
    18,    36,    56,    69,    70,    71,    77,    63,    62,    75,
    76,    64,    61,    61,    88,    81,    82,    83,    65,    37,
    38,    16,    17,    86,    91,    84,    97,    85,    93,    61,
    92,    42,    43,    44,    45,    98,   103,    37,    38,    16,
    17,   -79,    18,    33,   -79,    61,    46,    20,    47,    48,
    49,    50,    51,    52,   -78,   104,   106,   -78,   -79,   -79,
   -79,   -79,   -79,   -79,    37,    38,    16,    17,   105,    18,
   107,   -78,   -78,   -78,   -78,   -78,   -78,    10,    11,   108,
    12,    13,    14,    15,    16,    17,   109,    18,    99,   111,
   100,    19,    20,    66,    55,    67,    68,     0,     0,    37,
    38,    16,    17,     0,    18,   101,     0,   102,    31,    78,
    62,    79,    80,     0,     0,    37,    38,    16,    17,     0,
    18,    87,    88,    89,    90,     0,     0,    37,    38,    16,
    17,     0,    91,    94,    88,    95,    96,     0,     0,    37,
    38,    16,    17,     0,    91,    37,    38,    16,    17,     0,
    57,     0,   110,    58,    59,     2,     3,     4,    37,    38,
    16,    17
};

static const short yycheck[] = {    27,
    28,    21,    21,    21,    15,     8,    17,    24,    24,     5,
     6,     7,     8,     3,    20,    11,    12,    13,    14,    11,
    16,     6,    19,    43,    43,    43,    54,    30,     6,    46,
    46,    17,    60,    61,     6,    55,    55,    55,    18,    11,
    12,    13,    14,    16,    16,    15,    17,    17,    76,    77,
    18,     5,     6,     7,     8,    18,    18,    11,    12,    13,
    14,     5,    16,     7,     8,    93,    20,    21,    22,    23,
    24,    25,    26,    27,     5,    17,    17,     8,    22,    23,
    24,    25,    26,    27,    11,    12,    13,    14,    18,    16,
    18,    22,    23,    24,    25,    26,    27,     6,     7,    18,
     9,    10,    11,    12,    13,    14,    18,    16,    15,     0,
    17,    20,    21,     5,    24,     7,     8,    -1,    -1,    11,
    12,    13,    14,    -1,    16,    15,    -1,    17,    20,     5,
     6,     7,     8,    -1,    -1,    11,    12,    13,    14,    -1,
    16,     5,     6,     7,     8,    -1,    -1,    11,    12,    13,
    14,    -1,    16,     5,     6,     7,     8,    -1,    -1,    11,
    12,    13,    14,    -1,    16,    11,    12,    13,    14,    -1,
    16,    -1,     0,    19,    20,     3,     4,     5,    11,    12,
    13,    14
};
/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
#line 3 "/usr/local/lib/bison.simple"

/* Skeleton output parser for bison,
   Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman

   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.  */


#ifndef alloca
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not GNU C.  */
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
#include <alloca.h>
#else /* not sparc */
#if defined (MSDOS) && !defined (__TURBOC__)
#include <malloc.h>
#else /* not MSDOS, or __TURBOC__ */
#if defined(_AIX)
#include <malloc.h>
 #pragma alloca
#else /* not MSDOS, __TURBOC__, or _AIX */
#ifdef __hpux
#ifdef __cplusplus
extern "C" {
void *alloca (unsigned int);
};
#else /* not __cplusplus */
void *alloca (unsigned int);
#endif /* not __cplusplus */
#endif /* __hpux */
#endif /* not _AIX */
#endif /* not MSDOS, or __TURBOC__ */
#endif /* not sparc.  */
#endif /* not GNU C.  */
#endif /* alloca not defined.  */

/* This is the parser code that is written into each bison parser
  when the %semantic_parser declaration is not specified in the grammar.
  It was written by Richard Stallman by simplifying the hairy parser
  used when %semantic_parser is specified.  */

/* Note: there must be only one dollar sign in this file.
   It is replaced by the list of actions, each action
   as one case of the switch.  */

#define yyerrok		(yyerrstatus = 0)
#define yyclearin	(yychar = YYEMPTY)
#define YYEMPTY		-2
#define YYEOF		0
#define YYACCEPT	return(0)
#define YYABORT 	return(1)
#define YYERROR		goto yyerrlab1
/* Like YYERROR except do call yyerror.
   This remains here temporarily to ease the
   transition to the new meaning of YYERROR, for GCC.
   Once GCC version 2 has supplanted version 1, this can go.  */
#define YYFAIL		goto yyerrlab
#define YYRECOVERING()  (!!yyerrstatus)
#define YYBACKUP(token, value) \
do								\
  if (yychar == YYEMPTY && yylen == 1)				\
    { yychar = (token), yylval = (value);			\
      yychar1 = YYTRANSLATE (yychar);				\
      YYPOPSTACK;						\
      goto yybackup;						\
    }								\
  else								\
    { yyerror ("syntax error: cannot back up"); YYERROR; }	\
while (0)

#define YYTERROR	1
#define YYERRCODE	256

#ifndef YYPURE
#define YYLEX		yylex()
#endif

#ifdef YYPURE
#ifdef YYLSP_NEEDED
#define YYLEX		yylex(&yylval, &yylloc)
#else
#define YYLEX		yylex(&yylval)
#endif
#endif

/* If nonreentrant, generate the variables here */

#ifndef YYPURE

int	yychar;			/*  the lookahead symbol		*/
YYSTYPE	yylval;			/*  the semantic value of the		*/
				/*  lookahead symbol			*/

#ifdef YYLSP_NEEDED
YYLTYPE yylloc;			/*  location data for the lookahead	*/
				/*  symbol				*/
#endif

int yynerrs;			/*  number of parse errors so far       */
#endif  /* not YYPURE */

#if YYDEBUG != 0
int yydebug;			/*  nonzero means print parse trace	*/
/* Since this is uninitialized, it does not stop multiple parsers
   from coexisting.  */
#endif

/*  YYINITDEPTH indicates the initial size of the parser's stacks	*/

#ifndef	YYINITDEPTH
#define YYINITDEPTH 200
#endif

/*  YYMAXDEPTH is the maximum size the stacks can grow to
    (effective only if the built-in stack extension method is used).  */

#if YYMAXDEPTH == 0
#undef YYMAXDEPTH
#endif

#ifndef YYMAXDEPTH
#define YYMAXDEPTH 10000
#endif

/* Prevent warning if -Wstrict-prototypes.  */
#ifdef __GNUC__
int yyparse (void);
#endif

#if __GNUC__ > 1		/* GNU C and GNU C++ define this.  */
#define __yy_bcopy(FROM,TO,COUNT)	__builtin_memcpy(TO,FROM,COUNT)
#else				/* not GNU C or C++ */
#ifndef __cplusplus

/* This is the most reliable way to avoid incompatibilities
   in available built-in functions on various systems.  */
static void
__yy_bcopy (from, to, count)
     char *from;
     char *to;
     int count;
{
  register char *f = from;
  register char *t = to;
  register int i = count;

  while (i-- > 0)
    *t++ = *f++;
}

#else /* __cplusplus */

/* This is the most reliable way to avoid incompatibilities
   in available built-in functions on various systems.  */
static void
__yy_bcopy (char *from, char *to, int count)
{
  register char *f = from;
  register char *t = to;
  register int i = count;

  while (i-- > 0)
    *t++ = *f++;
}

#endif
#endif

#line 184 "/usr/local/lib/bison.simple"
int
yyparse()
{
  register int yystate;
  register int yyn;
  register short *yyssp;
  register YYSTYPE *yyvsp;
  int yyerrstatus;	/*  number of tokens to shift before error messages enabled */
  int yychar1;		/*  lookahead token as an internal (translated) token number */

  short	yyssa[YYINITDEPTH];	/*  the state stack			*/
  YYSTYPE yyvsa[YYINITDEPTH];	/*  the semantic value stack		*/

  short *yyss = yyssa;		/*  refer to the stacks thru separate pointers */
  YYSTYPE *yyvs = yyvsa;	/*  to allow yyoverflow to reallocate them elsewhere */

#ifdef YYLSP_NEEDED
  YYLTYPE yylsa[YYINITDEPTH];	/*  the location stack			*/
  YYLTYPE *yyls = yylsa;
  YYLTYPE *yylsp;

#define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
#else
#define YYPOPSTACK   (yyvsp--, yyssp--)
#endif

  int yystacksize = YYINITDEPTH;

#ifdef YYPURE
  int yychar;
  YYSTYPE yylval;
  int yynerrs;
#ifdef YYLSP_NEEDED
  YYLTYPE yylloc;
#endif
#endif

  YYSTYPE yyval;		/*  the variable used to return		*/
				/*  semantic values from the action	*/
				/*  routines				*/

  int yylen;

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Starting parse\n");
#endif

  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = YYEMPTY;		/* Cause a token to be read.  */

  /* Initialize stack pointers.
     Waste one element of value and location stack
     so that they stay on the same level as the state stack.
     The wasted elements are never initialized.  */

  yyssp = yyss - 1;
  yyvsp = yyvs;
#ifdef YYLSP_NEEDED
  yylsp = yyls;
#endif

/* Push a new state, which is found in  yystate  .  */
/* In all cases, when you get here, the value and location stacks
   have just been pushed. so pushing a state here evens the stacks.  */
yynewstate:

  *++yyssp = yystate;

  if (yyssp >= yyss + yystacksize - 1)
    {
      /* Give user a chance to reallocate the stack */
      /* Use copies of these so that the &'s don't force the real ones into memory. */
      YYSTYPE *yyvs1 = yyvs;
      short *yyss1 = yyss;
#ifdef YYLSP_NEEDED
      YYLTYPE *yyls1 = yyls;
#endif

      /* Get the current used size of the three stacks, in elements.  */
      int size = yyssp - yyss + 1;

#ifdef yyoverflow
      /* Each stack pointer address is followed by the size of
	 the data in use in that stack, in bytes.  */
      yyoverflow("parser stack overflow",
		 &yyss1, size * sizeof (*yyssp),
		 &yyvs1, size * sizeof (*yyvsp),
#ifdef YYLSP_NEEDED
		 &yyls1, size * sizeof (*yylsp),
#endif
		 &yystacksize);

      yyss = yyss1; yyvs = yyvs1;
#ifdef YYLSP_NEEDED
      yyls = yyls1;
#endif
#else /* no yyoverflow */
      /* Extend the stack our own way.  */
      if (yystacksize >= YYMAXDEPTH)
	{
	  yyerror("parser stack overflow");
	  return 2;
	}
      yystacksize *= 2;
      if (yystacksize > YYMAXDEPTH)
	yystacksize = YYMAXDEPTH;
      yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
      __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
      yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
      __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
#ifdef YYLSP_NEEDED
      yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
      __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
#endif
#endif /* no yyoverflow */

      yyssp = yyss + size - 1;
      yyvsp = yyvs + size - 1;
#ifdef YYLSP_NEEDED
      yylsp = yyls + size - 1;
#endif

#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Stack size increased to %d\n", yystacksize);
#endif

      if (yyssp >= yyss + yystacksize - 1)
	YYABORT;
    }

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Entering state %d\n", yystate);
#endif

  goto yybackup;
 yybackup:

/* Do appropriate processing given the current state.  */
/* Read a lookahead token if we need one and don't already have one.  */
/* yyresume: */

  /* First try to decide what to do without reference to lookahead token.  */

  yyn = yypact[yystate];
  if (yyn == YYFLAG)
    goto yydefault;

  /* Not known => get a lookahead token if don't already have one.  */

  /* yychar is either YYEMPTY or YYEOF
     or a valid token in external form.  */

  if (yychar == YYEMPTY)
    {
#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Reading a token: ");
#endif
      yychar = YYLEX;
    }

  /* Convert token to internal form (in yychar1) for indexing tables with */

  if (yychar <= 0)		/* This means end of input. */
    {
      yychar1 = 0;
      yychar = YYEOF;		/* Don't call YYLEX any more */

#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Now at end of input.\n");
#endif
    }
  else
    {
      yychar1 = YYTRANSLATE(yychar);

#if YYDEBUG != 0
      if (yydebug)
	{
	  fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
	  /* Give the individual parser a way to print the precise meaning
	     of a token, for further debugging info.  */
#ifdef YYPRINT
	  YYPRINT (stderr, yychar, yylval);
#endif
	  fprintf (stderr, ")\n");
	}
#endif
    }

  yyn += yychar1;
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
    goto yydefault;

  yyn = yytable[yyn];

  /* yyn is what to do for this token type in this state.
     Negative => reduce, -yyn is rule number.
     Positive => shift, yyn is new state.
       New state is final state => don't bother to shift,
       just return success.
     0, or most negative number => error.  */

  if (yyn < 0)
    {
      if (yyn == YYFLAG)
	goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  else if (yyn == 0)
    goto yyerrlab;

  if (yyn == YYFINAL)
    YYACCEPT;

  /* Shift the lookahead token.  */

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
#endif

  /* Discard the token being shifted unless it is eof.  */
  if (yychar != YYEOF)
    yychar = YYEMPTY;

  *++yyvsp = yylval;
#ifdef YYLSP_NEEDED
  *++yylsp = yylloc;
#endif

  /* count tokens shifted since error; after three, turn off error status.  */
  if (yyerrstatus) yyerrstatus--;

  yystate = yyn;
  goto yynewstate;

/* Do the default action for the current state.  */
yydefault:

  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;

/* Do a reduction.  yyn is the number of a rule to reduce with.  */
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen]; /* implement default value of the action */

#if YYDEBUG != 0
  if (yydebug)
    {
      int i;

      fprintf (stderr, "Reducing via rule %d (line %d), ",
	       yyn, yyrline[yyn]);

      /* Print the symbols being reduced, and their result.  */
      for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
	fprintf (stderr, "%s ", yytname[yyrhs[i]]);
      fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
    }
#endif


  switch (yyn) {

case 3:
#line 59 "grammar.y"
{ strcat(yyvsp[-1],"\\notes"); 
                         if(tiearmed) { tiearmed=0; strcat(yyvsp[-1],"\\tten0"); }
                         if(tiepend) { tiepend=0; tiearmed=1; }
                           printf("%s", strcat(strcat(yyvsp[-1],yyvsp[0]),suspmorceau)); 
                           free(yyvsp[-1]); free(yyvsp[0]);
                        ;
    break;}
case 4:
#line 65 "grammar.y"
{ strcat(yyvsp[-2],"\\notes"); 
                         if(tiearmed) { tiearmed=0; strcat(yyvsp[-2],"\\tten0"); }
                         if(tiepend) { tiepend=0; tiearmed=1; }
                           printf("%s",strcat(strcat(strcat(strcat(strcat
                                (yyvsp[-2],yyvsp[-1]),xbarre),"\\notes"),yyvsp[0]),suspmorceau)); 
                           free(yyvsp[-2]); free(yyvsp[-1]); free(yyvsp[0]);
                        ;
    break;}
case 5:
#line 72 "grammar.y"
{ printf("%s%%\n",yyvsp[0]); free(yyvsp[0]);;
    break;}
case 6:
#line 75 "grammar.y"
{ strcat(yyvsp[-1],"\\notes"); 
                     if(tiearmed) { tiearmed=0; strcat(yyvsp[-1],"\\tten0"); }
                     if(tiepend) { tiepend=0; tiearmed=1; }
                     printf("%s", strcat(yyvsp[-1],yyvsp[0])); free(yyvsp[-1]); free(yyvsp[0]);
                     yyval=malloc(MAXLEN); strcpy(yyval,reprmorceau); 
                   ;
    break;}
case 7:
#line 81 "grammar.y"
{ strcat(yyvsp[-2],"\\notes"); 
                     if(tiearmed) { tiearmed=0; strcat(yyvsp[-2],"\\tten0"); }
                     if(tiepend) { tiepend=0; tiearmed=1; }
                     printf("%s", strcat(strcat(strcat(strcat
                     (yyvsp[-2],yyvsp[-1]),xbarre),"\\notes"),yyvsp[0])); 
                     free(yyvsp[-2]); free(yyvsp[-1]); free(yyvsp[0]);
                     yyval=malloc(MAXLEN); strcpy(yyval,reprmorceau); 
                        ;
    break;}
case 8:
#line 89 "grammar.y"
{yyval=malloc(MAXLEN);
              if (firstline) { firstline=0;  
                               strcpy(yyval,"\\debutmorceau\n\\setelemq{1.2}%\n"); 
                             }
              else             strcpy(yyval,yyvsp[0]); 
             ;
    break;}
case 9:
#line 95 "grammar.y"
{ yyval = malloc(MAXLEN); 
                          strcpy(yyval,yyvsp[0]); strcat(yyval,yyvsp[-1]); free(yyvsp[-1]);
                   ;
    break;}
case 10:
#line 98 "grammar.y"
{ prelen=strcspn(yyvsp[0],"_") ;
                         strncpy(num,yyvsp[0],prelen) ; strcpy(num+prelen,"");
                         strcpy(den,yyvsp[0]+prelen+1) ;
                         yyval=malloc(MAXLEN);
                         strcat(strcat(strcat(strcat(strcat(strcpy(
                              yyval,"\\generalmeter{\\meterfrac{"),
                                   num),"}{"),den),"}}\n"),yyvsp[-1]);
                         free(yyvsp[-1]); free(yyvsp[0]); 
                       ;
    break;}
case 11:
#line 107 "grammar.y"
{ yyval = strcat(yyvsp[-1],yyvsp[0]);
                     ;
    break;}
case 12:
#line 109 "grammar.y"
{ 
              if (yyvsp[0]==first || yyvsp[0]==second ) yyval = strcat(strcat(yyvsp[-2],yyvsp[0]),yyvsp[-1]);
              else { yyval = strcat(yyvsp[-2],yyvsp[-1]); nn=strlen(yyvsp[0]); 
                     if(nn==1) {strcat(yyval,"\\notes\\Uptext{"); strcat(yyval,yyvsp[0]);
                                strcat(yyval,"}\\enotes");
                                }
                     else { strcat(yyval,"\\notes\\Uptext{$\\vert$ time ");
                            strncat(yyval,yyvsp[0],1); strcat(yyval," on part(s) ");
                            strncat(yyval,yyvsp[0]+1,1);
                            for(i=3; i <= (int) nn; i++)
                               {strcat(yyval,",");strncat(yyval,yyvsp[0]+i-1,1);
                               }    
                             strcat(yyval,"}\\enotes");
                           }                
                     free(yyvsp[0]);
                   }
                         ;
    break;}
case 13:
#line 126 "grammar.y"
{ 
              if (yyvsp[-1]==first || yyvsp[-1]==second ) yyval = strcat(strcat(yyvsp[-2],yyvsp[-1]),yyvsp[0]);
              else { yyval = strcat(yyvsp[-2],yyvsp[0]); nn=strlen(yyvsp[-1]); 
                     if(nn==1) {strcat(yyval,"\\notes\\Uptext{"); strcat(yyval,yyvsp[-1]);
                                strcat(yyval,"}\\enotes");
                                }
                     else { strcat(yyval,"\\notes\\Uptext{$\\vert$ time ");
                            strncat(yyval,yyvsp[-1],1); strcat(yyval," on part(s) ");
                            strncat(yyval,yyvsp[-1]+1,1);
                            for(i=3; i <= (int) nn; i++)
                               {strcat(yyval,",");strncat(yyval,yyvsp[-1]+i-1,1);
                               }    
                             strcat(yyval,"}\\enotes");
                          }                
                     free(yyvsp[-1]);
                   }
                         ;
    break;}
case 14:
#line 143 "grammar.y"
{ 
           if (yyvsp[0]==first || yyvsp[0]==second) yyval = strcat(strcat(yyvsp[-1],yyvsp[0]),"\\xbarre");
           else { yyval = yyvsp[-1]; nn=strlen(yyvsp[0]);
                  if(nn==1) { strcat(yyval,"\\notes\\Uptext{repeat "); 
                              strcat(yyval,yyvsp[0]); strcat(yyval,"}\\enotes");
                            }
                  else {strcat(yyval,"\\notes\\Uptext{$\\vert$ time "); 
                        strncat(yyval,yyvsp[0],1);
                        strcat(yyval," on part(s) "); strncat(yyval,yyvsp[0]+1,1);
                        for(i=3; i <= (int) nn; i++)
                            {strcat(yyval,",");strncat(yyval,yyvsp[0]+i-1,1);
                            }    
                         strcat(yyval,"}\\enotes");
                        }                
                  free(yyvsp[0]);
                 }
                     ;
    break;}
case 15:
#line 160 "grammar.y"
{ yyval = yyvsp[-1]; free(yyvsp[0]);
                     ;
    break;}
case 16:
#line 162 "grammar.y"
{ yyval = insertetn(yyvsp[-1]); free(yyvsp[0]);
                     ;
    break;}
case 17:
#line 164 "grammar.y"
{ yyval = strcat(yyvsp[-1],"\\notes"); 
                         if(tiearmed) { tiearmed=0; strcat(yyval,"\\tten0"); }
                         if(tiepend) { tiepend=0; tiearmed=1; }
                         strcat(yyval,yyvsp[0]); free(yyvsp[0]); 
                        ;
    break;}
case 18:
#line 169 "grammar.y"
{ yyval = strcat(yyvsp[-2],"\\notes"); 
                         if(tiearmed) { tiearmed=0; strcat(yyval,"\\tten0"); }
                         if(tiepend) { tiepend=0; tiearmed=1; }
                         strcat(yyval,yyvsp[-1]); strcat(yyval,xbarre); 
                         strcat(yyval,"\\notes"); strcat(yyval,yyvsp[0]); 
                         free(yyvsp[-1]); free(yyvsp[0]);
                        ;
    break;}
case 19:
#line 176 "grammar.y"
{ yyval=strcat(yyvsp[-1],"\\notes\\Uptext{$\\vert$}"); ;
    break;}
case 20:
#line 177 "grammar.y"
{ yyval=yyvsp[-1]; ;
    break;}
case 21:
#line 180 "grammar.y"
{yyval = strcat(strcat(yyvsp[-1],"\\enotes"),yyvsp[0]); 
                ;
    break;}
case 22:
#line 182 "grammar.y"
{ yyval = inserttie(yyvsp[-2],yyvsp[-1]);
                      strcat(strcat(yyval,"\\enotes"),yyvsp[0]); 
                      tiepend=1; free(yyvsp[-2]); free(yyvsp[-1]); 
                    ;
    break;}
case 23:
#line 186 "grammar.y"
{ yyval = inserttie(yyvsp[-1],yyvsp[0]);
                      strcat(strcat(yyval,"\\enotes"),alaligne); 
                      tiepend=1; free(yyvsp[-1]); free(yyvsp[0]); 
                    ;
    break;}
case 24:
#line 190 "grammar.y"
{ yyval = inserttie(yyvsp[-1],yyvsp[0]);
                      strcat(strcat(yyval,"\\enotes"),setdoublebar); 
                      tiepend=1; free(yyvsp[-1]); free(yyvsp[0]); 
                    ;
    break;}
case 25:
#line 194 "grammar.y"
{ yyval = strcat(strcat(yyvsp[-2],"\\enotes"),yyvsp[0]); 
                     ;
    break;}
case 26:
#line 196 "grammar.y"
{ 
                         yyval = inserttie(yyvsp[-2],yyvsp[-1]);
                         strcat(strcat(yyval,"\\enotes"),yyvsp[0]); 
                         tiepend=1; free(yyvsp[-2]); free(yyvsp[-1]); 
                        ;
    break;}
case 27:
#line 201 "grammar.y"
{yyval = insertetn(yyvsp[-2]); strcat(yyval,yyvsp[0]); free(yyvsp[0]);
                      ;
    break;}
case 28:
#line 203 "grammar.y"
{yyval = inserttie(yyvsp[-2],yyvsp[-1]); insertetn(yyval);   
                          strcat(yyval,"\\tten0"); strcat(yyval,yyvsp[0]); 
                          free(yyvsp[-2]); free(yyvsp[-1]); free(yyvsp[0]); 
                         ;
    break;}
case 29:
#line 207 "grammar.y"
{yyval = strcat(yyvsp[-3],yyvsp[-2]); strcat (yyval,yyvsp[-1]);
                            strcat(yyval,"\\enotes"); strcat(yyval,yyvsp[0]);
                            free(yyvsp[-2]); free(yyvsp[-1]);
                           ;
    break;}
case 30:
#line 211 "grammar.y"
{yyval = strcat(yyvsp[-2],yyvsp[-1]);
                             strcat(yyval,"\\enotes"); strcat(yyval,yyvsp[0]);
                             free(yyvsp[-1]); 
                      ;
    break;}
case 31:
#line 217 "grammar.y"
{yyval = strcat(strcat(yyvsp[-1],"\\enotes"),alaligne); 
                    strcat(yyval,suspmorceau);
                   ;
    break;}
case 32:
#line 220 "grammar.y"
{ yyval = inserttie(yyvsp[-2],yyvsp[-1]);
                       strcat(strcat(yyval,"\\enotes"),alaligne); 
                       strcat(yyval,suspmorceau);
                       tiepend=1; free(yyvsp[-2]); free(yyvsp[-1]); 
                      ;
    break;}
case 33:
#line 225 "grammar.y"
{ yyval = inserttie(yyvsp[-1],yyvsp[0]);
                      strcat(strcat(yyval,"\\enotes"),alaligne); 
                      strcat(yyval,suspmorceau);
                      tiepend=1; free(yyvsp[-1]); free(yyvsp[0]); 
                     ;
    break;}
case 34:
#line 230 "grammar.y"
{ yyval = strcat(strcat(yyvsp[-2],"\\enotes"),alaligne); 
                         strcat(yyval,suspmorceau);
                       ;
    break;}
case 35:
#line 233 "grammar.y"
{ 
                           yyval = inserttie(yyvsp[-2],yyvsp[-1]);
                           strcat(strcat(yyval,"\\enotes"),alaligne); 
                           strcat(yyval,suspmorceau);
                           tiepend=1; free(yyvsp[-2]); free(yyvsp[-1]); 
                          ;
    break;}
case 36:
#line 239 "grammar.y"
{yyval = insertetn(yyvsp[-2]); strcat(yyval,yyvsp[0]); free(yyvsp[0]);
                       ;
    break;}
case 37:
#line 241 "grammar.y"
{yyval = inserttie(yyvsp[-2],yyvsp[-1]); insertetn(yyval);   
                           strcat(yyval,"\\tten0"); strcat(yyval,yyvsp[0]); 
                           free(yyvsp[-2]); free(yyvsp[-1]); free(yyvsp[0]); 
                          ;
    break;}
case 38:
#line 245 "grammar.y"
{yyval = strcat(yyvsp[-3],yyvsp[-2]); strcat (yyval,yyvsp[-1]);
                              strcat(yyval,"\\enotes"); strcat(yyval,alaligne);
                              strcat(yyval,suspmorceau);
                              free(yyvsp[-2]); free(yyvsp[-1]);
                             ;
    break;}
case 39:
#line 250 "grammar.y"
{yyval = strcat(yyvsp[-2],yyvsp[-1]); 
                         strcat(yyval,"\\enotes"); strcat(yyval,alaligne);
                         strcat(yyval,suspmorceau);
                         free(yyvsp[-1]); 
                        ;
    break;}
case 40:
#line 257 "grammar.y"
{yyval = yyvsp[-1]; strcat(strcat(yyval,"\\enotes"),yyvsp[0]);
                 ;
    break;}
case 41:
#line 259 "grammar.y"
{yyval = inserttie(yyvsp[-2],yyvsp[-1]);
                     strcat(strcat(yyval,"\\enotes"),yyvsp[0]); 
                     tiepend=1; free(yyvsp[-2]); free(yyvsp[-1]); 
                    ;
    break;}
case 42:
#line 263 "grammar.y"
{yyval = inserttie(yyvsp[-1],yyvsp[0]);
                     strcat(strcat(yyval,"\\enotes"),xbarre); 
                     tiepend=1; free(yyvsp[-1]); free(yyvsp[0]); 
                    ;
    break;}
case 43:
#line 267 "grammar.y"
{yyval = inserttie(yyvsp[-1],yyvsp[0]);
                     strcat(strcat(yyval,"\\enotes"),setdoublebar); 
                     strcat(yyval,xbarre);
                     tiepend=1; free(yyvsp[-1]); free(yyvsp[0]); 
                    ;
    break;}
case 44:
#line 272 "grammar.y"
{yyval = inserttie(yyvsp[-1],yyvsp[0]);
                     strcat(strcat(yyval,"\\enotes"),leftrepeatsymbol); 
                     tiepend=1; free(yyvsp[-1]); free(yyvsp[0]); 
                    ;
    break;}
case 45:
#line 276 "grammar.y"
{yyval = yyvsp[-2]; strcat(strcat(yyval,"\\enotes"),yyvsp[0]);
                     ;
    break;}
case 46:
#line 278 "grammar.y"
{yyval = inserttie(yyvsp[-2],yyvsp[-1]);
                         strcat(strcat(yyval,"\\enotes"),yyvsp[0]); 
                         tiepend=1; free(yyvsp[-2]); free(yyvsp[-1]); 
                        ;
    break;}
case 47:
#line 282 "grammar.y"
{yyval = strcat(insertetn(yyvsp[-2]),yyvsp[0]); free(yyvsp[0]);
                      ;
    break;}
case 48:
#line 284 "grammar.y"
{yyval = inserttie(yyvsp[-2],yyvsp[-1]); 
                          strcat(strcat(insertetn(yyval),"\\tten0"),yyvsp[0]); 
                          free(yyvsp[-2]); free(yyvsp[-1]); free(yyvsp[0]);
                         ;
    break;}
case 49:
#line 288 "grammar.y"
{yyval = strcat(yyvsp[-3],yyvsp[-2]); strcat (yyval,yyvsp[-1]);
                             strcat(yyval,"\\enotes"); strcat(yyval,yyvsp[0]);
                             free(yyvsp[-2]); free(yyvsp[-1]);
                           ;
    break;}
case 50:
#line 292 "grammar.y"
{yyval = strcat(yyvsp[-2],yyvsp[-1]); 
                             strcat(yyval,"\\enotes"); strcat(yyval,yyvsp[0]);
                             free(yyvsp[-1]); 
                     ;
    break;}
case 51:
#line 299 "grammar.y"
{ yyval=yyvsp[0]; ;
    break;}
case 52:
#line 300 "grammar.y"
{ yyval = strcat(yyvsp[-1],yyvsp[0]); free(yyvsp[0]); ;
    break;}
case 53:
#line 301 "grammar.y"
{ yyval=inserttie(yyvsp[-2],yyvsp[-1]); strcat(yyval,"\\tten0");
                           strcat(yyval,yyvsp[0]); free(yyvsp[-2]); free(yyvsp[-1]); free(yyvsp[0]);
                         ;
    break;}
case 54:
#line 306 "grammar.y"
{ yyval=yyvsp[0]; ;
    break;}
case 55:
#line 307 "grammar.y"
{ yyval=yyvsp[0]; ;
    break;}
case 56:
#line 308 "grammar.y"
{ yyval=yyvsp[0]; ;
    break;}
case 57:
#line 309 "grammar.y"
{ yyval = strcat(insertetn(yyvsp[-2]),yyvsp[-1]);
                           free(yyvsp[-1]);
                         ;
    break;}
case 58:
#line 314 "grammar.y"
{ yyval =  malloc(MAXLEN); strcpy(yyval,"\\");
                              strcat(strcat(strcat(yyval,yyvsp[-1]),"p "),yyvsp[-2]);
                      ;
    break;}
case 59:
#line 317 "grammar.y"
{ yyval =  malloc(MAXLEN); strcpy(yyval,"\\");
                          strcat(strcat(yyval,yyvsp[0]),yyvsp[-1]); 
                  ;
    break;}
case 60:
#line 320 "grammar.y"
{ yyval=insertthtrip(yyvsp[-1],yyvsp[0]); free(yyvsp[-1]); 
                     ;
    break;}
case 61:
#line 324 "grammar.y"
{ yyval =  malloc(MAXLEN); strcpy(yyval,"\\b");
         strcat(strcat(strcat(strcat(strcat(yyval,yyvsp[-1])," bb3"),"\\b"),yyvsp[-3]),"p");
                            ;
    break;}
case 62:
#line 327 "grammar.y"
{ yyval = malloc(MAXLEN); strcpy(yyval,"\\b");
         strcat(strcat(strcat(strcat(yyval,yyvsp[0])," bb3"),"\\b"),yyvsp[-2]);
                            ;
    break;}
case 63:
#line 330 "grammar.y"
{ yyval = yyvsp[-4]; 
            strcat(strcat(strcat(insert(yyval,yyvsp[-1]),"\\b"),yyvsp[-3]),"p"); 
            lbhead = strchr(yyval,' ')-yyval;
            if( lbhead > 6) yyval = shorten(yyval);
                                   ;
    break;}
case 64:
#line 335 "grammar.y"
{ yyval = yyvsp[-3];
            strcat(strcat(insert(yyval,yyvsp[0]),"\\b"),yyvsp[-2]);
            lbhead = strchr(yyval,' ')-yyval;
            if( lbhead > 6) yyval = shorten(yyval);
                               ;
    break;}
case 65:
#line 340 "grammar.y"
{yyval = yyvsp[-5];
              strcat(strcat(strcat(inserts(yyvsp[-5],yyvsp[-1],yyvsp[-4]),"\\b"),yyvsp[-3]),"p");
              lbhead = strchr(yyval,' ')-yyval;
              if( lbhead > 6) yyval = shorten(yyval); free(yyvsp[-4]);     
                                       ;
    break;}
case 66:
#line 345 "grammar.y"
{yyval = yyvsp[-4];
              strcat(strcat(inserts(yyvsp[-4],yyvsp[0],yyvsp[-3]),"\\b"),yyvsp[-2]);
              lbhead = strchr(yyval,' ')-yyval;
              if( lbhead > 6) yyval = shorten(yyval); free(yyvsp[-3]);
                                   ;
    break;}
case 67:
#line 350 "grammar.y"
{yyval = yyvsp[-5];
              strcat(strcat(strcat(insertt(yyvsp[-5],yyvsp[-1],yyvsp[-4]),"\\b"),yyvsp[-3]),"p");
              lbhead = strchr(yyval,' ')-yyval;
              if( lbhead > 6) yyval = shorten(yyval); free(yyvsp[-4]);
                                       ;
    break;}
case 68:
#line 355 "grammar.y"
{yyval = yyvsp[-4];
              strcat(strcat(insertt(yyvsp[-4],yyvsp[0],yyvsp[-3]),"\\b"),yyvsp[-2]);
              lbhead = strchr(yyval,' ')-yyval;
              if( lbhead > 6) yyval = shorten(yyval);free(yyvsp[-3]);
                                   ;
    break;}
case 69:
#line 360 "grammar.y"
{ yyval = yyvsp[-3]; 
            if(yyvsp[-1]==ql || yyvsp[-1] == hh || yyvsp[-1] == wh) { yyval=yyvsp[-3]; free(yyvsp[-2]);
                 printf("%s","%\n% There is a tab or beam indicator missing."
                        " Will ignore this note.\n");
                                                 }
            else {
                  strcat(strcat(strcat(insert(yyval,yyvsp[-1]),"\\b"),yyvsp[-2]),"p"); 
                  lbhead = strchr(yyval,' ')-yyval;
                  if( lbhead > 6) yyval = shorten(yyval);
                 }                  ;
    break;}
case 70:
#line 370 "grammar.y"
{ yyval = yyvsp[-2];
            if(yyvsp[0] == ql || yyvsp[0] == hh || yyvsp[0] == wh) { yyval=yyvsp[-2]; free(yyvsp[-1]);
                 printf("%s","%\n% There is a tab or beam indicator missing."
                        " Will ignore this note.\n");
                                                 }
            else {
                  strcat(strcat(insert(yyval,yyvsp[0]),"\\b"),yyvsp[-1]);
                  lbhead = strchr(yyval,' ')-yyval;
                  if( lbhead > 6) yyval = shorten(yyval);
                 }              ;
    break;}
case 71:
#line 380 "grammar.y"
{yyval = yyvsp[-4];
            if(yyvsp[-1] == ql || yyvsp[-1] == hh || yyvsp[-1] == wh) { yyval=yyvsp[-4]; free(yyvsp[-3]);
                 printf("%s","%\n% There is a tab or beam indicator missing."
                        " Will ignore this note.\n");
                                                 }
            else {
                  strcat(strcat(strcat(inserts(yyvsp[-4],yyvsp[-1],yyvsp[-3]),"\\b"),yyvsp[-2]),"p");
                  lbhead = strchr(yyval,' ')-yyval;
                  if( lbhead > 6) yyval = shorten(yyval); free(yyvsp[-3]);     
                 }                      ;
    break;}
case 72:
#line 390 "grammar.y"
{yyval = yyvsp[-3];
            if(yyvsp[0] == ql || yyvsp[0] == hh || yyvsp[0] == wh) { yyval=yyvsp[-3]; free(yyvsp[-2]);
                 printf("%s","%\n% There is a tab or beam indicator missing."
                        " Will ignore this note.\n");
                                                 }
            else {
                  strcat(strcat(inserts(yyvsp[-3],yyvsp[0],yyvsp[-2]),"\\b"),yyvsp[-1]);
                  lbhead = strchr(yyval,' ')-yyval;
                  if( lbhead > 6) yyval = shorten(yyval); free(yyvsp[-2]);
                 }                  ;
    break;}
case 73:
#line 400 "grammar.y"
{yyval = yyvsp[-4];
            if(yyvsp[-1] == ql || yyvsp[-1] == hh || yyvsp[-1] == wh) { yyval=yyvsp[-4]; free(yyvsp[-3]);
                 printf("%s","%\n% There is a tab or beam indicator missing."
                        " Will ignore this note.\n");
                                                 }
            else {
                  strcat(strcat(strcat(insertt(yyvsp[-4],yyvsp[-1],yyvsp[-3]),"\\b"),yyvsp[-2]),"p");
                  lbhead = strchr(yyval,' ')-yyval;
                  if( lbhead > 6) yyval = shorten(yyval); free(yyvsp[-3]);
                 }                      ;
    break;}
case 74:
#line 410 "grammar.y"
{yyval = yyvsp[-3];
            if(yyvsp[0] == ql || yyvsp[0] == hh || yyvsp[0] == wh) { yyval=yyvsp[-3]; free(yyvsp[-2]);
                 printf("%s","%\n% There is a tab or beam indicator missing."
                        " Will ignore this note.\n");
                                                 }
            else {
                  strcat(strcat(insertt(yyvsp[-3],yyvsp[0],yyvsp[-2]),"\\b"),yyvsp[-1]);
                  lbhead = strchr(yyval,' ')-yyval;
                  if( lbhead > 6) yyval = shorten(yyval);free(yyvsp[-2]);
                 }                  ;
    break;}
case 75:
#line 420 "grammar.y"
{ yyval=inserttrip(yyvsp[-1],yyvsp[0]); free(yyvsp[-1]);
                       ;
    break;}
case 76:
#line 425 "grammar.y"
{ yyval = yyvsp[0]; ;
    break;}
case 77:
#line 426 "grammar.y"
{ yyval = malloc(MAXLEN); strcpy(yyval,yyvsp[0]); ;
    break;}
case 78:
#line 427 "grammar.y"
{ yyval = malloc(MAXLEN); strcpy(yyval,yyvsp[0]); ;
    break;}
case 79:
#line 428 "grammar.y"
{ yyval = malloc(MAXLEN); 
                  if      ( yyvsp[0]==first )  strcpy(yyval,"\\Uptext{$\\vert$ 1.}");
                  else if ( yyvsp[0]==second ) strcpy(yyval,"\\Uptext{$\\vert$ 2.}");
                  else  {   nn=strlen(yyvsp[0]);
                    if(nn==1) { strcpy(yyval,"\\Uptext{repeat "); 
                                strcat(yyval,yyvsp[0]); strcat(yyval,"}"); 
                              }
                    else      { strcpy(yyval,"\\Uptext{$\\vert$ time "); 
                                strncat(yyval,yyvsp[0],1);
                                strcat(yyval," on part(s) "); strncat(yyval,yyvsp[0]+1,1);
                                for(i=3; i <= (int) nn; i++)
                                   {strcat(yyval,", and ");strncat(yyval,yyvsp[0]+i-1,1);
                                   }    
                                strcat(yyval,"}"); 
                              }                
                    free(yyvsp[0]);
                         }
                 ;
    break;}
case 80:
#line 446 "grammar.y"
{ yyval = strcat(yyvsp[-1],yyvsp[0]); free(yyvsp[0]);;
    break;}
case 81:
#line 450 "grammar.y"
{ yyval = yyvsp[0]; ;
    break;}
case 82:
#line 451 "grammar.y"
{ yyval = yyvsp[-1]; ;
    break;}
case 83:
#line 452 "grammar.y"
{ yyval = yyvsp[0]; ;
    break;}
case 84:
#line 453 "grammar.y"
{ yyval = yyvsp[-1] ;
    break;}
case 85:
#line 456 "grammar.y"
{ yyval=malloc(MAXLEN);    
               if( ntext != 4 || strlen(yyvsp[0]) > 0) 
               { strcat(strcat(strcpy(yyval,"\\line{"),yyvsp[0])," \\hss}\n"); free(yyvsp[0]);
               }
               else yyval=yyvsp[0];
            ;
    break;}
case 86:
#line 462 "grammar.y"
{ yyval=malloc(MAXLEN);    
           if(ntext > 4){strcat(strcat(strcpy(yyval,"\\line{"),yyvsp[0])," \\hss}\n");
                            free(yyvsp[0]);
                        }
           else if(ntext == 4){ if(strlen(yyvsp[0]) > 0)
                                     {strcpy(yyval,"\\pagenumbers\\pageno="); 
                                      strcat(strcat(yyval,yyvsp[0]),"\n"); free(yyvsp[0]);
                                     }
                                else { strcpy(yyval,"%\n"); free(yyvsp[0]); 
                                     }
                              }
           else               {strcat(strcat(strcpy(yyval,"%"),yyvsp[0]),"\n"); 
                               free(yyvsp[0]); 
                              }
               ;
    break;}
case 87:
#line 477 "grammar.y"
{ yyval=malloc(MAXLEN); 
                        strcat(strcpy(yyval,"\\line{\\moyen "),yyvsp[-2]);    
                        strcat(strcat(strcat(strcat(strcat
                        (yyval," \\hss\n\\rm "),yyvsp[-1])," \\hss "),yyvsp[0]),"}\n\\bigskip\n"); 
                        free(yyvsp[-2]); free(yyvsp[-1]); free(yyvsp[0]); 
               ;
    break;}
case 88:
#line 485 "grammar.y"
{yyval=yyvsp[0]; ntext++; ;
    break;}
case 89:
#line 488 "grammar.y"
{yyval=yyvsp[0]; ntext++; ;
    break;}
}
   /* the action file gets copied in in place of this dollarsign */
#line 457 "/usr/local/lib/bison.simple"

  yyvsp -= yylen;
  yyssp -= yylen;
#ifdef YYLSP_NEEDED
  yylsp -= yylen;
#endif

#if YYDEBUG != 0
  if (yydebug)
    {
      short *ssp1 = yyss - 1;
      fprintf (stderr, "state stack now");
      while (ssp1 != yyssp)
	fprintf (stderr, " %d", *++ssp1);
      fprintf (stderr, "\n");
    }
#endif

  *++yyvsp = yyval;

#ifdef YYLSP_NEEDED
  yylsp++;
  if (yylen == 0)
    {
      yylsp->first_line = yylloc.first_line;
      yylsp->first_column = yylloc.first_column;
      yylsp->last_line = (yylsp-1)->last_line;
      yylsp->last_column = (yylsp-1)->last_column;
      yylsp->text = 0;
    }
  else
    {
      yylsp->last_line = (yylsp+yylen-1)->last_line;
      yylsp->last_column = (yylsp+yylen-1)->last_column;
    }
#endif

  /* Now "shift" the result of the reduction.
     Determine what state that goes to,
     based on the state we popped back to
     and the rule number reduced by.  */

  yyn = yyr1[yyn];

  yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
    yystate = yytable[yystate];
  else
    yystate = yydefgoto[yyn - YYNTBASE];

  goto yynewstate;

yyerrlab:   /* here on detecting error */

  if (! yyerrstatus)
    /* If not already recovering from an error, report this error.  */
    {
      ++yynerrs;

#ifdef YYERROR_VERBOSE
      yyn = yypact[yystate];

      if (yyn > YYFLAG && yyn < YYLAST)
	{
	  int size = 0;
	  char *msg;
	  int x, count;

	  count = 0;
	  /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
	  for (x = (yyn < 0 ? -yyn : 0);
	       x < (sizeof(yytname) / sizeof(char *)); x++)
	    if (yycheck[x + yyn] == x)
	      size += strlen(yytname[x]) + 15, count++;
	  msg = (char *) malloc(size + 15);
	  if (msg != 0)
	    {
	      strcpy(msg, "parse error");

	      if (count < 5)
		{
		  count = 0;
		  for (x = (yyn < 0 ? -yyn : 0);
		       x < (sizeof(yytname) / sizeof(char *)); x++)
		    if (yycheck[x + yyn] == x)
		      {
			strcat(msg, count == 0 ? ", expecting `" : " or `");
			strcat(msg, yytname[x]);
			strcat(msg, "'");
			count++;
		      }
		}
	      yyerror(msg);
	      free(msg);
	    }
	  else
	    yyerror ("parse error; also virtual memory exceeded");
	}
      else
#endif /* YYERROR_VERBOSE */
	yyerror("parse error");
    }

  goto yyerrlab1;
yyerrlab1:   /* here on error raised explicitly by an action */

  if (yyerrstatus == 3)
    {
      /* if just tried and failed to reuse lookahead token after an error, discard it.  */

      /* return failure if at end of input */
      if (yychar == YYEOF)
	YYABORT;

#if YYDEBUG != 0
      if (yydebug)
	fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
#endif

      yychar = YYEMPTY;
    }

  /* Else will try to reuse lookahead token
     after shifting the error token.  */

  yyerrstatus = 3;		/* Each real token shifted decrements this */

  goto yyerrhandle;

yyerrdefault:  /* current state does not do anything special for the error token. */

#if 0
  /* This is wrong; only states that explicitly want error tokens
     should shift them.  */
  yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  if (yyn) goto yydefault;
#endif

yyerrpop:   /* pop the current state because it cannot handle the error token */

  if (yyssp == yyss) YYABORT;
  yyvsp--;
  yystate = *--yyssp;
#ifdef YYLSP_NEEDED
  yylsp--;
#endif

#if YYDEBUG != 0
  if (yydebug)
    {
      short *ssp1 = yyss - 1;
      fprintf (stderr, "Error: state stack now");
      while (ssp1 != yyssp)
	fprintf (stderr, " %d", *++ssp1);
      fprintf (stderr, "\n");
    }
#endif

yyerrhandle:

  yyn = yypact[yystate];
  if (yyn == YYFLAG)
    goto yyerrdefault;

  yyn += YYTERROR;
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
    goto yyerrdefault;

  yyn = yytable[yyn];
  if (yyn < 0)
    {
      if (yyn == YYFLAG)
	goto yyerrpop;
      yyn = -yyn;
      goto yyreduce;
    }
  else if (yyn == 0)
    goto yyerrpop;

  if (yyn == YYFINAL)
    YYACCEPT;

#if YYDEBUG != 0
  if (yydebug)
    fprintf(stderr, "Shifting error token, ");
#endif

  *++yyvsp = yylval;
#ifdef YYLSP_NEEDED
  *++yylsp = yylloc;
#endif

  yystate = yyn;
  goto yynewstate;
}
#line 491 "grammar.y"


#include <stdio.h>

int yyerror(char *s){printf("%s\n",s); return 0;}

#ifdef MAC
#include "Main.h" 
#endif

int main (int argc, char **argv)

{
	int retcode;
	char *infile;
	char *outfile;
	int inopened=0;
	int outopened=0;

       firstline=1; ntext=0; tiepend=0; tiearmed=0;

	if (argc > 1)	/* if a file was named, open it for reading*/
	{
		if(! strncmp(argv[1],"help",4)) 
		{
			printf("%s","bmw2tex [input [output]]\n"
				"The extension .bmw will be added to the input"
				" file name if not already present\n"
				"The extension .tex will be added to the output"
				" file name if not already present\n"
				"If an output file name is not given,"
				" the input file name with .bmw replaced\n by"
				" .tex will be used.\n"
				"If no file names are given, stdin and stdout"
				" will be used.\n");
			exit(0);
              }        

              infile=(char *) malloc(129); strcpy(infile,argv[1]);
              if(strcmp(infile+strlen(infile)-4,".bmw") ) 
			strcat(infile,".bmw");

		if (freopen (infile, "r", stdin) == (FILE *) NULL)
		{
			fprintf (stderr, "cannot open %s\n", infile);
			return 1;	/* terminate abnormally */
		}
              else inopened=1;
		fprintf (stderr, "processing %s...\n", infile);
           
		if(argc > 2) /* if a second file was named, open it for writing*/
		{
              	outfile= (char *) malloc(129); strcpy(outfile,argv[2]);
              	if(strcmp(outfile+strlen(outfile)-4,".tex"))
				strcat(outfile,".tex");
		}
		else
		{
              	outfile= (char *) malloc(129); strcpy(outfile,""); 
			strncat(outfile,infile,strlen(infile)-4);
			strcat(outfile,".tex");			            
		}

		if (freopen (outfile, "w", stdout) == (FILE *) NULL)
		{
			fprintf (stderr, "cannot open %s\n", outfile);
			return 1;	/* terminate abnormally */
		}
              else outopened=1;
		fprintf (stderr, "writing %s...\n", outfile);
              free(infile); free(outfile);
	}

/* standard initial text output */
printf("%s\n","%&bagpipe\n\\input bagpipe\n%");
printf("%s\n","% Converted from BMW format by bmw2tex\n%");
printf("%s\n","\\def\\freqbarno{9999}");
printf("%s\n","\\maxlinesinpage=12\n%");
printf("%s\n","\\ifx\\medleyflag\\relax\\else\n"
                "  \\nopagenumbers\\pageno=1\\medtall\\medwidewidth\\fi");
printf("%s\n","\\newpitch\\newgrace\\noautoglue\n%");

yydebug=0; /* set to 1 to turn on parsing trace */ 

retcode = yyparse();

/* standard ending text */
printf("%s\n","\\byemedley");
printf("%s\n","\\bye");

if (inopened ) fclose(stdin );
if (outopened) fclose(stdout);

return retcode;

}

char *insert(char *aptr, char *bptr)
/* add a note to a beamed note group head structure */
  {
   char *rptr; 
   char rchr[MAXLEN];
   size_t len;

   rptr=rchr;
   len=strcspn(aptr," ");
   strncpy(rptr,aptr,len);
   strcpy(rptr+len,bptr);
   strcat(rptr,aptr+len);
   strcpy(aptr,rptr);
   return aptr;
  }

char *inserts(char *aptr, char *bptr, char *cptr)
/* add an embellishment to a beamed note group
   plus a note to its head structure  */
  {
   char *rptr; 
   char rchr[MAXLEN]; 
   char *sptr; 
   char schr[MAXLEN]; 
   char *dptr;
   size_t lena,lenr,lend;

   rptr=rchr;
   sptr=schr;
   lena=strcspn(aptr," ");
   strncpy(rptr,aptr,lena);
   strcpy(rptr+lena,bptr);
   strcat(rptr,aptr+lena);
   dptr=strrchr(rptr,'\\');
   lenr=strlen(rptr);
   lend=strlen(dptr);
   strncpy(sptr,rptr,lenr-lend);
   strcat(strcat(strcat(strcpy(sptr+lenr-lend,"{"),dptr),cptr),"}");
   strcpy(aptr,sptr); 
   return aptr;
  }


char *insertt(char *aptr, char *bptr, char *cptr)
/* add a tie to a beamed note group plus a note to its head structure */
  {
   char *rptr; 
   char rchr[MAXLEN]; 
   char *sptr; 
   char schr[MAXLEN]; 
   char *dptr;
   size_t lena,lenr,lend;

   rptr=rchr;
   sptr=schr;
   lena=strcspn(aptr," ");
   strncpy(rptr,aptr,lena);
   strcpy(rptr+lena,bptr);
   strcat(rptr,aptr+lena);
   dptr=strrchr(rptr,'\\');
   lenr=strlen(rptr);
   lend=strlen(dptr);
   strncpy(sptr,rptr,lenr-lend);
   strcat(strcat(strcpy(sptr+lenr-lend,"{"),cptr),dptr);
   if (*(sptr+strlen(sptr)-1) == 'p') strcat(sptr+lenr-lend,"\\tten0}");
   else                               strcat(sptr+lenr-lend,"\\psk\\tten0}");
   strcpy(aptr,sptr); 
   return aptr;
  }

char *inserttie(char *aptr, char* bptr)
/* add a tie between notes */
  { 
   char *retptr; char* tieptr; char *rptr;
   char rchr[MAXLEN]; 
   int lena, lenh, lent;

   rptr=rchr;   
   retptr = (char *) malloc(MAXLEN); strcpy(retptr,"");
   tieptr=strrchr(aptr,'\\');
   lena=strlen(aptr); lent=strlen(tieptr); lenh=lena-lent;
   strncat(retptr,aptr,lenh);   
   if( *(tieptr+1) != 'b' )
      {
       strcat(retptr,bptr);
       strcat(retptr,aptr+lenh);  
       if(*(aptr+lena-1) != 'p') strcat(retptr,"\\psk");
      }
   else
      {
       strcat(retptr,"{"); 
       strcat(retptr,bptr); strcat(retptr,aptr+lenh);
       if( *(aptr+lena) != 'p' ) strcat(retptr,"\\psk}");
       else                      strcat(retptr,"}");
      }
   return retptr;
  }       

char *inserttrip( char *aptr, char* bptr)
/* insert a triplet instruction in a beamed group */
  { 
   char *retptr; 
   char *rptr; 
   char rchr[MAXLEN]; 
   char *sptr; 
   char schr[MAXLEN]; 
   char *cptr; char *dptr; char *eptr;
   char search;
   size_t lta, lha, ltr, lhr, lts, lhs;

   rptr=rchr; strcpy(rptr,"");
   sptr=schr; strcpy(sptr,"");

   retptr= (char *) malloc(MAXLEN); strcpy(retptr,""); 
   cptr=strrchr(aptr,'\\'); lta=strlen(cptr); lha=strlen(aptr)-lta;
   strncat(rptr,aptr,lha); 

   if(*(cptr-1)=='}')search='{';
   else search='\\';
   dptr=strrchr(rptr,search); ltr=strlen(dptr); lhr=strlen(rptr)-ltr;
   strncat(sptr,rptr,lhr);

   eptr=strrchr(sptr,'\\'); lts=strlen(eptr); lhs=strlen(sptr)-lts;
   strncat(retptr,sptr,lhs);
   if(*(eptr-1)=='{'){ strcat(retptr,bptr); strcat(retptr,eptr);
                     }
   else              { strcat(retptr,"{"); strcat(retptr,bptr);
                       strcat(strcat(retptr,eptr),"}"); 
                     }
   strcat(retptr,dptr); strcat(retptr,cptr);

   return retptr;
  }
   
char *insertthtrip( char *aptr, char* bptr)
/* insert a triplet instruction between notes */
  { 
   char *retptr; 
   char *cptr; 
   size_t lta, lha;

   retptr= (char *) malloc(MAXLEN); strcpy(retptr,""); 
   cptr=strrchr(aptr,'\\'); lta=strlen(cptr); lha=strlen(aptr)-lta;
   strncat(retptr,aptr,lha); strcat(retptr,bptr); strcat(retptr,cptr);

   return retptr;
  }

char *insertetn(char *aptr)
/* add some glue  (\etn) between beats */
  { char *tieptr;

   /* tieptr=strrchr(aptr,'\\'); */
   /* if( *(tieptr+1) != 'b' ) */
   strcat(aptr,"\\etn");
   strcat(aptr,"\n");
   return aptr;
  }

char *shorten( char *aptr )
/* try to compress a beamed note group to a beam structure with
   four elements */ 
  { 
    char *sptr; char *bptr; char *cptr; char *retptr;
    int lena, lens, lsh, lbh, i, j;    

    lena=strlen(aptr);
    sptr = strchr(aptr, ' ');   
    lens=strlen(sptr);
    lsh=lena-lens;
    for ( i=2; i<lsh-2; i++) 
      { 
         if ( *(aptr+i) == *(aptr+i+1) )
            { 
             retptr= (char *) malloc(MAXLEN); strcpy(retptr,"");
             bptr=aptr+i+1;
             lbh = lena-strlen(bptr);
             strncat(retptr,aptr,lbh-1); strncat(retptr,bptr,lsh-lbh+4); 
             bptr=sptr+4; cptr=bptr;
             for ( j = 2; j < i; j++)
                { 
                 if ( *bptr=='{' ) bptr=strchr(bptr,'}')+1; 
                 else 
                    { 
                     bptr=bptr+3; 
                     if( *(bptr) == 'p' ) bptr++ ;
                    }           
                }  
             lbh=strlen(cptr)-strlen(bptr);
             if (lbh) strncat(retptr,cptr,lbh);             
             cptr=bptr;
             if( *bptr=='{' )
                { 
                 bptr=strchr(bptr+1,'}');
                 lbh=strlen(cptr)-strlen(bptr);
                 strncat(retptr,cptr,lbh);                 
                 if( *(bptr+1)=='{' ) strcat(retptr,bptr+2);
                 else
                    {
                     strncat(retptr,bptr+1,3); bptr=bptr+4;
                     if(*bptr=='p')
                        {
                         strncat(retptr,bptr,1); bptr++;
                        }
                      strcat(retptr,"}"); strcat(retptr,bptr);
                     }
                } 
             else
                {
                 strcat(retptr,"{");
                 strncat(retptr,bptr,3); 
                 bptr=bptr+3;
                 if( *(bptr)=='p' ) { strncat(retptr,bptr,1); bptr++; }
                 if( *bptr != '{')
                    { 
                      strncat(retptr,bptr,3); bptr=bptr+3;
                      if( *bptr=='p' ){ strncat(retptr,bptr,1); bptr++ ; }
                      strcat(retptr,"}"); strcat(retptr,bptr);
                    }
                 else strcat(retptr,bptr+1);
                }  
             free(aptr);
             return retptr;
            }   
        }    
    printf("%% can't shorten long beam macro, output file will not TeX ");
    return aptr;
  }            
           
             