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