OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [sys/] [linux/] [intl/] [plural.c] - Blame information for rev 148

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
 
2
/*  A Bison parser, made from plural.y
3
    by GNU Bison version 1.28  */
4
 
5
#define YYBISON 1  /* Identify Bison output.  */
6
 
7
#define yyparse __gettextparse
8
#define yylex __gettextlex
9
#define yyerror __gettexterror
10
#define yylval __gettextlval
11
#define yychar __gettextchar
12
#define yydebug __gettextdebug
13
#define yynerrs __gettextnerrs
14
#define EQUOP2  257
15
#define CMPOP2  258
16
#define ADDOP2  259
17
#define MULOP2  260
18
#define NUMBER  261
19
 
20
#line 1 "plural.y"
21
 
22
/* Expression parsing for plural form selection.
23
   Copyright (C) 2000, 2001 Free Software Foundation, Inc.
24
   This file is part of the GNU C Library.
25
   Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
26
 
27
   The GNU C Library is free software; you can redistribute it and/or
28
   modify it under the terms of the GNU Lesser General Public
29
   License as published by the Free Software Foundation; either
30
   version 2.1 of the License, or (at your option) any later version.
31
 
32
   The GNU C Library is distributed in the hope that it will be useful,
33
   but WITHOUT ANY WARRANTY; without even the implied warranty of
34
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
35
   Lesser General Public License for more details.
36
 
37
   You should have received a copy of the GNU Lesser General Public
38
   License along with the GNU C Library; if not, write to the Free
39
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
40
   02111-1307 USA.  */
41
 
42
#ifdef HAVE_CONFIG_H
43
# include <config.h>
44
#endif
45
 
46
#include <stdlib.h>
47
#include "gettextP.h"
48
 
49
/* Names for the libintl functions are a problem.  They must not clash
50
   with existing names and they should follow ANSI C.  But this source
51
   code is also used in GNU C Library where the names have a __
52
   prefix.  So we have to make a difference here.  */
53
#ifdef _LIBC
54
# define FREE_EXPRESSION __gettext_free_exp
55
#else
56
# define FREE_EXPRESSION gettext_free_exp__
57
# define __gettextparse gettextparse__
58
#endif
59
 
60
#define YYLEX_PARAM     &((struct parse_args *) arg)->cp
61
#define YYPARSE_PARAM   arg
62
 
63
#line 46 "plural.y"
64
typedef union {
65
  unsigned long int num;
66
  enum operator op;
67
  struct expression *exp;
68
} YYSTYPE;
69
#line 52 "plural.y"
70
 
71
/* Prototypes for local functions.  */
72
static struct expression *new_exp PARAMS ((int nargs, enum operator op,
73
                                           struct expression * const *args));
74
static inline struct expression *new_exp_0 PARAMS ((enum operator op));
75
static inline struct expression *new_exp_1 PARAMS ((enum operator op,
76
                                                   struct expression *right));
77
static struct expression *new_exp_2 PARAMS ((enum operator op,
78
                                             struct expression *left,
79
                                             struct expression *right));
80
static inline struct expression *new_exp_3 PARAMS ((enum operator op,
81
                                                   struct expression *bexp,
82
                                                   struct expression *tbranch,
83
                                                   struct expression *fbranch));
84
static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
85
static void yyerror PARAMS ((const char *str));
86
 
87
/* Allocation of expressions.  */
88
 
89
static struct expression *
90
new_exp (nargs, op, args)
91
     int nargs;
92
     enum operator op;
93
     struct expression * const *args;
94
{
95
  int i;
96
  struct expression *newp;
97
 
98
  /* If any of the argument could not be malloc'ed, just return NULL.  */
99
  for (i = nargs - 1; i >= 0; i--)
100
    if (args[i] == NULL)
101
      goto fail;
102
 
103
  /* Allocate a new expression.  */
104
  newp = (struct expression *) malloc (sizeof (*newp));
105
  if (newp != NULL)
106
    {
107
      newp->nargs = nargs;
108
      newp->operation = op;
109
      for (i = nargs - 1; i >= 0; i--)
110
        newp->val.args[i] = args[i];
111
      return newp;
112
    }
113
 
114
 fail:
115
  for (i = nargs - 1; i >= 0; i--)
116
    FREE_EXPRESSION (args[i]);
117
 
118
  return NULL;
119
}
120
 
121
static inline struct expression *
122
new_exp_0 (op)
123
     enum operator op;
124
{
125
  return new_exp (0, op, NULL);
126
}
127
 
128
static inline struct expression *
129
new_exp_1 (op, right)
130
     enum operator op;
131
     struct expression *right;
132
{
133
  struct expression *args[1];
134
 
135
  args[0] = right;
136
  return new_exp (1, op, args);
137
}
138
 
139
static struct expression *
140
new_exp_2 (op, left, right)
141
     enum operator op;
142
     struct expression *left;
143
     struct expression *right;
144
{
145
  struct expression *args[2];
146
 
147
  args[0] = left;
148
  args[1] = right;
149
  return new_exp (2, op, args);
150
}
151
 
152
static inline struct expression *
153
new_exp_3 (op, bexp, tbranch, fbranch)
154
     enum operator op;
155
     struct expression *bexp;
156
     struct expression *tbranch;
157
     struct expression *fbranch;
