Plan 9 from Bell Labs’s /usr/web/sources/contrib/cnielsen/cuetools/toc_parse.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include <stdlib.h>
#ifndef lint
#ifdef __unused
__unused
#endif
static char const 
yyrcsid[] = "$FreeBSD: src/usr.bin/yacc/skeleton.c,v 1.37 2003/02/12 18:03:55 davidc Exp $";
#endif
#define YYBYACC 1
#define YYMAJOR 1
#define YYMINOR 9
#define YYLEX yylex()
#define YYEMPTY -1
#define yyclearin (yychar=(YYEMPTY))
#define yyerrok (yyerrflag=0)
#define YYRECOVERING() (yyerrflag!=0)
#if defined(__cplusplus) || __STDC__
static int yygrowstack(void);
#else
static int yygrowstack();
#endif
#define yyparse toc_yyparse
#define yylex toc_yylex
#define yyerror toc_yyerror
#define yychar toc_yychar
#define yyval toc_yyval
#define yylval toc_yylval
#define yydebug toc_yydebug
#define yynerrs toc_yynerrs
#define yyerrflag toc_yyerrflag
#define yyss toc_yyss
#define yyssp toc_yyssp
#define yyvs toc_yyvs
#define yyvsp toc_yyvsp
#define yylhs toc_yylhs
#define yylen toc_yylen
#define yydefred toc_yydefred
#define yydgoto toc_yydgoto
#define yysindex toc_yysindex
#define yyrindex toc_yyrindex
#define yygindex toc_yygindex
#define yytable toc_yytable
#define yycheck toc_yycheck
#define yyname toc_yyname
#define yyrule toc_yyrule
#define yysslim toc_yysslim
#define yystacksize toc_yystacksize
#define YYPREFIX "toc_yy"
#line 2 "toc_parse.y"
/*
 * toc_parse.y -- parser for toc files
 *
 * Copyright (C) 2004 Svend Sorensen
 * For license terms, see the file COPYING in this distribution.
 */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "cd.h"
#include "time.h"

#define YYDEBUG 1

extern int toc_yylex();
void yyerror (char *s);

