plural.c 40 KB

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