plural.c 37 KB

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