Home | History | Annotate | Line # | Download | only in yacc
      1  1.1  christos /*	$NetBSD: defines3.calc.c,v 1.3 2026/01/18 16:41:31 christos Exp $	*/
      2  1.1  christos 
      3  1.1  christos /* original parser id follows */
      4  1.1  christos /* yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93" */
      5  1.1  christos /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
      6  1.1  christos 
      7  1.1  christos #define YYBYACC 1
      8  1.2  christos #define YYMAJOR 2
      9  1.2  christos #define YYMINOR 0
     10  1.1  christos #define YYCHECK "yyyymmdd"
     11  1.1  christos 
     12  1.1  christos #define YYEMPTY        (-1)
     13  1.1  christos #define yyclearin      (yychar = YYEMPTY)
     14  1.1  christos #define yyerrok        (yyerrflag = 0)
     15  1.1  christos #define YYRECOVERING() (yyerrflag != 0)
     16  1.1  christos #define YYENOMEM       (-2)
     17  1.1  christos #define YYEOF          0
     18  1.1  christos #define YYPREFIX "yy"
     19  1.1  christos 
     20  1.1  christos #define YYPURE 0
     21  1.1  christos 
     22  1.1  christos #line 2 "calc.y"
     23  1.1  christos # include <stdio.h>
     24  1.1  christos # include <ctype.h>
     25  1.1  christos 
     26  1.1  christos int regs[26];
     27  1.1  christos int base;
     28  1.1  christos 
     29  1.1  christos extern int yylex(void);
     30  1.1  christos static void yyerror(const char *s);
     31  1.1  christos 
     32  1.1  christos #line 31 "prefix.tab.c"
     33  1.1  christos 
     34  1.1  christos #if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
     35  1.1  christos /* Default: YYSTYPE is the semantic value type. */
     36  1.1  christos typedef int YYSTYPE;
     37  1.1  christos # define YYSTYPE_IS_DECLARED 1
     38  1.1  christos #endif
     39  1.1  christos 
     40  1.1  christos /* compatibility with bison */
     41  1.1  christos #ifdef YYPARSE_PARAM
     42  1.1  christos /* compatibility with FreeBSD */
     43  1.1  christos # ifdef YYPARSE_PARAM_TYPE
     44  1.1  christos #  define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
     45  1.1  christos # else
     46  1.1  christos #  define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
     47  1.1  christos # endif
     48  1.1  christos #else
     49  1.1  christos # define YYPARSE_DECL() yyparse(void)
     50  1.1  christos #endif
     51  1.1  christos 
     52  1.1  christos /* Parameters sent to lex. */
     53  1.1  christos #ifdef YYLEX_PARAM
     54  1.1  christos # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
     55  1.1  christos # define YYLEX yylex(YYLEX_PARAM)
     56  1.1  christos #else
     57  1.1  christos # define YYLEX_DECL() yylex(void)
     58  1.1  christos # define YYLEX yylex()
     59  1.1  christos #endif
     60  1.1  christos 
     61  1.1  christos #if !(defined(yylex) || defined(YYSTATE))
     62  1.1  christos int YYLEX_DECL();
     63  1.1  christos #endif
     64  1.1  christos 
     65  1.1  christos /* Parameters sent to yyerror. */
     66  1.1  christos #ifndef YYERROR_DECL
     67  1.1  christos #define YYERROR_DECL() yyerror(const char *s)
     68  1.1  christos #endif
     69  1.1  christos #ifndef YYERROR_CALL
     70  1.1  christos #define YYERROR_CALL(msg) yyerror(msg)
     71  1.1  christos #endif
     72  1.1  christos 
     73  1.1  christos extern int YYPARSE_DECL();
     74  1.1  christos 
     75  1.1  christos #define DIGIT 257
     76  1.1  christos #define LETTER 258
     77  1.1  christos #define UMINUS 259
     78  1.1  christos #define YYERRCODE 256
     79  1.2  christos typedef int YYINT;
     80  1.1  christos static const YYINT yylhs[] = {                           -1,
     81  1.1  christos     0,    0,    0,    1,    1,    2,    2,    2,    2,    2,
     82  1.1  christos     2,    2,    2,    2,    2,    2,    3,    3,
     83  1.1  christos };
     84  1.1  christos static const YYINT yylen[] = {                            2,
     85  1.1  christos     0,    3,    3,    1,    3,    3,    3,    3,    3,    3,
     86  1.1  christos     3,    3,    3,    2,    1,    1,    1,    2,
     87  1.1  christos };
     88  1.1  christos static const YYINT yydefred[] = {                         1,
     89  1.1  christos     0,    0,   17,    0,    0,    0,    0,    0,    0,    3,
     90  1.1  christos     0,   15,   14,    0,    2,    0,    0,    0,    0,    0,
     91  1.1  christos     0,    0,   18,    0,    6,    0,    0,    0,    0,    9,
     92  1.1  christos    10,   11,
     93  1.1  christos };
     94  1.1  christos static const YYINT yydgoto[] = {                          1,
     95  1.1  christos     7,    8,    9,
     96  1.1  christos };
     97  1.1  christos static const YYINT yysindex[] = {                         0,
     98  1.1  christos   -40,   -7,    0,  -55,  -38,  -38,    1,  -29, -247,    0,
     99  1.1  christos   -38,    0,    0,   22,    0,  -38,  -38,  -38,  -38,  -38,
    100  1.1  christos   -38,  -38,    0,  -29,    0,   51,   60,  -20,  -20,    0,
    101  1.1  christos     0,    0,
    102  1.1  christos };
    103  1.1  christos static const YYINT yyrindex[] = {                         0,
    104  1.1  christos     0,    0,    0,    2,    0,    0,    0,    9,   -9,    0,
    105  1.1  christos     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    106  1.1  christos     0,    0,    0,   10,    0,   -6,   14,    5,   13,    0,
    107  1.1  christos     0,    0,
    108  1.1  christos };
    109  1.1  christos static const YYINT yygindex[] = {                         0,
    110  1.1  christos     0,   65,    0,
    111  1.1  christos };
    112  1.1  christos #define YYTABLESIZE 220
    113  1.1  christos static const YYINT yytable[] = {                          6,
    114  1.1  christos    16,    6,   10,   13,    5,   11,    5,   22,   17,   23,
    115  1.1  christos    15,   15,   20,   18,    7,   19,   22,   21,    4,    5,
    116  1.1  christos     0,   20,    8,   12,    0,    0,   21,   16,   16,    0,
    117  1.1  christos     0,   16,   16,   16,   13,   16,    0,   16,   15,   15,
    118  1.1  christos     0,    0,    7,   15,   15,    7,   15,    7,   15,    7,
    119  1.1  christos     8,   12,    0,    8,   12,    8,    0,    8,   22,   17,
    120  1.1  christos     0,    0,   25,   20,   18,    0,   19,    0,   21,   13,
    121  1.1  christos    14,    0,    0,    0,    0,   24,    0,    0,    0,    0,
    122  1.1  christos    26,   27,   28,   29,   30,   31,   32,   22,   17,    0,
    123  1.1  christos     0,    0,   20,   18,   16,   19,   22,   21,    0,    0,
    124  1.1  christos     0,   20,   18,    0,   19,    0,   21,    0,    0,    0,
    125  1.1  christos     0,    0,    0,    0,   16,    0,    0,   13,    0,    0,
    126  1.1  christos     0,    0,    0,    0,    0,   15,    0,    0,    7,    0,
    127  1.1  christos     0,    0,    0,    0,    0,    0,    8,   12,    0,    0,
    128  1.1  christos     0,    0,    0,    0,    0,   16,    0,    0,    0,    0,
    129  1.1  christos     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    130  1.1  christos     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    131  1.1  christos     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    132  1.1  christos     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    133  1.1  christos     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    134  1.1  christos     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    135  1.1  christos     0,    0,    0,    0,    0,    2,    3,    4,    3,   12,
    136  1.1  christos };
    137  1.1  christos static const YYINT yycheck[] = {                         40,
    138  1.1  christos    10,   40,   10,   10,   45,   61,   45,   37,   38,  257,
    139  1.1  christos    10,   10,   42,   43,   10,   45,   37,   47,   10,   10,
    140  1.1  christos    -1,   42,   10,   10,   -1,   -1,   47,   37,   38,   -1,
    141  1.1  christos    -1,   41,   42,   43,   41,   45,   -1,   47,   37,   38,
    142  1.1  christos    -1,   -1,   38,   42,   43,   41,   45,   43,   47,   45,
    143  1.1  christos    38,   38,   -1,   41,   41,   43,   -1,   45,   37,   38,
    144  1.1  christos    -1,   -1,   41,   42,   43,   -1,   45,   -1,   47,    5,
    145  1.1  christos     6,   -1,   -1,   -1,   -1,   11,   -1,   -1,   -1,   -1,
    146  1.1  christos    16,   17,   18,   19,   20,   21,   22,   37,   38,   -1,
    147  1.1  christos    -1,   -1,   42,   43,  124,   45,   37,   47,   -1,   -1,
    148  1.1  christos    -1,   42,   43,   -1,   45,   -1,   47,   -1,   -1,   -1,
    149  1.1  christos    -1,   -1,   -1,   -1,  124,   -1,   -1,  124,   -1,   -1,
    150  1.1  christos    -1,   -1,   -1,   -1,   -1,  124,   -1,   -1,  124,   -1,
    151  1.1  christos    -1,   -1,   -1,   -1,   -1,   -1,  124,  124,   -1,   -1,
    152  1.1  christos    -1,   -1,   -1,   -1,   -1,  124,   -1,   -1,   -1,   -1,
    153  1.1  christos    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    154  1.1  christos    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    155  1.1  christos    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    156  1.1  christos    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    157  1.1  christos    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    158  1.1  christos    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    159  1.1  christos    -1,   -1,   -1,   -1,   -1,  256,  257,  258,  257,  258,
    160  1.1  christos };
    161  1.1  christos #define YYFINAL 1
    162  1.1  christos #ifndef YYDEBUG
    163  1.1  christos #define YYDEBUG 0
    164  1.1  christos #endif
    165  1.1  christos #define YYMAXTOKEN 259
    166  1.1  christos #define YYUNDFTOKEN 265
    167  1.1  christos #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
    168  1.1  christos #if YYDEBUG
    169  1.3  christos #ifndef NULL
    170  1.3  christos #define NULL (void*)0
    171  1.3  christos #endif
    172  1.1  christos static const char *const yyname[] = {
    173  1.1  christos 
    174  1.3  christos "end-of-file",NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,"'\\n'",NULL,NULL,
    175  1.3  christos NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    176  1.3  christos NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,"'%'","'&'",NULL,"'('","')'","'*'",
    177  1.3  christos "'+'",NULL,"'-'",NULL,"'/'",NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    178  1.3  christos NULL,NULL,NULL,"'='",NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    179  1.3  christos NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    180  1.3  christos NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    181  1.3  christos NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    182  1.3  christos NULL,NULL,NULL,"'|'",NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    183  1.3  christos NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    184  1.3  christos NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    185  1.3  christos NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    186  1.3  christos NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    187  1.3  christos NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    188  1.3  christos NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    189  1.3  christos NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    190  1.3  christos NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,"DIGIT","LETTER","UMINUS",NULL,
    191  1.3  christos NULL,NULL,NULL,NULL,"illegal-symbol",
    192  1.1  christos };
    193  1.1  christos static const char *const yyrule[] = {
    194  1.1  christos "$accept : list",
    195  1.1  christos "list :",
    196  1.1  christos "list : list stat '\\n'",
    197  1.1  christos "list : list error '\\n'",
    198  1.1  christos "stat : expr",
    199  1.1  christos "stat : LETTER '=' expr",
    200  1.1  christos "expr : '(' expr ')'",
    201  1.1  christos "expr : expr '+' expr",
    202  1.1  christos "expr : expr '-' expr",
    203  1.1  christos "expr : expr '*' expr",
    204  1.1  christos "expr : expr '/' expr",
    205  1.1  christos "expr : expr '%' expr",
    206  1.1  christos "expr : expr '&' expr",
    207  1.1  christos "expr : expr '|' expr",
    208  1.1  christos "expr : '-' expr",
    209  1.1  christos "expr : LETTER",
    210  1.1  christos "expr : number",
    211  1.1  christos "number : DIGIT",
    212  1.1  christos "number : number DIGIT",
    213  1.1  christos 
    214  1.1  christos };
    215  1.1  christos #endif
    216  1.1  christos 
    217  1.1  christos #if YYDEBUG
    218  1.1  christos int      yydebug;
    219  1.1  christos #endif
    220  1.1  christos 
    221  1.1  christos int      yyerrflag;
    222  1.1  christos int      yychar;
    223  1.1  christos YYSTYPE  yyval;
    224  1.1  christos YYSTYPE  yylval;
    225  1.1  christos int      yynerrs;
    226  1.1  christos 
    227  1.1  christos /* define the initial stack-sizes */
    228  1.1  christos #ifdef YYSTACKSIZE
    229  1.1  christos #undef YYMAXDEPTH
    230  1.1  christos #define YYMAXDEPTH  YYSTACKSIZE
    231  1.1  christos #else
    232  1.1  christos #ifdef YYMAXDEPTH
    233  1.1  christos #define YYSTACKSIZE YYMAXDEPTH
    234  1.1  christos #else
    235  1.1  christos #define YYSTACKSIZE 10000
    236  1.1  christos #define YYMAXDEPTH  10000
    237  1.1  christos #endif
    238  1.1  christos #endif
    239  1.1  christos 
    240  1.1  christos #define YYINITSTACKSIZE 200
    241  1.1  christos 
    242  1.1  christos typedef struct {
    243  1.1  christos     unsigned stacksize;
    244  1.1  christos     YYINT    *s_base;
    245  1.1  christos     YYINT    *s_mark;
    246  1.1  christos     YYINT    *s_last;
    247  1.1  christos     YYSTYPE  *l_base;
    248  1.1  christos     YYSTYPE  *l_mark;
    249  1.1  christos } YYSTACKDATA;
    250  1.1  christos /* variables for the parser stack */
    251  1.1  christos static YYSTACKDATA yystack;
    252  1.1  christos #line 66 "calc.y"
    253  1.1  christos  /* start of programs */
    254  1.1  christos 
    255  1.1  christos int
    256  1.1  christos main (void)
    257  1.1  christos {
    258  1.1  christos     while(!feof(stdin)) {
    259  1.1  christos 	yyparse();
    260  1.1  christos     }
    261  1.1  christos     return 0;
    262  1.1  christos }
    263  1.1  christos 
    264  1.1  christos static void
    265  1.1  christos yyerror(const char *s)
    266  1.1  christos {
    267  1.1  christos     fprintf(stderr, "%s\n", s);
    268  1.1  christos }
    269  1.1  christos 
    270  1.1  christos int
    271  1.1  christos yylex(void)
    272  1.1  christos {
    273  1.1  christos 	/* lexical analysis routine */
    274  1.1  christos 	/* returns LETTER for a lower case letter, yylval = 0 through 25 */
    275  1.1  christos 	/* return DIGIT for a digit, yylval = 0 through 9 */
    276  1.1  christos 	/* all other characters are returned immediately */
    277  1.1  christos 
    278  1.1  christos     int c;
    279  1.1  christos 
    280  1.1  christos     while( (c=getchar()) == ' ' )   { /* skip blanks */ }
    281  1.1  christos 
    282  1.1  christos     /* c is now nonblank */
    283  1.1  christos 
    284  1.1  christos     if( islower( c )) {
    285  1.1  christos 	yylval = c - 'a';
    286  1.1  christos 	return ( LETTER );
    287  1.1  christos     }
    288  1.1  christos     if( isdigit( c )) {
    289  1.1  christos 	yylval = c - '0';
    290  1.1  christos 	return ( DIGIT );
    291  1.1  christos     }
    292  1.1  christos     return( c );
    293  1.1  christos }
    294  1.3  christos #line 293 "prefix.tab.c"
    295  1.1  christos 
    296  1.1  christos #if YYDEBUG
    297  1.1  christos #include <stdio.h>	/* needed for printf */
    298  1.1  christos #endif
    299  1.1  christos 
    300  1.1  christos #include <stdlib.h>	/* needed for malloc, etc */
    301  1.1  christos #include <string.h>	/* needed for memset */
    302  1.1  christos 
    303  1.1  christos /* allocate initial stack or double stack size, up to YYMAXDEPTH */
    304  1.1  christos static int yygrowstack(YYSTACKDATA *data)
    305  1.1  christos {
    306  1.1  christos     int i;
    307  1.1  christos     unsigned newsize;
    308  1.1  christos     YYINT *newss;
    309  1.1  christos     YYSTYPE *newvs;
    310  1.1  christos 
    311  1.1  christos     if ((newsize = data->stacksize) == 0)
    312  1.1  christos         newsize = YYINITSTACKSIZE;
    313  1.1  christos     else if (newsize >= YYMAXDEPTH)
    314  1.1  christos         return YYENOMEM;
    315  1.1  christos     else if ((newsize *= 2) > YYMAXDEPTH)
    316  1.1  christos         newsize = YYMAXDEPTH;
    317  1.1  christos 
    318  1.1  christos     i = (int) (data->s_mark - data->s_base);
    319  1.1  christos     newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
    320  1.3  christos     if (newss == NULL)
    321  1.1  christos         return YYENOMEM;
    322  1.1  christos 
    323  1.1  christos     data->s_base = newss;
    324  1.1  christos     data->s_mark = newss + i;
    325  1.1  christos 
    326  1.1  christos     newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
    327  1.3  christos     if (newvs == NULL)
    328  1.1  christos         return YYENOMEM;
    329  1.1  christos 
    330  1.1  christos     data->l_base = newvs;
    331  1.1  christos     data->l_mark = newvs + i;
    332  1.1  christos 
    333  1.1  christos     data->stacksize = newsize;
    334  1.1  christos     data->s_last = data->s_base + newsize - 1;
    335  1.1  christos     return 0;
    336  1.1  christos }
    337  1.1  christos 
    338  1.1  christos #if YYPURE || defined(YY_NO_LEAKS)
    339  1.1  christos static void yyfreestack(YYSTACKDATA *data)
    340  1.1  christos {
    341  1.1  christos     free(data->s_base);
    342  1.1  christos     free(data->l_base);
    343  1.1  christos     memset(data, 0, sizeof(*data));
    344  1.1  christos }
    345  1.1  christos #else
    346  1.1  christos #define yyfreestack(data) /* nothing */
    347  1.1  christos #endif
    348  1.1  christos 
    349  1.1  christos #define YYABORT  goto yyabort
    350  1.1  christos #define YYREJECT goto yyabort
    351  1.1  christos #define YYACCEPT goto yyaccept
    352  1.1  christos #define YYERROR  goto yyerrlab
    353  1.1  christos 
    354  1.1  christos int
    355  1.1  christos YYPARSE_DECL()
    356  1.1  christos {
    357  1.1  christos     int yym, yyn, yystate;
    358  1.1  christos #if YYDEBUG
    359  1.1  christos     const char *yys;
    360  1.1  christos 
    361  1.3  christos     if ((yys = getenv("YYDEBUG")) != NULL)
    362  1.1  christos     {
    363  1.1  christos         yyn = *yys;
    364  1.1  christos         if (yyn >= '0' && yyn <= '9')
    365  1.1  christos             yydebug = yyn - '0';
    366  1.1  christos     }
    367  1.1  christos #endif
    368  1.1  christos 
    369  1.2  christos     /* yym is set below */
    370  1.2  christos     /* yyn is set below */
    371  1.1  christos     yynerrs = 0;
    372  1.1  christos     yyerrflag = 0;
    373  1.1  christos     yychar = YYEMPTY;
    374  1.1  christos     yystate = 0;
    375  1.1  christos 
    376  1.1  christos #if YYPURE
    377  1.1  christos     memset(&yystack, 0, sizeof(yystack));
    378  1.1  christos #endif
    379  1.1  christos 
    380  1.1  christos     if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
    381  1.1  christos     yystack.s_mark = yystack.s_base;
    382  1.1  christos     yystack.l_mark = yystack.l_base;
    383  1.1  christos     yystate = 0;
    384  1.1  christos     *yystack.s_mark = 0;
    385  1.1  christos 
    386  1.1  christos yyloop:
    387  1.1  christos     if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
    388  1.1  christos     if (yychar < 0)
    389  1.1  christos     {
    390  1.1  christos         yychar = YYLEX;
    391  1.1  christos         if (yychar < 0) yychar = YYEOF;
    392  1.1  christos #if YYDEBUG
    393  1.1  christos         if (yydebug)
    394  1.1  christos         {
    395  1.1  christos             if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
    396  1.1  christos             printf("%sdebug: state %d, reading %d (%s)\n",
    397  1.1  christos                     YYPREFIX, yystate, yychar, yys);
    398  1.1  christos         }
    399  1.1  christos #endif
    400  1.1  christos     }
    401  1.1  christos     if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
    402  1.1  christos             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
    403  1.1  christos     {
    404  1.1  christos #if YYDEBUG
    405  1.1  christos         if (yydebug)
    406  1.1  christos             printf("%sdebug: state %d, shifting to state %d\n",
    407  1.1  christos                     YYPREFIX, yystate, yytable[yyn]);
    408  1.1  christos #endif
    409  1.1  christos         if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
    410  1.1  christos         yystate = yytable[yyn];
    411  1.1  christos         *++yystack.s_mark = yytable[yyn];
    412  1.1  christos         *++yystack.l_mark = yylval;
    413  1.1  christos         yychar = YYEMPTY;
    414  1.1  christos         if (yyerrflag > 0)  --yyerrflag;
    415  1.1  christos         goto yyloop;
    416  1.1  christos     }
    417  1.1  christos     if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
    418  1.1  christos             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
    419  1.1  christos     {
    420  1.1  christos         yyn = yytable[yyn];
    421  1.1  christos         goto yyreduce;
    422  1.1  christos     }
    423  1.1  christos     if (yyerrflag != 0) goto yyinrecovery;
    424  1.1  christos 
    425  1.1  christos     YYERROR_CALL("syntax error");
    426  1.1  christos 
    427  1.1  christos     goto yyerrlab; /* redundant goto avoids 'unused label' warning */
    428  1.1  christos yyerrlab:
    429  1.1  christos     ++yynerrs;
    430  1.1  christos 
    431  1.1  christos yyinrecovery:
    432  1.1  christos     if (yyerrflag < 3)
    433  1.1  christos     {
    434  1.1  christos         yyerrflag = 3;
    435  1.1  christos         for (;;)
    436  1.1  christos         {
    437  1.1  christos             if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
    438  1.1  christos                     yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
    439  1.1  christos             {
    440  1.1  christos #if YYDEBUG
    441  1.1  christos                 if (yydebug)
    442  1.1  christos                     printf("%sdebug: state %d, error recovery shifting\
    443  1.1  christos  to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
    444  1.1  christos #endif
    445  1.1  christos                 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
    446  1.1  christos                 yystate = yytable[yyn];
    447  1.1  christos                 *++yystack.s_mark = yytable[yyn];
    448  1.1  christos                 *++yystack.l_mark = yylval;
    449  1.1  christos                 goto yyloop;
    450  1.1  christos             }
    451  1.1  christos             else
    452  1.1  christos             {
    453  1.1  christos #if YYDEBUG
    454  1.1  christos                 if (yydebug)
    455  1.1  christos                     printf("%sdebug: error recovery discarding state %d\n",
    456  1.1  christos                             YYPREFIX, *yystack.s_mark);
    457  1.1  christos #endif
    458  1.1  christos                 if (yystack.s_mark <= yystack.s_base) goto yyabort;
    459  1.1  christos                 --yystack.s_mark;
    460  1.1  christos                 --yystack.l_mark;
    461  1.1  christos             }
    462  1.1  christos         }
    463  1.1  christos     }
    464  1.1  christos     else
    465  1.1  christos     {
    466  1.1  christos         if (yychar == YYEOF) goto yyabort;
    467  1.1  christos #if YYDEBUG
    468  1.1  christos         if (yydebug)
    469  1.1  christos         {
    470  1.1  christos             if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
    471  1.1  christos             printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
    472  1.1  christos                     YYPREFIX, yystate, yychar, yys);
    473  1.1  christos         }
    474  1.1  christos #endif
    475  1.1  christos         yychar = YYEMPTY;
    476  1.1  christos         goto yyloop;
    477  1.1  christos     }
    478  1.1  christos 
    479  1.1  christos yyreduce:
    480  1.1  christos #if YYDEBUG
    481  1.1  christos     if (yydebug)
    482  1.1  christos         printf("%sdebug: state %d, reducing by rule %d (%s)\n",
    483  1.1  christos                 YYPREFIX, yystate, yyn, yyrule[yyn]);
    484  1.1  christos #endif
    485  1.1  christos     yym = yylen[yyn];
    486  1.1  christos     if (yym > 0)
    487  1.1  christos         yyval = yystack.l_mark[1-yym];
    488  1.1  christos     else
    489  1.1  christos         memset(&yyval, 0, sizeof yyval);
    490  1.1  christos 
    491  1.1  christos     switch (yyn)
    492  1.1  christos     {
    493  1.1  christos case 3:
    494  1.1  christos #line 28 "calc.y"
    495  1.1  christos 	{  yyerrok ; }
    496  1.3  christos #line 495 "prefix.tab.c"
    497  1.1  christos break;
    498  1.1  christos case 4:
    499  1.1  christos #line 32 "calc.y"
    500  1.1  christos 	{  printf("%d\n",yystack.l_mark[0]);}
    501  1.3  christos #line 500 "prefix.tab.c"
    502  1.1  christos break;
    503  1.1  christos case 5:
    504  1.1  christos #line 34 "calc.y"
    505  1.1  christos 	{  regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
    506  1.3  christos #line 505 "prefix.tab.c"
    507  1.1  christos break;
    508  1.1  christos case 6:
    509  1.1  christos #line 38 "calc.y"
    510  1.1  christos 	{  yyval = yystack.l_mark[-1]; }
    511  1.3  christos #line 510 "prefix.tab.c"
    512  1.1  christos break;
    513  1.1  christos case 7:
    514  1.1  christos #line 40 "calc.y"
    515  1.1  christos 	{  yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
    516  1.3  christos #line 515 "prefix.tab.c"
    517  1.1  christos break;
    518  1.1  christos case 8:
    519  1.1  christos #line 42 "calc.y"
    520  1.1  christos 	{  yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
    521  1.3  christos #line 520 "prefix.tab.c"
    522  1.1  christos break;
    523  1.1  christos case 9:
    524  1.1  christos #line 44 "calc.y"
    525  1.1  christos 	{  yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
    526  1.3  christos #line 525 "prefix.tab.c"
    527  1.1  christos break;
    528  1.1  christos case 10:
    529  1.1  christos #line 46 "calc.y"
    530  1.1  christos 	{  yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
    531  1.3  christos #line 530 "prefix.tab.c"
    532  1.1  christos break;
    533  1.1  christos case 11:
    534  1.1  christos #line 48 "calc.y"
    535  1.1  christos 	{  yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
    536  1.3  christos #line 535 "prefix.tab.c"
    537  1.1  christos break;
    538  1.1  christos case 12:
    539  1.1  christos #line 50 "calc.y"
    540  1.1  christos 	{  yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
    541  1.3  christos #line 540 "prefix.tab.c"
    542  1.1  christos break;
    543  1.1  christos case 13:
    544  1.1  christos #line 52 "calc.y"
    545  1.1  christos 	{  yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
    546  1.3  christos #line 545 "prefix.tab.c"
    547  1.1  christos break;
    548  1.1  christos case 14:
    549  1.1  christos #line 54 "calc.y"
    550  1.1  christos 	{  yyval = - yystack.l_mark[0]; }
    551  1.3  christos #line 550 "prefix.tab.c"
    552  1.1  christos break;
    553  1.1  christos case 15:
    554  1.1  christos #line 56 "calc.y"
    555  1.1  christos 	{  yyval = regs[yystack.l_mark[0]]; }
    556  1.3  christos #line 555 "prefix.tab.c"
    557  1.1  christos break;
    558  1.1  christos case 17:
    559  1.1  christos #line 61 "calc.y"
    560  1.1  christos 	{  yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
    561  1.3  christos #line 560 "prefix.tab.c"
    562  1.1  christos break;
    563  1.1  christos case 18:
    564  1.1  christos #line 63 "calc.y"
    565  1.1  christos 	{  yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
    566  1.3  christos #line 565 "prefix.tab.c"
    567  1.1  christos break;
    568  1.3  christos #line 567 "prefix.tab.c"
    569  1.1  christos     }
    570  1.1  christos     yystack.s_mark -= yym;
    571  1.1  christos     yystate = *yystack.s_mark;
    572  1.1  christos     yystack.l_mark -= yym;
    573  1.1  christos     yym = yylhs[yyn];
    574  1.1  christos     if (yystate == 0 && yym == 0)
    575  1.1  christos     {
    576  1.1  christos #if YYDEBUG
    577  1.1  christos         if (yydebug)
    578  1.1  christos             printf("%sdebug: after reduction, shifting from state 0 to\
    579  1.1  christos  state %d\n", YYPREFIX, YYFINAL);
    580  1.1  christos #endif
    581  1.1  christos         yystate = YYFINAL;
    582  1.1  christos         *++yystack.s_mark = YYFINAL;
    583  1.1  christos         *++yystack.l_mark = yyval;
    584  1.1  christos         if (yychar < 0)
    585  1.1  christos         {
    586  1.1  christos             yychar = YYLEX;
    587  1.1  christos             if (yychar < 0) yychar = YYEOF;
    588  1.1  christos #if YYDEBUG
    589  1.1  christos             if (yydebug)
    590  1.1  christos             {
    591  1.1  christos                 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
    592  1.1  christos                 printf("%sdebug: state %d, reading %d (%s)\n",
    593  1.1  christos                         YYPREFIX, YYFINAL, yychar, yys);
    594  1.1  christos             }
    595  1.1  christos #endif
    596  1.1  christos         }
    597  1.1  christos         if (yychar == YYEOF) goto yyaccept;
    598  1.1  christos         goto yyloop;
    599  1.1  christos     }
    600  1.1  christos     if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
    601  1.1  christos             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
    602  1.1  christos         yystate = yytable[yyn];
    603  1.1  christos     else
    604  1.1  christos         yystate = yydgoto[yym];
    605  1.1  christos #if YYDEBUG
    606  1.1  christos     if (yydebug)
    607  1.1  christos         printf("%sdebug: after reduction, shifting from state %d \
    608  1.1  christos to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
    609  1.1  christos #endif
    610  1.1  christos     if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
    611  1.1  christos     *++yystack.s_mark = (YYINT) yystate;
    612  1.1  christos     *++yystack.l_mark = yyval;
    613  1.1  christos     goto yyloop;
    614  1.1  christos 
    615  1.1  christos yyoverflow:
    616  1.1  christos     YYERROR_CALL("yacc stack overflow");
    617  1.1  christos 
    618  1.1  christos yyabort:
    619  1.1  christos     yyfreestack(&yystack);
    620  1.1  christos     return (1);
    621  1.1  christos 
    622  1.1  christos yyaccept:
    623  1.1  christos     yyfreestack(&yystack);
    624  1.1  christos     return (0);
    625  1.1  christos }
    626