158
{
159
  struct expression *args[3];
160
 
161
  args[0] = bexp;
162
  args[1] = tbranch;
163
  args[2] = fbranch;
164
  return new_exp (3, op, args);
165
}
166
 
167
#include <stdio.h>
168
 
169
#ifndef __cplusplus
170
#ifndef __STDC__
171
#define const
172
#endif
173
#endif
174
 
175
 
176
 
177
#define YYFINAL         27
178
#define YYFLAG          -32768
179
#define YYNTBASE        16
180
 
181
#define YYTRANSLATE(x) ((unsigned)(x) <= 261 ? yytranslate[x] : 18)
182
 
183
static const char yytranslate[] = {     0,
184
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
185
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
186
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
187
     2,     2,    10,     2,     2,     2,     2,     5,     2,    14,
188
    15,     2,     2,     2,     2,     2,     2,     2,     2,     2,
189
     2,     2,     2,     2,     2,     2,     2,    12,     2,     2,
190
     2,     2,     3,     2,     2,     2,     2,     2,     2,     2,
191
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
192
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
193
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
194
     2,     2,     2,     2,     2,     2,     2,     2,     2,    13,
195
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
196
     2,     2,     2,     4,     2,     2,     2,     2,     2,     2,
197
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
198
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
199
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
200
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
201
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
202
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
203
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
204
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
205
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
206
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
207
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
208
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
209
     2,     2,     2,     2,     2,     1,     6,     7,     8,     9,
210
    11
211
};
212
 
213
#if YYDEBUG != 0
214
static const short yyprhs[] = {     0,
215
     0,     2,     8,    12,    16,    20,    24,    28,    32,    35,
216
    37,    39
217
};
218
 
219
static const short yyrhs[] = {    17,
220
     0,    17,     3,    17,    12,    17,     0,    17,     4,    17,
221
     0,    17,     5,    17,     0,    17,     6,    17,     0,    17,
222
     7,    17,     0,    17,     8,    17,     0,    17,     9,    17,
223
     0,    10,    17,     0,    13,     0,    11,     0,    14,    17,
224
    15,     0
225
};
226
 
227
#endif
228
 
229
#if YYDEBUG != 0
230
static const short yyrline[] = { 0,
231
   171,   179,   183,   187,   191,   195,   199,   203,   207,   211,
232
   215,   220
233
};
234
#endif
235
 
236
 
237
#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
238
 
239
static const char * const yytname[] = {   "$","error","$undefined.","'?'","'|'",
240
"'&'","EQUOP2","CMPOP2","ADDOP2","MULOP2","'!'","NUMBER","':'","'n'","'('","')'",
241
"start","exp", NULL
242
};
243
#endif
244
 
245
static const short yyr1[] = {     0,
246
    16,    17,    17,    17,    17,    17,    17,    17,    17,    17,
247
    17,    17
248
};
249
 
250
static const short yyr2[] = {     0,
251
     1,     5,     3,     3,     3,     3,     3,     3,     2,     1,
252
     1,     3
253
};
254
 
255
static const short yydefact[] = {     0,
256
     0,    11,    10,     0,     1,     9,     0,     0,     0,     0,
257
     0,     0,     0,     0,    12,     0,     3,     4,     5,     6,
258
     7,     8,     0,     2,     0,     0,     0
259
};
260
 
261
static const short yydefgoto[] = {    25,
262
     5
263
};
264
 
265
static const short yypact[] = {    -9,
266
    -9,-32768,-32768,    -9,    34,-32768,    11,    -9,    -9,    -9,
267
    -9,    -9,    -9,    -9,-32768,    24,    39,    43,    16,    26,
268
    -3,-32768,    -9,    34,    21,    53,-32768
269
};
270
 
271
static const short yypgoto[] = {-32768,
272
    -1
273
};
274
 
275
 
276
#define YYLAST          53
277
 
278
 
279
static const short yytable[] = {     6,
280
     1,     2,     7,     3,     4,    14,    16,    17,    18,    19,
281
    20,    21,    22,     8,     9,    10,    11,    12,    13,    14,
282
    26,    24,    12,    13,    14,    15,     8,     9,    10,    11,
283
    12,    13,    14,    13,    14,    23,     8,     9,    10,    11,
284
    12,    13,    14,    10,    11,    12,    13,    14,    11,    12,
285
    13,    14,    27
286
};
287
 
288
static const short yycheck[] = {     1,
289
    10,    11,     4,    13,    14,     9,     8,     9,    10,    11,
290
    12,    13,    14,     3,     4,     5,     6,     7,     8,     9,
291
     0,    23,     7,     8,     9,    15,     3,     4,     5,     6,
292
     7,     8,     9,     8,     9,    12,     3,     4,     5,     6,
293
     7,     8,     9,     5,     6,     7,     8,     9,     6,     7,
294
     8,     9,     0
295
};
296
#define YYPURE 1
297
 
298
/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
299
#line 3 "/usr/lib/bison.simple"
300
/* This file comes from bison-1.28.  */
301
 
302
/* Skeleton output parser for bison,
303
   Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
304
 
305
   This program is free software; you can redistribute it and/or modify
306
   it under the terms of the GNU General Public License as published by
307
   the Free Software Foundation; either version 2, or (at your option)
308
   any later version.
309
 
310
   This program is distributed in the hope that it will be useful,
311
   but WITHOUT ANY WARRANTY; without even the implied warranty of
312
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
313
   GNU General Public License for more details.
314
 
315
   You should have received a copy of the GNU General Public License
316
   along with this program; if not, write to the Free Software
317
   Foundation, Inc., 59 Temple Place - Suite 330,
318
   Boston, MA 02111-1307, USA.  */