static Cd *cd = NULL;
static Track *track = NULL;
static Cdtext *cdtext = NULL;
#line 27 "toc_parse.y"
typedef union {
	long ival;
	char *sval;
} YYSTYPE;
#line 77 "toc_parse.c"
#define YYERRCODE 256
#define NUMBER 257
#define STRING 258
#define CATALOG 259
#define CD_DA 260
#define CD_ROM 261
#define CD_ROM_XA 262
#define TRACK 263
#define AUDIO 264
#define MODE1 265
#define MODE1_RAW 266
#define MODE2 267
#define MODE2_FORM1 268
#define MODE2_FORM2 269
#define MODE2_FORM_MIX 270
#define MODE2_RAW 271
#define RW 272
#define RW_RAW 273
#define NO 274
#define COPY 275
#define PRE_EMPHASIS 276
#define TWO_CHANNEL_AUDIO 277
#define FOUR_CHANNEL_AUDIO 278
#define ISRC 279
#define SILENCE 280
#define ZERO 281
#define AUDIOFILE 282
#define DATAFILE 283
#define FIFO 284
#define START 285
#define PREGAP 286
#define INDEX 287
#define CD_TEXT 288
#define LANGUAGE_MAP 289
#define LANGUAGE 290
#define TITLE 291
#define PERFORMER 292
#define SONGWRITER 293
#define COMPOSER 294
#define ARRANGER 295
#define MESSAGE 296
#define DISC_ID 297
#define GENRE 298
#define TOC_INFO1 299
#define TOC_INFO2 300
#define UPC_EAN 301
#define SIZE_INFO 302
const short toc_yylhs[] = {                                        -1,
    0,    9,   10,   10,   12,   12,   12,   12,    1,    1,
    1,   11,   11,   16,   17,   18,    2,    2,    3,    3,
    3,    3,    3,    3,    3,    3,    4,    4,   19,   19,
   20,   20,   20,   20,   20,   20,   20,   21,   21,    5,
    5,    5,    6,    6,    6,   22,   22,   22,   22,   22,
   22,   25,   25,   23,   23,   23,   24,   14,   26,   26,
   27,   15,   15,   28,   29,   29,   30,   30,    8,    8,
    8,    8,    8,    8,    8,    8,    8,    8,    8,    8,
    8,   31,   31,    7,    7,   13,   13,
};
const short toc_yylen[] = {                                         2,
    3,    0,    0,    2,    3,    2,    7,    2,    1,    1,
    1,    1,    2,    3,    0,    3,    1,    2,    1,    1,
    1,    1,    1,    1,    1,    1,    1,    1,    1,    2,
    1,    3,    6,    1,    1,    1,    2,    1,    1,    2,
    2,    2,    3,    3,    2,    3,    4,    5,    3,    4,
    4,    1,    1,    2,    3,    3,    3,    6,    1,    2,
    4,    1,    2,    7,    0,    2,    3,    5,    1,    1,
    1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
    1,    0,    3,    1,    5,    0,    1,
};
const short toc_yydefred[] = {                                      2,
    0,    3,    0,    0,    0,    9,   10,   11,    0,    0,
    0,    4,   12,    0,    8,    0,    0,    6,   13,    0,
    0,    5,   87,    0,   19,   20,   21,   22,   23,   24,
   25,   26,    0,    0,    0,    0,    0,    0,    0,    0,
    0,   52,   53,    0,    0,    0,    0,    0,    0,    0,
   38,   39,    0,   29,   31,   34,   35,   36,    0,    0,
    0,   16,   27,   28,   18,   37,    0,    0,   40,   41,
   45,   42,    0,    0,    0,    0,    0,   54,    0,    0,
    0,    0,   30,    0,    0,    0,    0,   62,   44,   43,
   32,    0,   49,    0,    0,    0,   55,   56,   57,    0,
   46,    0,    0,    0,   63,   47,    0,   50,   51,    0,
    0,    0,    0,   59,    0,    7,   48,    0,    0,    0,
    0,   60,   65,   85,   33,    0,   58,    0,   61,   80,
   69,   70,   71,   72,   73,   74,   75,   76,   77,   78,
   79,   81,    0,    0,   66,   64,    0,   82,   67,    0,
    0,    0,   68,   83,
};
const short toc_yydgoto[] = {                                       1,
   10,   33,   34,   65,   51,   52,   79,  144,    2,    3,
   11,   12,   24,   61,   87,   13,   14,   21,   53,   54,
   55,   56,   57,   58,   59,  113,  114,   88,  128,  145,
  150,
};
const short toc_yysindex[] = {                                      0,
    0,    0, -234,    8, -239,    0,    0,    0,  -99,   19,
    0,    0,    0, -230,    0,   25,   26,    0,    0, -190,
 -215,    0,    0, -252,    0,    0,    0,    0,    0,    0,
    0,    0,   32, -257,   33, -244,   34,   35,   36,   38,
 -209,    0,    0, -208, -207, -206,  -10, -204, -204,  -66,
    0,    0, -215,    0,    0,    0,    0,    0, -204,  -41,
 -235,    0,    0,    0,    0,    0,   73,   74,    0,    0,
    0,    0,   75, -204,   -7, -204,   28,    0,   77,   78,
   79,   26,    0,   81,   26, -165, -105,    0,    0,    0,
    0,   -6,    0,   83,   84, -162,    0,    0,    0, -235,
    0, -161,  -26,   88,    0,    0,   89,    0,    0,   42,
 -104,   43, -117,    0,   26,    0,    0, -155,   93, -153,
   95,    0,    0,    0,    0,   26,    0, -119,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,   96, -116,    0,    0,   97,    0,    0,  -35,
   98, -148,    0,    0,
};
const short toc_yyrindex[] = {                                      0,
    0,    0, -152,    0,    0,    0,    0,    0,    0,    0,
    1,    0,    0,    0,    0,    0, -179,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,  102,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    2,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,   -5,    0,    0,    0,
    0, -235,    0,    0, -144,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,  -95,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0, -114,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,
};
const short toc_yygindex[] = {                                      0,
    0,    0,    0,    0,    0,    0,  -36,    0,    0,    0,
    0,    0,  -68,    0,   14,  104,    0,    0,    0,   63,
    0,    0,    0,    0,    0,    0,    4,  -77,    0,    0,
    0,
};
#define YYTABLESIZE 265
const short toc_yytable[] = {                                      78,
    1,   14,   93,  106,   84,  143,  148,  121,  152,  105,
   86,   80,   81,  100,   63,   64,  102,   15,   16,  104,
  119,    4,   84,   17,    5,    6,    7,    8,   18,   86,
   67,   68,   20,  105,   22,   23,   60,   92,   94,   95,
   35,   62,   66,   69,   70,   71,  123,   72,   73,   74,
   75,   76,   77,    9,   86,  107,   82,  129,   36,   37,
   38,   39,   40,   41,   42,   43,   44,   45,   46,   47,
   48,   49,   50,   25,   26,   27,   28,   29,   30,   31,
   32,   85,   89,   90,   91,   96,   97,   98,   99,  151,
  101,  103,  108,  109,  110,  112,  115,  116,  117,  118,
  120,  124,  125,  126,  127,  146,  149,  153,  154,   86,
   15,   17,   86,  111,   19,   83,  122,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,  112,
    0,  147,   86,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,  130,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,  131,  132,  133,  134,  135,  136,  137,  138,  139,
  140,  141,  142,   86,   86,   86,    0,    0,    0,    0,
    0,    0,    0,    0,    0,   86,   86,   86,   86,   86,
   86,   86,   86,   86,   86,   86,   86,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,   77,    0,    0,   77,
   77,   84,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,   15,   14,
};
const short toc_yycheck[] = {                                      10,
    0,    0,   10,   10,   10,  125,  123,  125,   44,   87,
  125,   48,   49,   82,  272,  273,   85,   10,  258,  125,
  125,  256,   59,  123,  259,  260,  261,  262,   10,  125,
  275,  276,  263,  111,   10,   10,  289,   74,   75,   76,
  256,   10,   10,   10,   10,   10,  115,   10,  258,  258,
  258,  258,  257,  288,  290,   92,  123,  126,  274,  275,
  276,  277,  278,  279,  280,  281,  282,  283,  284,  285,
  286,  287,  288,  264,  265,  266,  267,  268,  269,  270,
  271,  123,   10,   10,   10,   58,   10,   10,   10,  125,
   10,  257,   10,   10,  257,  257,  123,   10,   10,   58,
   58,  257,   10,  257,   10,   10,   10,   10,  257,  289,
  263,   10,  257,  100,   11,   53,  113,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  257,
   -1,  258,  257,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  279,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,  291,  292,  293,  294,  295,  296,  297,  298,  299,
  300,  301,  302,  279,  290,  290,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,  291,  292,  293,  294,  295,
  296,  297,  298,  299,  300,  301,  302,   -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,  257,   -1,   -1,  257,
  257,  257,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,  263,  263,
};
#define YYFINAL 1
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
#define YYMAXTOKEN 302
#if YYDEBUG
const char * const toc_yyname[] = {
"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,"':'",0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"NUMBER",
"STRING","CATALOG","CD_DA","CD_ROM","CD_ROM_XA","TRACK","AUDIO","MODE1",
"MODE1_RAW","MODE2","MODE2_FORM1","MODE2_FORM2","MODE2_FORM_MIX","MODE2_RAW",
"RW","RW_RAW","NO","COPY","PRE_EMPHASIS","TWO_CHANNEL_AUDIO",
"FOUR_CHANNEL_AUDIO","ISRC","SILENCE","ZERO","AUDIOFILE","DATAFILE","FIFO",
"START","PREGAP","INDEX","CD_TEXT","LANGUAGE_MAP","LANGUAGE","TITLE",
"PERFORMER","SONGWRITER","COMPOSER","ARRANGER","MESSAGE","DISC_ID","GENRE",
"TOC_INFO1","TOC_INFO2","UPC_EAN","SIZE_INFO",
};
const char * const toc_yyrule[] = {
"$accept : tocfile",
"tocfile : new_cd global_statements track_list",
"new_cd :",
"global_statements :",
"global_statements : global_statements global_statement",
"global_statement : CATALOG STRING '\\n'",
"global_statement : disc_mode '\\n'",
"global_statement : CD_TEXT '{' opt_nl language_map cdtext_langs '}' '\\n'",
"global_statement : error '\\n'",
"disc_mode : CD_DA",
"disc_mode : CD_ROM",
"disc_mode : CD_ROM_XA",
"track_list : track",
"track_list : track_list track",
"track : new_track track_def track_statements",
"new_track :",
"track_def : TRACK track_modes '\\n'",
"track_modes : track_mode",
"track_modes : track_mode track_sub_mode",
"track_mode : AUDIO",
"track_mode : MODE1",
"track_mode : MODE1_RAW",
"track_mode : MODE2",
"track_mode : MODE2_FORM1",
"track_mode : MODE2_FORM2",
"track_mode : MODE2_FORM_MIX",
"track_mode : MODE2_RAW",
"track_sub_mode : RW",
"track_sub_mode : RW_RAW",
"track_statements : track_statement",
"track_statements : track_statements track_statement",
"track_statement : track_flags",
"track_statement : ISRC STRING '\\n'",
"track_statement : CD_TEXT '{' opt_nl cdtext_langs '}' '\\n'",
"track_statement : track_data",
"track_statement : track_pregap",
"track_statement : track_index",
"track_statement : error '\\n'",
"track_flags : track_set_flag",
"track_flags : track_clear_flag",
"track_set_flag : COPY '\\n'",
"track_set_flag : PRE_EMPHASIS '\\n'",
"track_set_flag : FOUR_CHANNEL_AUDIO '\\n'",
"track_clear_flag : NO PRE_EMPHASIS '\\n'",
"track_clear_flag : NO COPY '\\n'",
"track_clear_flag : TWO_CHANNEL_AUDIO '\\n'",
"track_data : zero_data time '\\n'",
"track_data : AUDIOFILE STRING time '\\n'",
"track_data : AUDIOFILE STRING time time '\\n'",
"track_data : DATAFILE STRING '\\n'",
"track_data : DATAFILE STRING time '\\n'",
"track_data : FIFO STRING time '\\n'",
"zero_data : SILENCE",
"zero_data : ZERO",
"track_pregap : START '\\n'",
"track_pregap : START time '\\n'",
"track_pregap : PREGAP time '\\n'",
"track_index : INDEX time '\\n'",
"language_map : LANGUAGE_MAP '{' opt_nl languages '}' '\\n'",
"languages : language",
"languages : languages language",
"language : NUMBER ':' NUMBER opt_nl",
"cdtext_langs : cdtext_lang",
"cdtext_langs : cdtext_langs cdtext_lang",
"cdtext_lang : LANGUAGE NUMBER '{' opt_nl cdtext_defs '}' '\\n'",
"cdtext_defs :",
"cdtext_defs : cdtext_defs cdtext_def",
"cdtext_def : cdtext_item STRING '\\n'",
"cdtext_def : cdtext_item '{' bytes '}' '\\n'",
"cdtext_item : TITLE",
"cdtext_item : PERFORMER",
"cdtext_item : SONGWRITER",
"cdtext_item : COMPOSER",
"cdtext_item : ARRANGER",
"cdtext_item : MESSAGE",
"cdtext_item : DISC_ID",
"cdtext_item : GENRE",
"cdtext_item : TOC_INFO1",
"cdtext_item : TOC_INFO2",
"cdtext_item : UPC_EAN",
"cdtext_item : ISRC",
"cdtext_item : SIZE_INFO",
"bytes :",
"bytes : bytes ',' NUMBER",
"time : NUMBER",
"time : NUMBER ':' NUMBER ':' NUMBER",
"opt_nl :",
"opt_nl : '\\n'",
};
#endif
#if YYDEBUG
#include <stdio.h>
#endif
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
#define YYMAXDEPTH YYSTACKSIZE
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 10000
#define YYMAXDEPTH 10000
#endif
#endif
#define YYINITSTACKSIZE 200
int yydebug;
int yynerrs;
int yyerrflag;
int yychar;
short *yyssp;
YYSTYPE *yyvsp;
YYSTYPE yyval;
YYSTYPE yylval;
short *yyss;
short *yysslim;
YYSTYPE *yyvs;
int yystacksize;
#line 325 "toc_parse.y"

