Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

plural.c 36KB

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