319
 
320
/* As a special exception, when this file is copied by Bison into a
321
   Bison output file, you may use that output file without restriction.
322
   This special exception was added by the Free Software Foundation
323
   in version 1.24 of Bison.  */
324
 
325
/* This is the parser code that is written into each bison parser
326
  when the %semantic_parser declaration is not specified in the grammar.
327
  It was written by Richard Stallman by simplifying the hairy parser
328
  used when %semantic_parser is specified.  */
329
 
330
#ifndef YYSTACK_USE_ALLOCA
331
#ifdef alloca
332
#define YYSTACK_USE_ALLOCA
333
#else /* alloca not defined */
334
#ifdef __GNUC__
335
#define YYSTACK_USE_ALLOCA
336
#define alloca __builtin_alloca
337
#else /* not GNU C.  */
338
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
339
#define YYSTACK_USE_ALLOCA
340
#include <alloca.h>
341
#else /* not sparc */
342
/* We think this test detects Watcom and Microsoft C.  */
343
/* This used to test MSDOS, but that is a bad idea
344
   since that symbol is in the user namespace.  */
345
#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
346
#if 0 /* No need for malloc.h, which pollutes the namespace;
347
         instead, just don't use alloca.  */
348
#include <malloc.h>
349
#endif
350
#else /* not MSDOS, or __TURBOC__ */
351
#if defined(_AIX)
352
/* I don't know what this was needed for, but it pollutes the namespace.
353
   So I turned it off.   rms, 2 May 1997.  */
354
/* #include <malloc.h>  */
355
 #pragma alloca
356
#define YYSTACK_USE_ALLOCA
357
#else /* not MSDOS, or __TURBOC__, or _AIX */
358
#if 0
359
#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
360
                 and on HPUX 10.  Eventually we can turn this on.  */
361
#define YYSTACK_USE_ALLOCA
362
#define alloca __builtin_alloca
363
#endif /* __hpux */
364
#endif
365
#endif /* not _AIX */
366
#endif /* not MSDOS, or __TURBOC__ */
367
#endif /* not sparc */
368
#endif /* not GNU C */
369
#endif /* alloca not defined */
370
#endif /* YYSTACK_USE_ALLOCA not defined */
371
 
372
#ifdef YYSTACK_USE_ALLOCA
373
#define YYSTACK_ALLOC alloca
374
#else
375
#define YYSTACK_ALLOC malloc
376
#endif
377
 
378
/* Note: there must be only one dollar sign in this file.
379
   It is replaced by the list of actions, each action
380
   as one case of the switch.  */
381
 
382
#define yyerrok         (yyerrstatus = 0)
383
#define yyclearin       (yychar = YYEMPTY)
384
#define YYEMPTY         -2
385
#define YYEOF           0
386
#define YYACCEPT        goto yyacceptlab
387
#define YYABORT         goto yyabortlab
388
#define YYERROR         goto yyerrlab1
389
/* Like YYERROR except do call yyerror.
390
   This remains here temporarily to ease the
391
   transition to the new meaning of YYERROR, for GCC.
392
   Once GCC version 2 has supplanted version 1, this can go.  */
393
#define YYFAIL          goto yyerrlab
394
#define YYRECOVERING()  (!!yyerrstatus)
395
#define YYBACKUP(token, value) \
396
do                                                              \
397
  if (yychar == YYEMPTY && yylen == 1)                          \
398
    { yychar = (token), yylval = (value);                       \
399
      yychar1 = YYTRANSLATE (yychar);                           \
400
      YYPOPSTACK;                                               \
401
      goto yybackup;                                            \
402
    }                                                           \
403
  else                                                          \
404
    { yyerror ("syntax error: cannot back up"); YYERROR; }      \
405
while (0)
406
 
407
#define YYTERROR        1
408
#define YYERRCODE       256
409
 
410
#ifndef YYPURE
411
#define YYLEX           yylex()
412
#endif
413
 
414
#ifdef YYPURE
415
#ifdef YYLSP_NEEDED
416
#ifdef YYLEX_PARAM
417
#define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
418
#else
419
#define YYLEX           yylex(&yylval, &yylloc)
420
#endif
421
#else /* not YYLSP_NEEDED */
422
#ifdef YYLEX_PARAM
423
#define YYLEX           yylex(&yylval, YYLEX_PARAM)
424
#else
425
#define YYLEX           yylex(&yylval)
426
#endif
427
#endif /* not YYLSP_NEEDED */
428
#endif
429
 
430
/* If nonreentrant, generate the variables here */
431
 
432
#ifndef YYPURE
433
 
434
int     yychar;                 /*  the lookahead symbol                */
435
YYSTYPE yylval;                 /*  the semantic value of the           */
436
                                /*  lookahead symbol                    */
437
 
438
#ifdef YYLSP_NEEDED
439
YYLTYPE yylloc;                 /*  location data for the lookahead     */
440
                                /*  symbol                              */
441
#endif
442
 
443
int yynerrs;                    /*  number of parse errors so far       */
444
#endif  /* not YYPURE */
445
 