/* lexer interface */
extern int toc_lineno;
extern int toc_yydebug;
extern FILE *toc_yyin;

void yyerror (char *s)
{
	fprintf(stderr, "%d: %s\n", toc_lineno, s);
}

Cd *toc_parse (FILE *fp)
{
	toc_yyin = fp;
	toc_yydebug = 0;

	if (0 == toc_yyparse())
		return cd;

	return NULL;
}
#line 434 "toc_parse.c"
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
static int yygrowstack()
{
    int newsize, i;
    short *newss;
    YYSTYPE *newvs;

    if ((newsize = yystacksize) == 0)
        newsize = YYINITSTACKSIZE;
    else if (newsize >= YYMAXDEPTH)
        return -1;
    else if ((newsize *= 2) > YYMAXDEPTH)
        newsize = YYMAXDEPTH;
    i = yyssp - yyss;
    newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) :
      (short *)malloc(newsize * sizeof *newss);
    if (newss == NULL)
        return -1;
    yyss = newss;
    yyssp = newss + i;
    newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) :
      (YYSTYPE *)malloc(newsize * sizeof *newvs);
    if (newvs == NULL)
        return -1;
    yyvs = newvs;
    yyvsp = newvs + i;
    yystacksize = newsize;
    yysslim = yyss + newsize - 1;
    return 0;
}

