plural.c 32 KB

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