446
#if YYDEBUG != 0
447
int yydebug;                    /*  nonzero means print parse trace     */
448
/* Since this is uninitialized, it does not stop multiple parsers
449
   from coexisting.  */
450
#endif
451
 
452
/*  YYINITDEPTH indicates the initial size of the parser's stacks       */
453
 
454
#ifndef YYINITDEPTH
455
#define YYINITDEPTH 200
456
#endif
457
 
458
/*  YYMAXDEPTH is the maximum size the stacks can grow to
459
    (effective only if the built-in stack extension method is used).  */
460
 
461
#if YYMAXDEPTH == 0
462
#undef YYMAXDEPTH
463
#endif
464
 
465
#ifndef YYMAXDEPTH
466
#define YYMAXDEPTH 10000
467
#endif
468
 
469
/* Define __yy_memcpy.  Note that the size argument
470
   should be passed with type unsigned int, because that is what the non-GCC
471
   definitions require.  With GCC, __builtin_memcpy takes an arg
472
   of type size_t, but it can handle unsigned int.  */
473
 
474
#if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
475
#define __yy_memcpy(TO,FROM,COUNT)      __builtin_memcpy(TO,FROM,COUNT)
476
#else                           /* not GNU C or C++ */
477
#ifndef __cplusplus
478
 
479
/* This is the most reliable way to avoid incompatibilities
480
   in available built-in functions on various systems.  */
481
static void
482
__yy_memcpy (to, from, count)
483
     char *to;
484
     char *from;
485
     unsigned int count;
486
{
487
  register char *f = from;
488
  register char *t = to;
489
  register int i = count;
490
 
491
  while (i-- > 0)
492
    *t++ = *f++;
493
}
494
 
495
#else /* __cplusplus */
496
 
497
/* This is the most reliable way to avoid incompatibilities
498
   in available built-in functions on various systems.  */
499
static void
500
__yy_memcpy (char *to, char *from, unsigned int count)
501
{
502
  register char *t = to;
503
  register char *f = from;
504
  register int i = count;
505
 
506
  while (i-- > 0)
507
    *t++ = *f++;
508
}
509
 
510
#endif
511
#endif
512
 
513
#line 217 "/usr/lib/bison.simple"
514
 
515
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
516
   into yyparse.  The argument should have type void *.
517
   It should actually point to an object.
518
   Grammar actions can access the variable by casting it
519
   to the proper pointer type.  */
520
 
521
#ifdef YYPARSE_PARAM
522
#ifdef __cplusplus
523
#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
524
#define YYPARSE_PARAM_DECL
525
#else /* not __cplusplus */
526
#define YYPARSE_PARAM_ARG YYPARSE_PARAM
527
#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
528
#endif /* not __cplusplus */
529
#else /* not YYPARSE_PARAM */
530
#define YYPARSE_PARAM_ARG
531
#define YYPARSE_PARAM_DECL
532
#endif /* not YYPARSE_PARAM */
533
 
534
/* Prevent warning if -Wstrict-prototypes.  */
535
#ifdef __GNUC__
536
#ifdef YYPARSE_PARAM
537
int yyparse (void *);
538
#else
539
int yyparse (void);
540
#endif
541
#endif
542
 
543
int
544
yyparse(YYPARSE_PARAM_ARG)
545
     YYPARSE_PARAM_DECL