#define YYABORT goto yyabort
#define YYREJECT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR goto yyerrlab

#ifndef YYPARSE_PARAM
#if defined(__cplusplus) || __STDC__
#define YYPARSE_PARAM_ARG void
#define YYPARSE_PARAM_DECL
#else	/* ! ANSI-C/C++ */
#define YYPARSE_PARAM_ARG
#define YYPARSE_PARAM_DECL
#endif	/* ANSI-C/C++ */
#else	/* YYPARSE_PARAM */
#ifndef YYPARSE_PARAM_TYPE
#define YYPARSE_PARAM_TYPE void *
#endif
#if defined(__cplusplus) || __STDC__
#define YYPARSE_PARAM_ARG YYPARSE_PARAM_TYPE YYPARSE_PARAM
#define YYPARSE_PARAM_DECL
#else	/* ! ANSI-C/C++ */
#define YYPARSE_PARAM_ARG YYPARSE_PARAM
#define YYPARSE_PARAM_DECL YYPARSE_PARAM_TYPE YYPARSE_PARAM;
#endif	/* ANSI-C/C++ */
#endif	/* ! YYPARSE_PARAM */

int
yyparse (YYPARSE_PARAM_ARG)
    YYPARSE_PARAM_DECL
{
    int yym, yyn, yystate;
#if YYDEBUG
    const char *yys;

    if ((yys = getenv("YYDEBUG")))
    {
        yyn = *yys;
        if (yyn >= '0' && yyn <= '9')
            yydebug = yyn - '0';
    }
#endif

    yynerrs = 0;
    yyerrflag = 0;
    yychar = (-1);

    if (yyss == NULL && yygrowstack()) goto yyoverflow;
    yyssp = yyss;
    yyvsp = yyvs;
    *yyssp = yystate = 0;

yyloop:
    if ((yyn = yydefred[yystate])) goto yyreduce;
    if (yychar < 0)
    {
        if ((yychar = yylex()) < 0) yychar = 0;
#if YYDEBUG
        if (yydebug)
        {
            yys = 0;
            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
            if (!yys) yys = "illegal-symbol";
            printf("%sdebug: state %d, reading %d (%s)\n",
                    YYPREFIX, yystate, yychar, yys);
        }
#endif
    }
    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
    {
#if YYDEBUG
        if (yydebug)
            printf("%sdebug: state %d, shifting to state %d\n",
                    YYPREFIX, yystate, yytable[yyn]);
#endif
        if (yyssp >= yysslim && yygrowstack())
        {
            goto yyoverflow;
        }
        *++yyssp = yystate = yytable[yyn];
        *++yyvsp = yylval;
        yychar = (-1);
        if (yyerrflag > 0)  --yyerrflag;
        goto yyloop;
    }
    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
    {
        yyn = yytable[yyn];
        goto yyreduce;
    }
    if (yyerrflag) goto yyinrecovery;
#if defined(lint) || defined(__GNUC__)
    goto yynewerror;
#endif
yynewerror:
    yyerror("syntax error");
#if defined(lint) || defined(__GNUC__)
    goto yyerrlab;
#endif
yyerrlab:
    ++yynerrs;
yyinrecovery:
    if (yyerrflag < 3)
    {
        yyerrflag = 3;
        for (;;)
        {
            if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
            {
#if YYDEBUG
                if (yydebug)
                    printf("%sdebug: state %d, error recovery shifting\
 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
#endif
                if (yyssp >= yysslim && yygrowstack())
                {
                    goto yyoverflow;
                }
                *++yyssp = yystate = yytable[yyn];
                *++yyvsp = yylval;
                goto yyloop;
            }
            else
            {
#if YYDEBUG
                if (yydebug)
                    printf("%sdebug: error recovery discarding state %d\n",
                            YYPREFIX, *yyssp);
#endif
                if (yyssp <= yyss) goto yyabort;
                --yyssp;
                --yyvsp;
            }
        }
    }
    else
    {
        if (yychar == 0) goto yyabort;
#if YYDEBUG
        if (yydebug)
        {
            yys = 0;
            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
            if (!yys) yys = "illegal-symbol";
            printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
                    YYPREFIX, yystate, yychar, yys);
        }
#endif
        yychar = (-1);
        goto yyloop;
    }
yyreduce:
#if YYDEBUG
    if (yydebug)
        printf("%sdebug: state %d, reducing by rule %d (%s)\n",
                YYPREFIX, yystate, yyn, yyrule[yyn]);
#endif
    yym = yylen[yyn];
    yyval = yyvsp[1-yym];
    switch (yyn)
    {
case 2:
#line 106 "toc_parse.y"
{
		cd = cd_init();
		cdtext = cd_get_cdtext(cd);
	}
break;
case 5:
#line 118 "toc_parse.y"
{ cd_set_catalog(cd, yyvsp[-1].sval); }
break;
case 6:
#line 119 "toc_parse.y"
{ cd_set_mode(cd, yyvsp[-1].ival); }
break;
case 14:
#line 136 "toc_parse.y"
{
		while (2 > track_get_nindex(track))
			track_add_index(track, 0);
	}
break;
case 15:
#line 143 "toc_parse.y"
{
		track = cd_add_track(cd);
		cdtext = track_get_cdtext(track);
		/* add 0 index */
		track_add_index(track, 0);
	}
break;
case 16:
#line 152 "toc_parse.y"
{ track_set_mode(track, yyvsp[-1].ival); }
break;
case 18:
#line 157 "toc_parse.y"
{ track_set_sub_mode(track, yyvsp[0].ival); }
break;
case 32:
#line 183 "toc_parse.y"
{ track_set_isrc(track, yyvsp[-1].sval); }
break;
case 38:
#line 192 "toc_parse.y"
{ track_set_flag(track, yyvsp[0].ival); }
break;
case 39:
#line 193 "toc_parse.y"
{ track_clear_flag(track, yyvsp[0].ival); }
break;
case 43:
#line 203 "toc_parse.y"
{ yyval.ival = yyvsp[-1].ival; }
break;
case 44:
#line 204 "toc_parse.y"
{ yyval.ival = yyvsp[-1].ival; }
break;
case 46:
#line 209 "toc_parse.y"
{
		if (NULL == track_get_filename(track))
			track_set_zero_pre(track, yyvsp[-1].ival);
		else
			track_set_zero_post(track, yyvsp[-1].ival);
	}
break;
case 47:
#line 215 "toc_parse.y"
{
		track_set_filename(track, yyvsp[-2].sval);
		track_set_start(track, yyvsp[-1].ival);
	}
break;
case 48:
#line 219 "toc_parse.y"
{
		track_set_filename(track, yyvsp[-3].sval);
		track_set_start(track, yyvsp[-2].ival);
		track_set_length(track, yyvsp[-1].ival);
	}
break;
case 49:
#line 224 "toc_parse.y"
{
		track_set_filename(track, yyvsp[-1].sval);
	}
break;
case 50:
#line 227 "toc_parse.y"
{
		track_set_filename(track, yyvsp[-2].sval);
		track_set_start(track, yyvsp[-1].ival);
	}
break;
case 51:
#line 231 "toc_parse.y"
{
		track_set_filename(track, yyvsp[-2].sval);
		track_set_start(track, yyvsp[-1].ival);
	}
break;
case 55:
#line 244 "toc_parse.y"
{
		track_add_index(track, yyvsp[-1].ival);
	}
break;
case 56:
#line 247 "toc_parse.y"
{
		track_set_zero_pre(track, yyvsp[-1].ival);
		track_add_index(track, yyvsp[-1].ival);
	}
break;
case 57:
#line 254 "toc_parse.y"
{ track_add_index(track, yyvsp[-1].ival); }
break;
case 67:
#line 285 "toc_parse.y"
{
		cdtext_set (yyvsp[-2].ival, yyvsp[-1].sval, cdtext);
	}
break;
case 68:
#line 288 "toc_parse.y"
{
		yyerror("binary CD-TEXT data not supported\n");
	}
break;
case 84:
#line 315 "toc_parse.y"
{ yyval.ival = yyvsp[0].ival; }
break;
case 85:
#line 316 "toc_parse.y"
{ yyval.ival = time_msf_to_frame(yyvsp[-4].ival, yyvsp[-2].ival, yyvsp[0].ival); }
break;
#line 769 "toc_parse.c"
    }
    yyssp -= yym;
    yystate = *yyssp;
    yyvsp -= yym;
    yym = yylhs[yyn];
    if (yystate == 0 && yym == 0)
    {
#if YYDEBUG
        if (yydebug)
            printf("%sdebug: after reduction, shifting from state 0 to\
 state %d\n", YYPREFIX, YYFINAL);
#endif
        yystate = YYFINAL;
        *++yyssp = YYFINAL;
        *++yyvsp = yyval;
        if (yychar < 0)
        {
            if ((yychar = yylex()) < 0) yychar = 0;
#if YYDEBUG
            if (yydebug)
            {
                yys = 0;
                if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
                if (!yys) yys = "illegal-symbol";
                printf("%sdebug: state %d, reading %d (%s)\n",
                        YYPREFIX, YYFINAL, yychar, yys);
            }
#endif
        }
        if (yychar == 0) goto yyaccept;
        goto yyloop;
    }
    if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
        yystate = yytable[yyn];
    else
        yystate = yydgoto[yym];
#if YYDEBUG
    if (yydebug)
        printf("%sdebug: after reduction, shifting from state %d \
to state %d\n", YYPREFIX, *yyssp, yystate);
#endif
    if (yyssp >= yysslim && yygrowstack())
    {
        goto yyoverflow;
    }
    *++yyssp = yystate;
    *++yyvsp = yyval;
    goto yyloop;
yyoverflow:
    yyerror("yacc stack overflow");
yyabort:
    return (1);
yyaccept:
    return (0);
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].