Ignore:
Timestamp:
Sep 14, 2010, 1:13:20 AM (15 years ago)
Author:
bird
Message:

kash: trimmed down the arith stuff, making it not drag in libc bits.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kash/generated/arith.c

    r1233 r2415  
    11#ifndef lint
    2 /*static char yysccsid[] = "from: @(#)yaccpar   1.9 (Berkeley) 02/21/93";*/
    3 static char yyrcsid[] = "$Id$";
    4 #endif
     2static const char yysccsid[] = "@(#)yaccpar     1.9 (Berkeley) 02/21/93";
     3#endif
     4
     5#include <stdlib.h>
     6#include <string.h>
     7
    58#define YYBYACC 1
    69#define YYMAJOR 1
    710#define YYMINOR 9
    8 #define yyclearin (yychar=(-1))
    9 #define yyerrok (yyerrflag=0)
    10 #define YYRECOVERING (yyerrflag!=0)
     11#define YYPATCH 20091027
     12
     13#define YYEMPTY        (-1)
     14#define yyclearin      (yychar = YYEMPTY)
     15#define yyerrok        (yyerrflag = 0)
     16#define YYRECOVERING() (yyerrflag != 0)
     17
     18/* compatibility with bison */
     19#ifdef YYPARSE_PARAM
     20/* compatibility with FreeBSD */
     21#ifdef YYPARSE_PARAM_TYPE
     22#define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
     23#else
     24#define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
     25#endif
     26#else
     27#define YYPARSE_DECL() yyparse(void)
     28#endif /* YYPARSE_PARAM */
     29
     30extern int YYPARSE_DECL();
     31
     32static int yygrowstack(void);
    1133#define YYPREFIX "yy"
    1234/*      $NetBSD: arith.y,v 1.17 2003/09/17 17:33:36 jmmv Exp $  */
     
    6789int main(int , char *[]);
    6890int error(char *);
     91#else
     92# undef  malloc
     93# define malloc(cb)        sh_malloc(NULL, (cb))
     94# undef  realloc
     95# define realloc(pv,cb)    sh_realloc(NULL, (pv), (cb))
     96# undef  free
     97# define free(pv)          sh_free(NULL, (pv))
    6998#endif
    7099
     
    95124#define ARITH_BNOT 281
    96125#define YYERRCODE 256
    97 short yylhs[] = {                                        -1,
     126static const short yylhs[] = {                           -1,
    98127    0,    1,    1,    1,    1,    1,    1,    1,    1,    1,
    99128    1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
    100129    1,    1,    1,    1,    1,
    101130};
    102 short yylen[] = {                                         2,
     131static const short yylen[] = {                            2,
    103132    1,    3,    3,    3,    3,    3,    3,    3,    3,    3,
    104133    3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
    105134    2,    2,    2,    2,    1,
    106135};
    107 short yydefred[] = {                                      0,
     136static const short yydefred[] = {                         0,
    108137   25,    0,    0,    0,    0,    0,    0,    0,    0,   24,
    109138   23,   21,   22,    0,    0,    0,    0,    0,    0,    0,
     
    112141    0,    0,    0,    0,    0,    0,    0,   18,   19,   20,
    113142};
    114 short yydgoto[] = {                                       7,
     143static const short yydgoto[] = {                          7,
    115144    8,
    116145};
    117 short yysindex[] = {                                   -255,
     146static const short yysindex[] = {                      -255,
    118147    0, -255, -255, -255, -255, -255,    0,  -67,  -85,    0,
    119148    0,    0,    0, -255, -255, -255, -255, -255, -255, -255,
     
    122151 -223, -223, -223, -253, -253, -248, -248,    0,    0,    0,
    123152};
    124 short yyrindex[] = {                                      0,
     153static const short yyrindex[] = {                         0,
    125154    0,    0,    0,    0,    0,    0,    0,   30,    0,    0,
    126155    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     
    129158   73,   85,   97,   33,   47,    1,   17,    0,    0,    0,
    130159};
    131 short yygindex[] = {                                      0,
     160static const short yygindex[] = {                         0,
    132161  142,
    133162};
    134163#define YYTABLESIZE 418
    135 short yytable[] = {                                       0,
     164static const short yytable[] = {                          0,
    136165   16,    1,    2,   19,   20,   21,   22,   23,   24,   25,
    137166   26,   27,   28,   29,   30,   31,   17,    3,    4,   27,
     
    177206   24,   25,   26,   27,   28,   29,   30,   31,
    178207};
    179 short yycheck[] = {                                      -1,
     208static const short yycheck[] = {                         -1,
    180209    0,  257,  258,  265,  266,  267,  268,  269,  270,  271,
    181210  272,  273,  274,  275,  276,  277,    0,  273,  274,  273,
     
    227256#define YYMAXTOKEN 281
    228257#if YYDEBUG
    229 char *yyname[] = {
     258static const char *yyname[] = {
     259
    230260"end-of-file",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,
    2312610,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,
     
    240270"ARITH_REM","ARITH_UNARYMINUS","ARITH_UNARYPLUS","ARITH_NOT","ARITH_BNOT",
    241271};
    242 char *yyrule[] = {
     272static const char *yyrule[] = {
    243273"$accept : exp",
    244274"exp : expr",
     
    267297"expr : ARITH_ADD expr",
    268298"expr : ARITH_NUM",
     299
    269300};
    270301#endif
     
    272303typedef int YYSTYPE;
    273304#endif
     305#if YYDEBUG
     306#include <stdio.h>
     307#endif
     308
     309/* define the initial stack-sizes */
    274310#ifdef YYSTACKSIZE
    275311#undef YYMAXDEPTH
    276 #define YYMAXDEPTH YYSTACKSIZE
     312#define YYMAXDEPTH  YYSTACKSIZE
    277313#else
    278314#ifdef YYMAXDEPTH
     
    280316#else
    281317#define YYSTACKSIZE 500
    282 #define YYMAXDEPTH 500
    283 #endif
    284 #endif
    285 int yydebug;
    286 int yynerrs;
    287 int yyerrflag;
    288 int yychar;
    289 short *yyssp;
     318#define YYMAXDEPTH  500
     319#endif
     320#endif
     321
     322#define YYINITSTACKSIZE 500
     323
     324int      yydebug;
     325int      yynerrs;
     326int      yyerrflag;
     327int      yychar;
     328short   *yyssp;
    290329YYSTYPE *yyvsp;
    291 YYSTYPE yyval;
    292 YYSTYPE yylval;
    293 short yyss[YYSTACKSIZE];
    294 YYSTYPE yyvs[YYSTACKSIZE];
    295 #define yystacksize YYSTACKSIZE
     330YYSTYPE  yyval;
     331YYSTYPE  yylval;
     332
     333/* variables for the parser stack */
     334static short   *yyss;
     335static short   *yysslim;
     336static YYSTYPE *yyvs;
     337static unsigned yystacksize;
    296338int
    297339arith(shinstance *psh, const char *s)
     
    370412yyerror(const char *s)
    371413{
    372    shinstance *psh = arith_psh;
     414    shinstance *psh = arith_psh;
     415#ifndef YYBISON /* yyerrok references yyerrstatus which is a local variable in yyparse().*/
    373416        yyerrok;
     417#endif
    374418        yyclearin;
    375419        arith_lex_reset();      /* reprime lex */
     
    378422        /* NOTREACHED */
    379423}
    380 #define YYABORT goto yyabort
     424/* allocate initial stack or double stack size, up to YYMAXDEPTH */
     425static int yygrowstack(void)
     426{
     427    int i;
     428    unsigned newsize;
     429    short *newss;
     430    YYSTYPE *newvs;
     431
     432    if ((newsize = yystacksize) == 0)
     433        newsize = YYINITSTACKSIZE;
     434    else if (newsize >= YYMAXDEPTH)
     435        return -1;
     436    else if ((newsize *= 2) > YYMAXDEPTH)
     437        newsize = YYMAXDEPTH;
     438
     439    i = yyssp - yyss;
     440    newss = (yyss != 0)
     441          ? (short *)realloc(yyss, newsize * sizeof(*newss))
     442          : (short *)malloc(newsize * sizeof(*newss));
     443    if (newss == 0)
     444        return -1;
     445
     446    yyss  = newss;
     447    yyssp = newss + i;
     448    newvs = (yyvs != 0)
     449          ? (YYSTYPE *)realloc(yyvs, newsize * sizeof(*newvs))
     450          : (YYSTYPE *)malloc(newsize * sizeof(*newvs));
     451    if (newvs == 0)
     452        return -1;
     453
     454    yyvs = newvs;
     455    yyvsp = newvs + i;
     456    yystacksize = newsize;
     457    yysslim = yyss + newsize - 1;
     458    return 0;
     459}
     460
     461#define YYABORT  goto yyabort
    381462#define YYREJECT goto yyabort
    382463#define YYACCEPT goto yyaccept
    383 #define YYERROR goto yyerrlab
    384 #ifdef __cplusplus
    385 extern "C" {
    386 char * getenv();
    387 int yylex();
    388 int yyparse();
    389 }
    390 
    391 #endif
     464#define YYERROR  goto yyerrlab
     465
    392466int
    393 #if defined(__STDC__)
    394 yyparse(void)
    395 #else
    396 yyparse()
    397 #endif
     467YYPARSE_DECL()
    398468{
    399     register int yym, yyn, yystate;
    400 #if YYDEBUG
    401     register char *yys;
    402 #ifndef __cplusplus
    403     extern char *getenv();
    404 #endif
    405 
    406     if (yys = getenv("YYDEBUG"))
     469    int yym, yyn, yystate;
     470#if YYDEBUG
     471    const char *yys;
     472
     473    if ((yys = getenv("YYDEBUG")) != 0)
    407474    {
    408475        yyn = *yys;
     
    414481    yynerrs = 0;
    415482    yyerrflag = 0;
    416     yychar = (-1);
    417 
     483    yychar = YYEMPTY;
     484    yystate = 0;
     485
     486    if (yyss == NULL && yygrowstack()) goto yyoverflow;
    418487    yyssp = yyss;
    419488    yyvsp = yyvs;
    420     *yyssp = yystate = 0;
     489    yystate = 0;
     490    *yyssp = 0;
    421491
    422492yyloop:
     
    444514                    YYPREFIX, yystate, yytable[yyn]);
    445515#endif
    446         if (yyssp >= yyss + yystacksize - 1)
     516        if (yyssp >= yysslim && yygrowstack())
    447517        {
    448518            goto yyoverflow;
    449519        }
    450         *++yyssp = yystate = yytable[yyn];
     520        yystate = yytable[yyn];
     521        *++yyssp = yytable[yyn];
    451522        *++yyvsp = yylval;
    452         yychar = (-1);
     523        yychar = YYEMPTY;
    453524        if (yyerrflag > 0)  --yyerrflag;
    454525        goto yyloop;
     
    461532    }
    462533    if (yyerrflag) goto yyinrecovery;
     534
    463535    yyerror("syntax error");
    464 #ifdef lint
     536
    465537    goto yyerrlab;
    466 #endif
     538
    467539yyerrlab:
    468540    ++yynerrs;
     541
    469542yyinrecovery:
    470543    if (yyerrflag < 3)
     
    481554 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
    482555#endif
    483                 if (yyssp >= yyss + yystacksize - 1)
     556                if (yyssp >= yysslim && yygrowstack())
    484557                {
    485558                    goto yyoverflow;
    486559                }
    487                 *++yyssp = yystate = yytable[yyn];
     560                yystate = yytable[yyn];
     561                *++yyssp = yytable[yyn];
    488562                *++yyvsp = yylval;
    489563                goto yyloop;
     
    515589        }
    516590#endif
    517         yychar = (-1);
     591        yychar = YYEMPTY;
    518592        goto yyloop;
    519593    }
     594
    520595yyreduce:
    521596#if YYDEBUG
     
    525600#endif
    526601    yym = yylen[yyn];
    527     yyval = yyvsp[1-yym];
     602    if (yym)
     603        yyval = yyvsp[1-yym];
     604    else
     605        memset(&yyval, 0, sizeof yyval);
    528606    switch (yyn)
    529607    {
    530608case 1:
    531 {
     609        {
    532610                        return (yyvsp[0]);
    533611                }
    534612break;
    535613case 2:
    536 { yyval = yyvsp[-1]; }
     614        { yyval = yyvsp[-1]; }
    537615break;
    538616case 3:
    539 { yyval = yyvsp[-2] ? yyvsp[-2] : yyvsp[0] ? yyvsp[0] : 0; }
     617        { yyval = yyvsp[-2] ? yyvsp[-2] : yyvsp[0] ? yyvsp[0] : 0; }
    540618break;
    541619case 4:
    542 { yyval = yyvsp[-2] ? ( yyvsp[0] ? yyvsp[0] : 0 ) : 0; }
     620        { yyval = yyvsp[-2] ? ( yyvsp[0] ? yyvsp[0] : 0 ) : 0; }
    543621break;
    544622case 5:
    545 { yyval = yyvsp[-2] | yyvsp[0]; }
     623        { yyval = yyvsp[-2] | yyvsp[0]; }
    546624break;
    547625case 6:
    548 { yyval = yyvsp[-2] ^ yyvsp[0]; }
     626        { yyval = yyvsp[-2] ^ yyvsp[0]; }
    549627break;
    550628case 7:
    551 { yyval = yyvsp[-2] & yyvsp[0]; }
     629        { yyval = yyvsp[-2] & yyvsp[0]; }
    552630break;
    553631case 8:
    554 { yyval = yyvsp[-2] == yyvsp[0]; }
     632        { yyval = yyvsp[-2] == yyvsp[0]; }
    555633break;
    556634case 9:
    557 { yyval = yyvsp[-2] > yyvsp[0]; }
     635        { yyval = yyvsp[-2] > yyvsp[0]; }
    558636break;
    559637case 10:
    560 { yyval = yyvsp[-2] >= yyvsp[0]; }
     638        { yyval = yyvsp[-2] >= yyvsp[0]; }
    561639break;
    562640case 11:
    563 { yyval = yyvsp[-2] < yyvsp[0]; }
     641        { yyval = yyvsp[-2] < yyvsp[0]; }
    564642break;
    565643case 12:
    566 { yyval = yyvsp[-2] <= yyvsp[0]; }
     644        { yyval = yyvsp[-2] <= yyvsp[0]; }
    567645break;
    568646case 13:
    569 { yyval = yyvsp[-2] != yyvsp[0]; }
     647        { yyval = yyvsp[-2] != yyvsp[0]; }
    570648break;
    571649case 14:
    572 { yyval = yyvsp[-2] << yyvsp[0]; }
     650        { yyval = yyvsp[-2] << yyvsp[0]; }
    573651break;
    574652case 15:
    575 { yyval = yyvsp[-2] >> yyvsp[0]; }
     653        { yyval = yyvsp[-2] >> yyvsp[0]; }
    576654break;
    577655case 16:
    578 { yyval = yyvsp[-2] + yyvsp[0]; }
     656        { yyval = yyvsp[-2] + yyvsp[0]; }
    579657break;
    580658case 17:
    581 { yyval = yyvsp[-2] - yyvsp[0]; }
     659        { yyval = yyvsp[-2] - yyvsp[0]; }
    582660break;
    583661case 18:
    584 { yyval = yyvsp[-2] * yyvsp[0]; }
     662        { yyval = yyvsp[-2] * yyvsp[0]; }
    585663break;
    586664case 19:
    587 {
     665        {
    588666                        if (yyvsp[0] == 0)
    589667                                yyerror("division by zero");
     
    592670break;
    593671case 20:
    594 {
     672        {
    595673                        if (yyvsp[0] == 0)
    596674                                yyerror("division by zero");
     
    599677break;
    600678case 21:
    601 { yyval = !(yyvsp[0]); }
     679        { yyval = !(yyvsp[0]); }
    602680break;
    603681case 22:
    604 { yyval = ~(yyvsp[0]); }
     682        { yyval = ~(yyvsp[0]); }
    605683break;
    606684case 23:
    607 { yyval = -(yyvsp[0]); }
     685        { yyval = -(yyvsp[0]); }
    608686break;
    609687case 24:
    610 { yyval = yyvsp[0]; }
     688        { yyval = yyvsp[0]; }
    611689break;
    612690    }
     
    652730to state %d\n", YYPREFIX, *yyssp, yystate);
    653731#endif
    654     if (yyssp >= yyss + yystacksize - 1)
     732    if (yyssp >= yysslim && yygrowstack())
    655733    {
    656734        goto yyoverflow;
    657735    }
    658     *++yyssp = yystate;
     736    *++yyssp = (short) yystate;
    659737    *++yyvsp = yyval;
    660738    goto yyloop;
     739
    661740yyoverflow:
    662741    yyerror("yacc stack overflow");
     742
    663743yyabort:
    664744    return (1);
     745
    665746yyaccept:
    666747    return (0);
Note: See TracChangeset for help on using the changeset viewer.