546
{
547
  register int yystate;
548
  register int yyn;
549
  register short *yyssp;
550
  register YYSTYPE *yyvsp;
551
  int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
552
  int yychar1 = 0;               /*  lookahead token as an internal (translated) token number */
553
 
554
  short yyssa[YYINITDEPTH];     /*  the state stack                     */
555
  YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
556
 
557
  short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
558
  YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
559
 
560
#ifdef YYLSP_NEEDED
561
  YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
562
  YYLTYPE *yyls = yylsa;
563
  YYLTYPE *yylsp;
564
 
565
#define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
566
#else
567
#define YYPOPSTACK   (yyvsp--, yyssp--)
568
#endif
569
 
570
  int yystacksize = YYINITDEPTH;
571
  int yyfree_stacks = 0;
572
 
573
#ifdef YYPURE
574
  int yychar;
575
  YYSTYPE yylval;
576
  int yynerrs;
577
#ifdef YYLSP_NEEDED
578
  YYLTYPE yylloc;
579
#endif
580
#endif
581
 
582
  YYSTYPE yyval;                /*  the variable used to return         */
583
                                /*  semantic values from the action     */
584
                                /*  routines                            */
585
 
586
  int yylen;
587
 
588
#if YYDEBUG != 0
589
  if (yydebug)
590
    fprintf(stderr, "Starting parse\n");
591
#endif
592
 
593
  yystate = 0;
594
  yyerrstatus = 0;
595
  yynerrs = 0;
596
  yychar = YYEMPTY;             /* Cause a token to be read.  */
597
 
598
  /* Initialize stack pointers.
599
     Waste one element of value and location stack
600
     so that they stay on the same level as the state stack.
601
     The wasted elements are never initialized.  */
602
 
603
  yyssp = yyss - 1;
604
  yyvsp = yyvs;
605
#ifdef YYLSP_NEEDED
606
  yylsp = yyls;
607
#endif
608
 
609
/* Push a new state, which is found in  yystate  .  */
610
/* In all cases, when you get here, the value and location stacks
611
   have just been pushed. so pushing a state here evens the stacks.  */
612
yynewstate:
613
 
614
  *++yyssp = yystate;
615
 
616
  if (yyssp >= yyss + yystacksize - 1)
617
    {
618
      /* Give user a chance to reallocate the stack */
619
      /* Use copies of these so that the &'s don't force the real ones into memory. */
620
      YYSTYPE *yyvs1 = yyvs;
621
      short *yyss1 = yyss;
622
#ifdef YYLSP_NEEDED
623
      YYLTYPE *yyls1 = yyls;
624
#endif
625
 
626
      /* Get the current used size of the three stacks, in elements.  */
627
      int size = yyssp - yyss + 1;
628
 
629
#ifdef yyoverflow
630
      /* Each stack pointer address is followed by the size of
631
         the data in use in that stack, in bytes.  */
632
#ifdef YYLSP_NEEDED
633
      /* This used to be a conditional around just the two extra args,
634
         but that might be undefined if yyoverflow is a macro.  */
635
      yyoverflow("parser stack overflow",
636
                 &yyss1, size * sizeof (*yyssp),
637
                 &yyvs1, size * sizeof (*yyvsp),
638
                 &yyls1, size * sizeof (*yylsp),
639
                 &yystacksize);
640
#else
641
      yyoverflow("parser stack overflow",
642
                 &yyss1, size * sizeof (*yyssp),
643
                 &yyvs1, size * sizeof (*yyvsp),
644
                 &yystacksize);
645
#endif
646
 
647
      yyss = yyss1; yyvs = yyvs1;
648
#ifdef YYLSP_NEEDED
649
      yyls = yyls1;
650
#endif
651
#else /* no yyoverflow */
652
      /* Extend the stack our own way.  */
653
      if (yystacksize >= YYMAXDEPTH)
654
        {
655
          yyerror("parser stack overflow");
656
          if (yyfree_stacks)
657
            {
658
              free (yyss);
659
              free (yyvs);
660
#ifdef YYLSP_NEEDED
661
              free (yyls);
662
#endif
663
            }
664
          return 2;
665
        }
666
      yystacksize *= 2;
667
      if (yystacksize > YYMAXDEPTH)
668
        yystacksize = YYMAXDEPTH;
669
#ifndef YYSTACK_USE_ALLOCA
670
      yyfree_stacks = 1;
671
#endif
672
      yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
673
      __yy_memcpy ((char *)yyss, (char *)yyss1,
674
                   size * (unsigned int) sizeof (*yyssp));
675
      yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
676
      __yy_memcpy ((char *)yyvs, (char *)yyvs1,
677
                   size * (unsigned int) sizeof (*yyvsp));
678
#ifdef YYLSP_NEEDED
679
      yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
680
      __yy_memcpy ((char *)yyls, (char *)yyls1,
681
                   size * (unsigned int) sizeof (*yylsp));
682
#endif
683
#endif /* no yyoverflow */
684
 
685
      yyssp = yyss + size - 1;
686
      yyvsp = yyvs + size - 1;
687
#ifdef YYLSP_NEEDED
688
      yylsp = yyls + size - 1;
689
#endif
690
 
691
#if YYDEBUG != 0
692
      if (yydebug)
693
        fprintf(stderr, "Stack size increased to %d\n", yystacksize);
694
#endif
695
 
696
      if (yyssp >= yyss + yystacksize - 1)
697
        YYABORT;
698
    }
699
 
700
#if YYDEBUG != 0
701
  if (yydebug)
702
    fprintf(stderr, "Entering state %d\n", yystate);
703
#endif
704
 
705
  goto yybackup;
706
 yybackup:
707
 
708
/* Do appropriate processing given the current state.  */
709
/* Read a lookahead token if we need one and don't already have one.  */
710
/* yyresume: */
711
 
712
  /* First try to decide what to do without reference to lookahead token.  */
713
 
714
  yyn = yypact[yystate];
715
  if (yyn == YYFLAG)
716
    goto yydefault;
717
 
718
  /* Not known => get a lookahead token if don't already have one.  */
719
 
720
  /* yychar is either YYEMPTY or YYEOF
721
     or a valid token in external form.  */
722
 
723
  if (yychar == YYEMPTY)
724
    {
725
#if YYDEBUG != 0
726
      if (yydebug)
727
        fprintf(stderr, "Reading a token: ");
728
#endif
729
      yychar = YYLEX;
730
    }
731
 
732
  /* Convert token to internal form (in yychar1) for indexing tables with */
733
 
734
  if (yychar <= 0)               /* This means end of input. */
735
    {
736
      yychar1 = 0;
737
      yychar = YYEOF;           /* Don't call YYLEX any more */
738
 
739
#if YYDEBUG != 0
740
      if (yydebug)
741
        fprintf(stderr, "Now at end of input.\n");
742
#endif
743
    }
744
  else
745
    {
746
      yychar1 = YYTRANSLATE(yychar);
747
 
748
#if YYDEBUG != 0
749
      if (yydebug)
750
        {
751
          fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
752
          /* Give the individual parser a way to print the precise meaning
753
             of a token, for further debugging info.  */
754
#ifdef YYPRINT
755
          YYPRINT (stderr, yychar, yylval);
756
#endif
757
          fprintf (stderr, ")\n");
758
        }
759
#endif
760
    }
761
 
762
  yyn += yychar1;
763
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
764
    goto yydefault;
765
 
766
  yyn = yytable[yyn];
767
 
768
  /* yyn is what to do for this token type in this state.
769
     Negative => reduce, -yyn is rule number.
770
     Positive => shift, yyn is new state.
771
       New state is final state => don't bother to shift,
772
       just return success.
773
     0, or most negative number => error.  */
774
 
775
  if (yyn < 0)
776
    {
777
      if (yyn == YYFLAG)
778
        goto yyerrlab;
779
      yyn = -yyn;
780
      goto yyreduce;
781
    }
782
  else if (yyn == 0)
783
    goto yyerrlab;
784
 
785
  if (yyn == YYFINAL)
786
    YYACCEPT;
787
 
788
  /* Shift the lookahead token.  */
789
 
790
#if YYDEBUG != 0
791
  if (yydebug)
792
    fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
793
#endif
794
 
795
  /* Discard the token being shifted unless it is eof.  */
796
  if (yychar != YYEOF)
797
    yychar = YYEMPTY;
798
 
799
  *++yyvsp = yylval;
800
#ifdef YYLSP_NEEDED
801
  *++yylsp = yylloc;
802
#endif
803
 
804
  /* count tokens shifted since error; after three, turn off error status.  */
805
  if (yyerrstatus) yyerrstatus--;
806
 
807
  yystate = yyn;
808
  goto yynewstate;
809
 
810
/* Do the default action for the current state.  */
811
yydefault:
812
 
813
  yyn = yydefact[yystate];
814
  if (yyn == 0)
815
    goto yyerrlab;
816
 
817
/* Do a reduction.  yyn is the number of a rule to reduce with.  */
818
yyreduce:
819
  yylen = yyr2[yyn];
820
  if (yylen > 0)
821
    yyval = yyvsp[1-yylen]; /* implement default value of the action */
822
 
823
#if YYDEBUG != 0
824
  if (yydebug)
825
    {
826
      int i;
827
 
828
      fprintf (stderr, "Reducing via rule %d (line %d), ",
829
               yyn, yyrline[yyn]);
830
 
831
      /* Print the symbols being reduced, and their result.  */
832
      for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
833
        fprintf (stderr, "%s ", yytname[yyrhs[i]]);
834
      fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
835
    }
836
#endif
837
 
838
 
839
  switch (yyn) {
840
 
841
case 1:
842
#line 172 "plural.y"
843
{
844
            if (yyvsp[0].exp == NULL)
845
              YYABORT;
846
            ((struct parse_args *) arg)->res = yyvsp[0].exp;
847
          ;
848
    break;}
849
case 2:
850
#line 180 "plural.y"
851
{
852
            yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp);
853
          ;
854
    break;}
855
case 3:
856
#line 184 "plural.y"
857
{
858
            yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp);
859
          ;
860
    break;}
