plural.c 38 KB

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