861
case 4:
862
#line 188 "plural.y"
863
{
864
            yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp);
865
          ;
866
    break;}
867
case 5:
868
#line 192 "plural.y"
869
{
870
            yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
871
          ;
872
    break;}
873
case 6:
874
#line 196 "plural.y"
875
{
876
            yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
877
          ;
878
    break;}
879
case 7:
880
#line 200 "plural.y"
881
{
882
            yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
883
          ;
884
    break;}
885
case 8:
886
#line 204 "plural.y"
887
{
888
            yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
889
          ;
890
    break;}
891
case 9:
892
#line 208 "plural.y"
893
{
894
            yyval.exp = new_exp_1 (lnot, yyvsp[0].exp);
895
          ;
896
    break;}
897
case 10:
898
#line 212 "plural.y"
899
{
900
            yyval.exp = new_exp_0 (var);
901
          ;
902
    break;}
903
case 11:
904
#line 216 "plural.y"
905
{
906
            if ((yyval.exp = new_exp_0 (num)) != NULL)
907
              yyval.exp->val.num = yyvsp[0].num;
908
          ;
909
    break;}
910
case 12:
911
#line 221 "plural.y"
912
{
913
            yyval.exp = yyvsp[-1].exp;
914
          ;
915
    break;}
916
}
917
   /* the action file gets copied in in place of this dollarsign */
918
#line 543 "/usr/lib/bison.simple"
919
 
920
  yyvsp -= yylen;
921
  yyssp -= yylen;
922
#ifdef YYLSP_NEEDED
923
  yylsp -= yylen;
924
#endif
925
 
926
#if YYDEBUG != 0
927
  if (yydebug)
928
    {
929
      short *ssp1 = yyss - 1;
930
      fprintf (stderr, "state stack now");
931
      while (ssp1 != yyssp)
932
        fprintf (stderr, " %d", *++ssp1);
933
      fprintf (stderr, "\n");
934
    }
935
#endif
936
 
937
  *++yyvsp = yyval;
938
 
939
#ifdef YYLSP_NEEDED
940
  yylsp++;
941
  if (yylen == 0)
942
    {
943
      yylsp->first_line = yylloc.first_line;
944
      yylsp->first_column = yylloc.first_column;
945
      yylsp->last_line = (yylsp-1)->last_line;
946
      yylsp->last_column = (yylsp-1)->last_column;
947
      yylsp->text = 0;
948
    }
949
  else
950
    {
951
      yylsp->last_line = (yylsp+yylen-1)->last_line;
952
      yylsp->last_column = (yylsp+yylen-1)->last_column;
953
    }
954
#endif
955
 
956
  /* Now "shift" the result of the reduction.
957
     Determine what state that goes to,
958
     based on the state we popped back to
959
     and the rule number reduced by.  */
960
 
961
  yyn = yyr1[yyn];
962
 
963
  yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
964
  if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
965
    yystate = yytable[yystate];
966
  else
967
    yystate = yydefgoto[yyn - YYNTBASE];
968
 
969
  goto yynewstate;
970
 
971
yyerrlab:   /* here on detecting error */
972
 
973
  if (! yyerrstatus)
974
    /* If not already recovering from an error, report this error.  */
975
    {
976
      ++yynerrs;
977
 
978
#ifdef YYERROR_VERBOSE
979
      yyn = yypact[yystate];
980
 
981
      if (yyn > YYFLAG && yyn < YYLAST)
982
        {
983
          int size = 0;
984
          char *msg;
985
          int x, count;
986
 
987
          count = 0;
988
          /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
989
          for (x = (yyn < 0 ? -yyn : 0);
990
               x < (sizeof(yytname) / sizeof(char *)); x++)
991
            if (yycheck[x + yyn] == x)
992
              size += strlen(yytname[x]) + 15, count++;
993
          msg = (char *) malloc(size + 15);
994
          if (msg != 0)
995
            {
996
              strcpy(msg, "parse error");
997
 
998
              if (count < 5)
999
                {
1000
                  count = 0;
1001
                  for (x = (yyn < 0 ? -yyn : 0);
1002
                       x < (sizeof(yytname) / sizeof(char *)); x++)
1003
                    if (yycheck[x + yyn] == x)
1004
                      {
1005
                        strcat(msg, count == 0 ? ", expecting `" : " or `");
1006
                        strcat(msg, yytname[x]);
1007
                        strcat(msg, "'");
1008
                        count++;
1009
                      }
1010
                }
1011
              yyerror(msg);
1012
              free(msg);
1013
            }
1014
          else
1015
            yyerror ("parse error; also virtual memory exceeded");
1016
        }
1017
      else
1018
#endif /* YYERROR_VERBOSE */
1019
        yyerror("parse error");
1020
    }
1021
 
1022
  goto yyerrlab1;
1023
yyerrlab1:   /* here on error raised explicitly by an action */
1024
 
1025
  if (yyerrstatus == 3)
1026
    {
1027
      /* if just tried and failed to reuse lookahead token after an error, discard it.  */
1028
 
1029
      /* return failure if at end of input */
1030
      if (yychar == YYEOF)
1031
        YYABORT;
1032
 
1033
#if YYDEBUG != 0
1034
      if (yydebug)
1035
        fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1036
#endif
1037
 
1038
      yychar = YYEMPTY;
1039
    }
1040
 
1041
  /* Else will try to reuse lookahead token
1042
     after shifting the error token.  */
1043
 
1044
  yyerrstatus = 3;              /* Each real token shifted decrements this */
1045
 
1046
  goto yyerrhandle;
1047
 
1048
yyerrdefault:  /* current state does not do anything special for the error token. */
1049
 
1050
#if 0
1051
  /* This is wrong; only states that explicitly want error tokens
1052
     should shift them.  */
1053
  yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
1054
  if (yyn) goto yydefault;
1055
#endif
1056
 
1057
yyerrpop:   /* pop the current state because it cannot handle the error token */
1058
 
1059
  if (yyssp == yyss) YYABORT;
1060
  yyvsp--;
1061
  yystate = *--yyssp;
1062
#ifdef YYLSP_NEEDED
1063
  yylsp--;
1064
#endif
1065
 
1066
#if YYDEBUG != 0
1067
  if (yydebug)
1068
    {
1069
      short *ssp1 = yyss - 1;
1070
      fprintf (stderr, "Error: state stack now");
1071
      while (ssp1 != yyssp)
1072
        fprintf (stderr, " %d", *++ssp1);
1073
      fprintf (stderr, "\n");
1074
    }
1075
#endif
1076
 
1077
yyerrhandle:
1078
 
1079
  yyn = yypact[yystate];
1080
  if (yyn == YYFLAG)
1081
    goto yyerrdefault;
1082
 
1083
  yyn += YYTERROR;
1084
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1085
    goto yyerrdefault;
1086
 
1087
  yyn = yytable[yyn];
1088
  if (yyn < 0)
1089
    {
1090
      if (yyn == YYFLAG)
1091
        goto yyerrpop;
1092
      yyn = -yyn;
1093
      goto yyreduce;
1094
    }
1095
  else if (yyn == 0)
1096
    goto yyerrpop;
1097
 
1098
  if (yyn == YYFINAL)
1099
    YYACCEPT;
1100
 
1101
#if YYDEBUG != 0
1102
  if (yydebug)
1103
    fprintf(stderr, "Shifting error token, ");
1104
#endif
1105
 
1106
  *++yyvsp = yylval;
1107
#ifdef YYLSP_NEEDED
1108
  *++yylsp = yylloc;
1109
#endif
1110
 
1111
  yystate = yyn;
1112
  goto yynewstate;
1113
 
1114
 yyacceptlab:
1115
  /* YYACCEPT comes here.  */
1116
  if (yyfree_stacks)
1117
    {
1118
      free (yyss);
1119
      free (yyvs);
1120
#ifdef YYLSP_NEEDED
1121
      free (yyls);
1122
#endif
1123
    }
1124
  return 0;
1125
 
1126
 yyabortlab:
1127
  /* YYABORT comes here.  */
1128
  if (yyfree_stacks)
1129
    {
1130
      free (yyss);
1131
      free (yyvs);
1132
#ifdef YYLSP_NEEDED
1133
      free (yyls);
1134
#endif
1135
    }
1136
  return 1;
1137
}
1138
#line 226 "plural.y"
1139
 
1140
 
1141
void
1142
internal_function
1143
FREE_EXPRESSION (exp)
1144
     struct expression *exp;
1145
{
1146
  if (exp == NULL)
1147
    return;
1148
 
1149
  /* Handle the recursive case.  */
1150
  switch (exp->nargs)
1151
    {
1152
    case 3:
1153
      FREE_EXPRESSION (exp->val.args[2]);
1154
      /* FALLTHROUGH */
1155
    case 2:
1156
      FREE_EXPRESSION (exp->val.args[1]);
1157
      /* FALLTHROUGH */
1158
    case 1:
1159
      FREE_EXPRESSION (exp->val.args[0]);
1160
      /* FALLTHROUGH */
1161
    default:
1162
      break;
1163
    }
1164
 
1165
  free (exp);
1166
}
1167
 
1168
 
1169
static int
1170
yylex (lval, pexp)
1171
     YYSTYPE *lval;
1172
     const char **pexp;
1173
{
1174
  const char *exp = *pexp;
1175
  int result;
1176
 
1177
  while (1)
1178
    {
1179
      if (exp[0] == '\0')
1180
        {
1181
          *pexp = exp;
1182
          return YYEOF;
1183
        }
1184
 
1185
      if (exp[0] != ' ' && exp[0] != '\t')
1186
        break;
1187
 
1188
      ++exp;
1189
    }
1190
 
1191
  result = *exp++;
1192
  switch (result)
1193
    {
1194
    case '0': case '1': case '2': case '3': case '4':
1195
    case '5': case '6': case '7': case '8': case '9':
1196
      {
1197
        unsigned long int n = result - '0';
1198
        while (exp[0] >= '0' && exp[0] <= '9')
1199
          {
1200
            n *= 10;
1201
            n += exp[0] - '0';
1202
            ++exp;
1203
          }
1204
        lval->num = n;
1205
        result = NUMBER;
1206
      }
1207
      break;
1208
 
1209
    case '=':
1210
      if (exp[0] == '=')
1211
        {
1212
          ++exp;
1213
          lval->op = equal;
1214
          result = EQUOP2;
1215
        }
1216
      else
1217
        result = YYERRCODE;
1218
      break;
1219
 
1220
    case '!':
1221
      if (exp[0] == '=')
1222
        {
1223
          ++exp;
1224
          lval->op = not_equal;
1225
          result = EQUOP2;
1226
        }
1227
      break;
1228
 
1229
    case '&':
1230
    case '|':
1231
      if (exp[0] == result)
1232
        ++exp;
1233
      else
1234
        result = YYERRCODE;
1235
      break;
1236
 
1237
    case '<':
1238
      if (exp[0] == '=')
1239
        {
1240
          ++exp;
1241
          lval->op = less_or_equal;
1242
        }
1243
      else
1244
        lval->op = less_than;
1245
      result = CMPOP2;
1246
      break;
1247
 
1248
    case '>':
1249
      if (exp[0] == '=')
1250
        {
1251
          ++exp;
1252
          lval->op = greater_or_equal;
1253
        }
1254
      else
1255
        lval->op = greater_than;
1256
      result = CMPOP2;
1257
      break;
1258
 
1259
    case '*':
1260
      lval->op = mult;
1261
      result = MULOP2;
1262
      break;
1263
 
1264
    case '/':
1265
      lval->op = divide;
1266
      result = MULOP2;
1267
      break;
1268
 
1269
    case '%':
1270
      lval->op = module;
1271
      result = MULOP2;
1272
      break;
1273
 
1274
    case '+':
1275
      lval->op = plus;
1276
      result = ADDOP2;
1277
      break;
1278
 
1279
    case '-':
1280
      lval->op = minus;
1281
      result = ADDOP2;
1282
      break;
1283
 
1284
    case 'n':
1285
    case '?':
1286
    case ':':
1287
    case '(':
1288
    case ')':
1289
      /* Nothing, just return the character.  */
1290
      break;
1291
 
1292
    case ';':
1293
    case '\n':
1294
    case '\0':
1295
      /* Be safe and let the user call this function again.  */
1296
      --exp;
1297
      result = YYEOF;
1298
      break;
1299
 
1300
    default:
1301
      result = YYERRCODE;
1302
#if YYDEBUG != 0
1303
      --exp;
1304
#endif
1305
      break;
1306
    }
1307
 
1308
  *pexp = exp;
1309
 
1310
  return result;
1311
}
1312
 
1313
 
1314
static void
1315
yyerror (str)
1316
     const char *str;
1317
{
1318
  /* Do nothing.  We don't print error messages here.  */
1319
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.