cmExprParser.cxx 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724
  1. /* A Bison parser, made by GNU Bison 3.3.2. */
  2. /* Bison implementation for Yacc-like parsers in C
  3. Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
  4. Inc.
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. /* As a special exception, you may create a larger work that contains
  16. part or all of the Bison parser skeleton and distribute that work
  17. under terms of your choice, so long as that work isn't itself a
  18. parser generator using the skeleton or a modified version thereof
  19. as a parser skeleton. Alternatively, if you modify or redistribute
  20. the parser skeleton itself, you may (at your option) remove this
  21. special exception, which will cause the skeleton and the resulting
  22. Bison output files to be licensed under the GNU General Public
  23. License without this special exception.
  24. This special exception was added by the Free Software Foundation in
  25. version 2.2 of Bison. */
  26. /* C LALR(1) parser skeleton written by Richard Stallman, by
  27. simplifying the original so-called "semantic" parser. */
  28. /* All symbols defined below should begin with yy or YY, to avoid
  29. infringing on user name space. This should be done even for local
  30. variables, as they might otherwise be expanded by user macros.
  31. There are some unavoidable exceptions within include files to
  32. define necessary library symbols; they are noted "INFRINGES ON
  33. USER NAME SPACE" below. */
  34. /* Undocumented macros, especially those whose name start with YY_,
  35. are private implementation details. Do not rely on them. */
  36. /* Identify Bison output. */
  37. #define YYBISON 1
  38. /* Bison version. */
  39. #define YYBISON_VERSION "3.3.2"
  40. /* Skeleton name. */
  41. #define YYSKELETON_NAME "yacc.c"
  42. /* Pure parsers. */
  43. #define YYPURE 1
  44. /* Push parsers. */
  45. #define YYPUSH 0
  46. /* Pull parsers. */
  47. #define YYPULL 1
  48. /* Substitute the variable and function names. */
  49. #define yyparse cmExpr_yyparse
  50. #define yylex cmExpr_yylex
  51. #define yyerror cmExpr_yyerror
  52. #define yydebug cmExpr_yydebug
  53. #define yynerrs cmExpr_yynerrs
  54. /* First part of user prologue. */
  55. #line 1 "cmExprParser.y" /* yacc.c:337 */
  56. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  57. file Copyright.txt or https://cmake.org/licensing for details. */
  58. /*
  59. This file must be translated to C and modified to build everywhere.
  60. Run bison like this:
  61. bison --yacc --name-prefix=cmExpr_yy --defines=cmExprParserTokens.h -ocmExprParser.cxx cmExprParser.y
  62. Modify cmExprParser.cxx:
  63. - "#if 0" out yyerrorlab block in range ["goto yyerrlab1", "yyerrlab1:"]
  64. */
  65. #include "cmConfigure.h" // IWYU pragma: keep
  66. #include <stdlib.h>
  67. #include <string.h>
  68. #include <stdexcept>
  69. /*-------------------------------------------------------------------------*/
  70. #define YYDEBUG 1
  71. #include "cmExprParserHelper.h" /* Interface to parser object. */
  72. #include "cmExprLexer.h" /* Interface to lexer object. */
  73. #include "cmExprParserTokens.h" /* Need YYSTYPE for YY_DECL. */
  74. /* Forward declare the lexer entry point. */
  75. YY_DECL;
  76. /* Helper function to forward error callback from parser. */
  77. static void cmExpr_yyerror(yyscan_t yyscanner, const char* message);
  78. /* Disable some warnings in the generated code. */
  79. #ifdef _MSC_VER
  80. # pragma warning (disable: 4102) /* Unused goto label. */
  81. # pragma warning (disable: 4065) /* Switch statement contains default but no case. */
  82. #endif
  83. #if defined(__GNUC__) && __GNUC__ >= 8
  84. # pragma GCC diagnostic ignored "-Wconversion"
  85. #endif
  86. #line 120 "cmExprParser.cxx" /* yacc.c:337 */
  87. # ifndef YY_NULLPTR
  88. # if defined __cplusplus
  89. # if 201103L <= __cplusplus
  90. # define YY_NULLPTR nullptr
  91. # else
  92. # define YY_NULLPTR 0
  93. # endif
  94. # else
  95. # define YY_NULLPTR ((void*)0)
  96. # endif
  97. # endif
  98. /* Enabling verbose error messages. */
  99. #ifdef YYERROR_VERBOSE
  100. # undef YYERROR_VERBOSE
  101. # define YYERROR_VERBOSE 1
  102. #else
  103. # define YYERROR_VERBOSE 1
  104. #endif
  105. /* In a future release of Bison, this section will be replaced
  106. by #include "cmExprParserTokens.h". */
  107. #ifndef YY_CMEXPR_YY_CMEXPRPARSERTOKENS_H_INCLUDED
  108. # define YY_CMEXPR_YY_CMEXPRPARSERTOKENS_H_INCLUDED
  109. /* Debug traces. */
  110. #ifndef YYDEBUG
  111. # define YYDEBUG 0
  112. #endif
  113. #if YYDEBUG
  114. extern int cmExpr_yydebug;
  115. #endif
  116. /* Token type. */
  117. #ifndef YYTOKENTYPE
  118. # define YYTOKENTYPE
  119. enum yytokentype
  120. {
  121. exp_PLUS = 258,
  122. exp_MINUS = 259,
  123. exp_TIMES = 260,
  124. exp_DIVIDE = 261,
  125. exp_MOD = 262,
  126. exp_SHIFTLEFT = 263,
  127. exp_SHIFTRIGHT = 264,
  128. exp_OPENPARENT = 265,
  129. exp_CLOSEPARENT = 266,
  130. exp_OR = 267,
  131. exp_AND = 268,
  132. exp_XOR = 269,
  133. exp_NOT = 270,
  134. exp_NUMBER = 271
  135. };
  136. #endif
  137. /* Tokens. */
  138. #define exp_PLUS 258
  139. #define exp_MINUS 259
  140. #define exp_TIMES 260
  141. #define exp_DIVIDE 261
  142. #define exp_MOD 262
  143. #define exp_SHIFTLEFT 263
  144. #define exp_SHIFTRIGHT 264
  145. #define exp_OPENPARENT 265
  146. #define exp_CLOSEPARENT 266
  147. #define exp_OR 267
  148. #define exp_AND 268
  149. #define exp_XOR 269
  150. #define exp_NOT 270
  151. #define exp_NUMBER 271
  152. /* Value type. */
  153. int cmExpr_yyparse (yyscan_t yyscanner);
  154. #endif /* !YY_CMEXPR_YY_CMEXPRPARSERTOKENS_H_INCLUDED */
  155. #ifdef short
  156. # undef short
  157. #endif
  158. #ifdef YYTYPE_UINT8
  159. typedef YYTYPE_UINT8 yytype_uint8;
  160. #else
  161. typedef unsigned char yytype_uint8;
  162. #endif
  163. #ifdef YYTYPE_INT8
  164. typedef YYTYPE_INT8 yytype_int8;
  165. #else
  166. typedef signed char yytype_int8;
  167. #endif
  168. #ifdef YYTYPE_UINT16
  169. typedef YYTYPE_UINT16 yytype_uint16;
  170. #else
  171. typedef unsigned short yytype_uint16;
  172. #endif
  173. #ifdef YYTYPE_INT16
  174. typedef YYTYPE_INT16 yytype_int16;
  175. #else
  176. typedef short yytype_int16;
  177. #endif
  178. #ifndef YYSIZE_T
  179. # ifdef __SIZE_TYPE__
  180. # define YYSIZE_T __SIZE_TYPE__
  181. # elif defined size_t
  182. # define YYSIZE_T size_t
  183. # elif ! defined YYSIZE_T
  184. # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
  185. # define YYSIZE_T size_t
  186. # else
  187. # define YYSIZE_T unsigned
  188. # endif
  189. #endif
  190. #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
  191. #ifndef YY_
  192. # if defined YYENABLE_NLS && YYENABLE_NLS
  193. # if ENABLE_NLS
  194. # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
  195. # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
  196. # endif
  197. # endif
  198. # ifndef YY_
  199. # define YY_(Msgid) Msgid
  200. # endif
  201. #endif
  202. #ifndef YY_ATTRIBUTE
  203. # if (defined __GNUC__ \
  204. && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
  205. || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
  206. # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
  207. # else
  208. # define YY_ATTRIBUTE(Spec) /* empty */
  209. # endif
  210. #endif
  211. #ifndef YY_ATTRIBUTE_PURE
  212. # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
  213. #endif
  214. #ifndef YY_ATTRIBUTE_UNUSED
  215. # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
  216. #endif
  217. /* Suppress unused-variable warnings by "using" E. */
  218. #if ! defined lint || defined __GNUC__
  219. # define YYUSE(E) ((void) (E))
  220. #else
  221. # define YYUSE(E) /* empty */
  222. #endif
  223. #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
  224. /* Suppress an incorrect diagnostic about yylval being uninitialized. */
  225. # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
  226. _Pragma ("GCC diagnostic push") \
  227. _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
  228. _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
  229. # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
  230. _Pragma ("GCC diagnostic pop")
  231. #else
  232. # define YY_INITIAL_VALUE(Value) Value
  233. #endif
  234. #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  235. # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  236. # define YY_IGNORE_MAYBE_UNINITIALIZED_END
  237. #endif
  238. #ifndef YY_INITIAL_VALUE
  239. # define YY_INITIAL_VALUE(Value) /* Nothing. */
  240. #endif
  241. #if ! defined yyoverflow || YYERROR_VERBOSE
  242. /* The parser invokes alloca or malloc; define the necessary symbols. */
  243. # ifdef YYSTACK_USE_ALLOCA
  244. # if YYSTACK_USE_ALLOCA
  245. # ifdef __GNUC__
  246. # define YYSTACK_ALLOC __builtin_alloca
  247. # elif defined __BUILTIN_VA_ARG_INCR
  248. # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
  249. # elif defined _AIX
  250. # define YYSTACK_ALLOC __alloca
  251. # elif defined _MSC_VER
  252. # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
  253. # define alloca _alloca
  254. # else
  255. # define YYSTACK_ALLOC alloca
  256. # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
  257. # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  258. /* Use EXIT_SUCCESS as a witness for stdlib.h. */
  259. # ifndef EXIT_SUCCESS
  260. # define EXIT_SUCCESS 0
  261. # endif
  262. # endif
  263. # endif
  264. # endif
  265. # endif
  266. # ifdef YYSTACK_ALLOC
  267. /* Pacify GCC's 'empty if-body' warning. */
  268. # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
  269. # ifndef YYSTACK_ALLOC_MAXIMUM
  270. /* The OS might guarantee only one guard page at the bottom of the stack,
  271. and a page size can be as small as 4096 bytes. So we cannot safely
  272. invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
  273. to allow for a few compiler-allocated temporary stack slots. */
  274. # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
  275. # endif
  276. # else
  277. # define YYSTACK_ALLOC YYMALLOC
  278. # define YYSTACK_FREE YYFREE
  279. # ifndef YYSTACK_ALLOC_MAXIMUM
  280. # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
  281. # endif
  282. # if (defined __cplusplus && ! defined EXIT_SUCCESS \
  283. && ! ((defined YYMALLOC || defined malloc) \
  284. && (defined YYFREE || defined free)))
  285. # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  286. # ifndef EXIT_SUCCESS
  287. # define EXIT_SUCCESS 0
  288. # endif
  289. # endif
  290. # ifndef YYMALLOC
  291. # define YYMALLOC malloc
  292. # if ! defined malloc && ! defined EXIT_SUCCESS
  293. void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
  294. # endif
  295. # endif
  296. # ifndef YYFREE
  297. # define YYFREE free
  298. # if ! defined free && ! defined EXIT_SUCCESS
  299. void free (void *); /* INFRINGES ON USER NAME SPACE */
  300. # endif
  301. # endif
  302. # endif
  303. #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
  304. #if (! defined yyoverflow \
  305. && (! defined __cplusplus \
  306. || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
  307. /* A type that is properly aligned for any stack member. */
  308. union yyalloc
  309. {
  310. yytype_int16 yyss_alloc;
  311. YYSTYPE yyvs_alloc;
  312. };
  313. /* The size of the maximum gap between one aligned stack and the next. */
  314. # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
  315. /* The size of an array large to enough to hold all stacks, each with
  316. N elements. */
  317. # define YYSTACK_BYTES(N) \
  318. ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
  319. + YYSTACK_GAP_MAXIMUM)
  320. # define YYCOPY_NEEDED 1
  321. /* Relocate STACK from its old location to the new one. The
  322. local variables YYSIZE and YYSTACKSIZE give the old and new number of
  323. elements in the stack, and YYPTR gives the new location of the
  324. stack. Advance YYPTR to a properly aligned location for the next
  325. stack. */
  326. # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
  327. do \
  328. { \
  329. YYSIZE_T yynewbytes; \
  330. YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
  331. Stack = &yyptr->Stack_alloc; \
  332. yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
  333. yyptr += yynewbytes / sizeof (*yyptr); \
  334. } \
  335. while (0)
  336. #endif
  337. #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
  338. /* Copy COUNT objects from SRC to DST. The source and destination do
  339. not overlap. */
  340. # ifndef YYCOPY
  341. # if defined __GNUC__ && 1 < __GNUC__
  342. # define YYCOPY(Dst, Src, Count) \
  343. __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
  344. # else
  345. # define YYCOPY(Dst, Src, Count) \
  346. do \
  347. { \
  348. YYSIZE_T yyi; \
  349. for (yyi = 0; yyi < (Count); yyi++) \
  350. (Dst)[yyi] = (Src)[yyi]; \
  351. } \
  352. while (0)
  353. # endif
  354. # endif
  355. #endif /* !YYCOPY_NEEDED */
  356. /* YYFINAL -- State number of the termination state. */
  357. #define YYFINAL 19
  358. /* YYLAST -- Last index in YYTABLE. */
  359. #define YYLAST 34
  360. /* YYNTOKENS -- Number of terminals. */
  361. #define YYNTOKENS 17
  362. /* YYNNTS -- Number of nonterminals. */
  363. #define YYNNTS 10
  364. /* YYNRULES -- Number of rules. */
  365. #define YYNRULES 24
  366. /* YYNSTATES -- Number of states. */
  367. #define YYNSTATES 41
  368. #define YYUNDEFTOK 2
  369. #define YYMAXUTOK 271
  370. /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
  371. as returned by yylex, with out-of-bounds checking. */
  372. #define YYTRANSLATE(YYX) \
  373. ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
  374. /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
  375. as returned by yylex. */
  376. static const yytype_uint8 yytranslate[] =
  377. {
  378. 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  379. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  380. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  381. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  382. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  383. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  384. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  385. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  386. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  387. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  388. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  389. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  390. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  391. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  392. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  393. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  394. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  395. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  396. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  397. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  398. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  399. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  400. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  401. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  402. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  403. 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
  404. 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  405. 15, 16
  406. };
  407. #if YYDEBUG
  408. /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
  409. static const yytype_uint8 yyrline[] =
  410. {
  411. 0, 77, 77, 82, 85, 90, 93, 98, 101, 106,
  412. 109, 112, 117, 120, 123, 128, 131, 134, 140, 145,
  413. 148, 151, 154, 159, 162
  414. };
  415. #endif
  416. #if YYDEBUG || YYERROR_VERBOSE || 1
  417. /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
  418. First, the terminals, then, starting at YYNTOKENS, nonterminals. */
  419. static const char *const yytname[] =
  420. {
  421. "$end", "error", "$undefined", "exp_PLUS", "exp_MINUS", "exp_TIMES",
  422. "exp_DIVIDE", "exp_MOD", "exp_SHIFTLEFT", "exp_SHIFTRIGHT",
  423. "exp_OPENPARENT", "exp_CLOSEPARENT", "exp_OR", "exp_AND", "exp_XOR",
  424. "exp_NOT", "exp_NUMBER", "$accept", "start", "exp", "bitwiseor",
  425. "bitwisexor", "bitwiseand", "shift", "term", "unary", "factor", YY_NULLPTR
  426. };
  427. #endif
  428. # ifdef YYPRINT
  429. /* YYTOKNUM[NUM] -- (External) token number corresponding to the
  430. (internal) symbol number NUM (which must be that of a token). */
  431. static const yytype_uint16 yytoknum[] =
  432. {
  433. 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
  434. 265, 266, 267, 268, 269, 270, 271
  435. };
  436. # endif
  437. #define YYPACT_NINF -11
  438. #define yypact_value_is_default(Yystate) \
  439. (!!((Yystate) == (-11)))
  440. #define YYTABLE_NINF -1
  441. #define yytable_value_is_error(Yytable_value) \
  442. 0
  443. /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
  444. STATE-NUM. */
  445. static const yytype_int8 yypact[] =
  446. {
  447. 1, 1, 1, 1, 1, -11, 6, -10, -4, 9,
  448. 4, 11, 2, -11, -11, -11, -11, 7, -11, -11,
  449. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  450. -11, -4, 9, 4, 11, 11, 2, 2, -11, -11,
  451. -11
  452. };
  453. /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
  454. Performed when YYTABLE does not specify something else to do. Zero
  455. means the default is an error. */
  456. static const yytype_uint8 yydefact[] =
  457. {
  458. 0, 0, 0, 0, 0, 23, 0, 2, 3, 5,
  459. 7, 9, 12, 15, 19, 20, 21, 0, 22, 1,
  460. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  461. 24, 4, 6, 8, 10, 11, 13, 14, 16, 17,
  462. 18
  463. };
  464. /* YYPGOTO[NTERM-NUM]. */
  465. static const yytype_int8 yypgoto[] =
  466. {
  467. -11, -11, 22, 10, 8, 12, -3, -2, -1, -11
  468. };
  469. /* YYDEFGOTO[NTERM-NUM]. */
  470. static const yytype_int8 yydefgoto[] =
  471. {
  472. -1, 6, 7, 8, 9, 10, 11, 12, 13, 14
  473. };
  474. /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
  475. positive, shift that token. If negative, reduce the rule whose
  476. number is the opposite. If YYTABLE_NINF, syntax error. */
  477. static const yytype_uint8 yytable[] =
  478. {
  479. 15, 16, 20, 18, 1, 2, 19, 27, 28, 29,
  480. 21, 3, 23, 24, 25, 26, 4, 5, 30, 20,
  481. 34, 35, 22, 36, 37, 17, 38, 39, 40, 32,
  482. 31, 0, 0, 0, 33
  483. };
  484. static const yytype_int8 yycheck[] =
  485. {
  486. 1, 2, 12, 4, 3, 4, 0, 5, 6, 7,
  487. 14, 10, 8, 9, 3, 4, 15, 16, 11, 12,
  488. 23, 24, 13, 25, 26, 3, 27, 28, 29, 21,
  489. 20, -1, -1, -1, 22
  490. };
  491. /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
  492. symbol of state STATE-NUM. */
  493. static const yytype_uint8 yystos[] =
  494. {
  495. 0, 3, 4, 10, 15, 16, 18, 19, 20, 21,
  496. 22, 23, 24, 25, 26, 25, 25, 19, 25, 0,
  497. 12, 14, 13, 8, 9, 3, 4, 5, 6, 7,
  498. 11, 20, 21, 22, 23, 23, 24, 24, 25, 25,
  499. 25
  500. };
  501. /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
  502. static const yytype_uint8 yyr1[] =
  503. {
  504. 0, 17, 18, 19, 19, 20, 20, 21, 21, 22,
  505. 22, 22, 23, 23, 23, 24, 24, 24, 24, 25,
  506. 25, 25, 25, 26, 26
  507. };
  508. /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
  509. static const yytype_uint8 yyr2[] =
  510. {
  511. 0, 2, 1, 1, 3, 1, 3, 1, 3, 1,
  512. 3, 3, 1, 3, 3, 1, 3, 3, 3, 1,
  513. 2, 2, 2, 1, 3
  514. };
  515. #define yyerrok (yyerrstatus = 0)
  516. #define yyclearin (yychar = YYEMPTY)
  517. #define YYEMPTY (-2)
  518. #define YYEOF 0
  519. #define YYACCEPT goto yyacceptlab
  520. #define YYABORT goto yyabortlab
  521. #define YYERROR goto yyerrorlab
  522. #define YYRECOVERING() (!!yyerrstatus)
  523. #define YYBACKUP(Token, Value) \
  524. do \
  525. if (yychar == YYEMPTY) \
  526. { \
  527. yychar = (Token); \
  528. yylval = (Value); \
  529. YYPOPSTACK (yylen); \
  530. yystate = *yyssp; \
  531. goto yybackup; \
  532. } \
  533. else \
  534. { \
  535. yyerror (yyscanner, YY_("syntax error: cannot back up")); \
  536. YYERROR; \
  537. } \
  538. while (0)
  539. /* Error token number */
  540. #define YYTERROR 1
  541. #define YYERRCODE 256
  542. /* Enable debugging if requested. */
  543. #if YYDEBUG
  544. # ifndef YYFPRINTF
  545. # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
  546. # define YYFPRINTF fprintf
  547. # endif
  548. # define YYDPRINTF(Args) \
  549. do { \
  550. if (yydebug) \
  551. YYFPRINTF Args; \
  552. } while (0)
  553. /* This macro is provided for backward compatibility. */
  554. #ifndef YY_LOCATION_PRINT
  555. # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
  556. #endif
  557. # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
  558. do { \
  559. if (yydebug) \
  560. { \
  561. YYFPRINTF (stderr, "%s ", Title); \
  562. yy_symbol_print (stderr, \
  563. Type, Value, yyscanner); \
  564. YYFPRINTF (stderr, "\n"); \
  565. } \
  566. } while (0)
  567. /*-----------------------------------.
  568. | Print this symbol's value on YYO. |
  569. `-----------------------------------*/
  570. static void
  571. yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner)
  572. {
  573. FILE *yyoutput = yyo;
  574. YYUSE (yyoutput);
  575. YYUSE (yyscanner);
  576. if (!yyvaluep)
  577. return;
  578. # ifdef YYPRINT
  579. if (yytype < YYNTOKENS)
  580. YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
  581. # endif
  582. YYUSE (yytype);
  583. }
  584. /*---------------------------.
  585. | Print this symbol on YYO. |
  586. `---------------------------*/
  587. static void
  588. yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner)
  589. {
  590. YYFPRINTF (yyo, "%s %s (",
  591. yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
  592. yy_symbol_value_print (yyo, yytype, yyvaluep, yyscanner);
  593. YYFPRINTF (yyo, ")");
  594. }
  595. /*------------------------------------------------------------------.
  596. | yy_stack_print -- Print the state stack from its BOTTOM up to its |
  597. | TOP (included). |
  598. `------------------------------------------------------------------*/
  599. static void
  600. yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
  601. {
  602. YYFPRINTF (stderr, "Stack now");
  603. for (; yybottom <= yytop; yybottom++)
  604. {
  605. int yybot = *yybottom;
  606. YYFPRINTF (stderr, " %d", yybot);
  607. }
  608. YYFPRINTF (stderr, "\n");
  609. }
  610. # define YY_STACK_PRINT(Bottom, Top) \
  611. do { \
  612. if (yydebug) \
  613. yy_stack_print ((Bottom), (Top)); \
  614. } while (0)
  615. /*------------------------------------------------.
  616. | Report that the YYRULE is going to be reduced. |
  617. `------------------------------------------------*/
  618. static void
  619. yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, yyscan_t yyscanner)
  620. {
  621. unsigned long yylno = yyrline[yyrule];
  622. int yynrhs = yyr2[yyrule];
  623. int yyi;
  624. YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
  625. yyrule - 1, yylno);
  626. /* The symbols being reduced. */
  627. for (yyi = 0; yyi < yynrhs; yyi++)
  628. {
  629. YYFPRINTF (stderr, " $%d = ", yyi + 1);
  630. yy_symbol_print (stderr,
  631. yystos[yyssp[yyi + 1 - yynrhs]],
  632. &yyvsp[(yyi + 1) - (yynrhs)]
  633. , yyscanner);
  634. YYFPRINTF (stderr, "\n");
  635. }
  636. }
  637. # define YY_REDUCE_PRINT(Rule) \
  638. do { \
  639. if (yydebug) \
  640. yy_reduce_print (yyssp, yyvsp, Rule, yyscanner); \
  641. } while (0)
  642. /* Nonzero means print parse trace. It is left uninitialized so that
  643. multiple parsers can coexist. */
  644. int yydebug;
  645. #else /* !YYDEBUG */
  646. # define YYDPRINTF(Args)
  647. # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
  648. # define YY_STACK_PRINT(Bottom, Top)
  649. # define YY_REDUCE_PRINT(Rule)
  650. #endif /* !YYDEBUG */
  651. /* YYINITDEPTH -- initial size of the parser's stacks. */
  652. #ifndef YYINITDEPTH
  653. # define YYINITDEPTH 200
  654. #endif
  655. /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
  656. if the built-in stack extension method is used).
  657. Do not make this value too large; the results are undefined if
  658. YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
  659. evaluated with infinite-precision integer arithmetic. */
  660. #ifndef YYMAXDEPTH
  661. # define YYMAXDEPTH 10000
  662. #endif
  663. #if YYERROR_VERBOSE
  664. # ifndef yystrlen
  665. # if defined __GLIBC__ && defined _STRING_H
  666. # define yystrlen strlen
  667. # else
  668. /* Return the length of YYSTR. */
  669. static YYSIZE_T
  670. yystrlen (const char *yystr)
  671. {
  672. YYSIZE_T yylen;
  673. for (yylen = 0; yystr[yylen]; yylen++)
  674. continue;
  675. return yylen;
  676. }
  677. # endif
  678. # endif
  679. # ifndef yystpcpy
  680. # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
  681. # define yystpcpy stpcpy
  682. # else
  683. /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
  684. YYDEST. */
  685. static char *
  686. yystpcpy (char *yydest, const char *yysrc)
  687. {
  688. char *yyd = yydest;
  689. const char *yys = yysrc;
  690. while ((*yyd++ = *yys++) != '\0')
  691. continue;
  692. return yyd - 1;
  693. }
  694. # endif
  695. # endif
  696. # ifndef yytnamerr
  697. /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
  698. quotes and backslashes, so that it's suitable for yyerror. The
  699. heuristic is that double-quoting is unnecessary unless the string
  700. contains an apostrophe, a comma, or backslash (other than
  701. backslash-backslash). YYSTR is taken from yytname. If YYRES is
  702. null, do not copy; instead, return the length of what the result
  703. would have been. */
  704. static YYSIZE_T
  705. yytnamerr (char *yyres, const char *yystr)
  706. {
  707. if (*yystr == '"')
  708. {
  709. YYSIZE_T yyn = 0;
  710. char const *yyp = yystr;
  711. for (;;)
  712. switch (*++yyp)
  713. {
  714. case '\'':
  715. case ',':
  716. goto do_not_strip_quotes;
  717. case '\\':
  718. if (*++yyp != '\\')
  719. goto do_not_strip_quotes;
  720. else
  721. goto append;
  722. append:
  723. default:
  724. if (yyres)
  725. yyres[yyn] = *yyp;
  726. yyn++;
  727. break;
  728. case '"':
  729. if (yyres)
  730. yyres[yyn] = '\0';
  731. return yyn;
  732. }
  733. do_not_strip_quotes: ;
  734. }
  735. if (! yyres)
  736. return yystrlen (yystr);
  737. return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres);
  738. }
  739. # endif
  740. /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
  741. about the unexpected token YYTOKEN for the state stack whose top is
  742. YYSSP.
  743. Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
  744. not large enough to hold the message. In that case, also set
  745. *YYMSG_ALLOC to the required number of bytes. Return 2 if the
  746. required number of bytes is too large to store. */
  747. static int
  748. yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
  749. yytype_int16 *yyssp, int yytoken)
  750. {
  751. YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
  752. YYSIZE_T yysize = yysize0;
  753. enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
  754. /* Internationalized format string. */
  755. const char *yyformat = YY_NULLPTR;
  756. /* Arguments of yyformat. */
  757. char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
  758. /* Number of reported tokens (one for the "unexpected", one per
  759. "expected"). */
  760. int yycount = 0;
  761. /* There are many possibilities here to consider:
  762. - If this state is a consistent state with a default action, then
  763. the only way this function was invoked is if the default action
  764. is an error action. In that case, don't check for expected
  765. tokens because there are none.
  766. - The only way there can be no lookahead present (in yychar) is if
  767. this state is a consistent state with a default action. Thus,
  768. detecting the absence of a lookahead is sufficient to determine
  769. that there is no unexpected or expected token to report. In that
  770. case, just report a simple "syntax error".
  771. - Don't assume there isn't a lookahead just because this state is a
  772. consistent state with a default action. There might have been a
  773. previous inconsistent state, consistent state with a non-default
  774. action, or user semantic action that manipulated yychar.
  775. - Of course, the expected token list depends on states to have
  776. correct lookahead information, and it depends on the parser not
  777. to perform extra reductions after fetching a lookahead from the
  778. scanner and before detecting a syntax error. Thus, state merging
  779. (from LALR or IELR) and default reductions corrupt the expected
  780. token list. However, the list is correct for canonical LR with
  781. one exception: it will still contain any token that will not be
  782. accepted due to an error action in a later state.
  783. */
  784. if (yytoken != YYEMPTY)
  785. {
  786. int yyn = yypact[*yyssp];
  787. yyarg[yycount++] = yytname[yytoken];
  788. if (!yypact_value_is_default (yyn))
  789. {
  790. /* Start YYX at -YYN if negative to avoid negative indexes in
  791. YYCHECK. In other words, skip the first -YYN actions for
  792. this state because they are default actions. */
  793. int yyxbegin = yyn < 0 ? -yyn : 0;
  794. /* Stay within bounds of both yycheck and yytname. */
  795. int yychecklim = YYLAST - yyn + 1;
  796. int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
  797. int yyx;
  798. for (yyx = yyxbegin; yyx < yyxend; ++yyx)
  799. if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
  800. && !yytable_value_is_error (yytable[yyx + yyn]))
  801. {
  802. if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
  803. {
  804. yycount = 1;
  805. yysize = yysize0;
  806. break;
  807. }
  808. yyarg[yycount++] = yytname[yyx];
  809. {
  810. YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
  811. if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
  812. yysize = yysize1;
  813. else
  814. return 2;
  815. }
  816. }
  817. }
  818. }
  819. switch (yycount)
  820. {
  821. # define YYCASE_(N, S) \
  822. case N: \
  823. yyformat = S; \
  824. break
  825. default: /* Avoid compiler warnings. */
  826. YYCASE_(0, YY_("syntax error"));
  827. YYCASE_(1, YY_("syntax error, unexpected %s"));
  828. YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
  829. YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
  830. YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
  831. YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
  832. # undef YYCASE_
  833. }
  834. {
  835. YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
  836. if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
  837. yysize = yysize1;
  838. else
  839. return 2;
  840. }
  841. if (*yymsg_alloc < yysize)
  842. {
  843. *yymsg_alloc = 2 * yysize;
  844. if (! (yysize <= *yymsg_alloc
  845. && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
  846. *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
  847. return 1;
  848. }
  849. /* Avoid sprintf, as that infringes on the user's name space.
  850. Don't have undefined behavior even if the translation
  851. produced a string with the wrong number of "%s"s. */
  852. {
  853. char *yyp = *yymsg;
  854. int yyi = 0;
  855. while ((*yyp = *yyformat) != '\0')
  856. if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
  857. {
  858. yyp += yytnamerr (yyp, yyarg[yyi++]);
  859. yyformat += 2;
  860. }
  861. else
  862. {
  863. yyp++;
  864. yyformat++;
  865. }
  866. }
  867. return 0;
  868. }
  869. #endif /* YYERROR_VERBOSE */
  870. /*-----------------------------------------------.
  871. | Release the memory associated to this symbol. |
  872. `-----------------------------------------------*/
  873. static void
  874. yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, yyscan_t yyscanner)
  875. {
  876. YYUSE (yyvaluep);
  877. YYUSE (yyscanner);
  878. if (!yymsg)
  879. yymsg = "Deleting";
  880. YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
  881. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  882. YYUSE (yytype);
  883. YY_IGNORE_MAYBE_UNINITIALIZED_END
  884. }
  885. /*----------.
  886. | yyparse. |
  887. `----------*/
  888. int
  889. yyparse (yyscan_t yyscanner)
  890. {
  891. /* The lookahead symbol. */
  892. int yychar;
  893. /* The semantic value of the lookahead symbol. */
  894. /* Default value used for initialization, for pacifying older GCCs
  895. or non-GCC compilers. */
  896. YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
  897. YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
  898. /* Number of syntax errors so far. */
  899. int yynerrs;
  900. int yystate;
  901. /* Number of tokens to shift before error messages enabled. */
  902. int yyerrstatus;
  903. /* The stacks and their tools:
  904. 'yyss': related to states.
  905. 'yyvs': related to semantic values.
  906. Refer to the stacks through separate pointers, to allow yyoverflow
  907. to reallocate them elsewhere. */
  908. /* The state stack. */
  909. yytype_int16 yyssa[YYINITDEPTH];
  910. yytype_int16 *yyss;
  911. yytype_int16 *yyssp;
  912. /* The semantic value stack. */
  913. YYSTYPE yyvsa[YYINITDEPTH];
  914. YYSTYPE *yyvs;
  915. YYSTYPE *yyvsp;
  916. YYSIZE_T yystacksize;
  917. int yyn;
  918. int yyresult;
  919. /* Lookahead token as an internal (translated) token number. */
  920. int yytoken = 0;
  921. /* The variables used to return semantic value and location from the
  922. action routines. */
  923. YYSTYPE yyval;
  924. #if YYERROR_VERBOSE
  925. /* Buffer for error messages, and its allocated size. */
  926. char yymsgbuf[128];
  927. char *yymsg = yymsgbuf;
  928. YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
  929. #endif
  930. #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
  931. /* The number of symbols on the RHS of the reduced rule.
  932. Keep to zero when no symbol should be popped. */
  933. int yylen = 0;
  934. yyssp = yyss = yyssa;
  935. yyvsp = yyvs = yyvsa;
  936. yystacksize = YYINITDEPTH;
  937. YYDPRINTF ((stderr, "Starting parse\n"));
  938. yystate = 0;
  939. yyerrstatus = 0;
  940. yynerrs = 0;
  941. yychar = YYEMPTY; /* Cause a token to be read. */
  942. goto yysetstate;
  943. /*------------------------------------------------------------.
  944. | yynewstate -- push a new state, which is found in yystate. |
  945. `------------------------------------------------------------*/
  946. yynewstate:
  947. /* In all cases, when you get here, the value and location stacks
  948. have just been pushed. So pushing a state here evens the stacks. */
  949. yyssp++;
  950. /*--------------------------------------------------------------------.
  951. | yynewstate -- set current state (the top of the stack) to yystate. |
  952. `--------------------------------------------------------------------*/
  953. yysetstate:
  954. *yyssp = (yytype_int16) yystate;
  955. if (yyss + yystacksize - 1 <= yyssp)
  956. #if !defined yyoverflow && !defined YYSTACK_RELOCATE
  957. goto yyexhaustedlab;
  958. #else
  959. {
  960. /* Get the current used size of the three stacks, in elements. */
  961. YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);
  962. # if defined yyoverflow
  963. {
  964. /* Give user a chance to reallocate the stack. Use copies of
  965. these so that the &'s don't force the real ones into
  966. memory. */
  967. YYSTYPE *yyvs1 = yyvs;
  968. yytype_int16 *yyss1 = yyss;
  969. /* Each stack pointer address is followed by the size of the
  970. data in use in that stack, in bytes. This used to be a
  971. conditional around just the two extra args, but that might
  972. be undefined if yyoverflow is a macro. */
  973. yyoverflow (YY_("memory exhausted"),
  974. &yyss1, yysize * sizeof (*yyssp),
  975. &yyvs1, yysize * sizeof (*yyvsp),
  976. &yystacksize);
  977. yyss = yyss1;
  978. yyvs = yyvs1;
  979. }
  980. # else /* defined YYSTACK_RELOCATE */
  981. /* Extend the stack our own way. */
  982. if (YYMAXDEPTH <= yystacksize)
  983. goto yyexhaustedlab;
  984. yystacksize *= 2;
  985. if (YYMAXDEPTH < yystacksize)
  986. yystacksize = YYMAXDEPTH;
  987. {
  988. yytype_int16 *yyss1 = yyss;
  989. union yyalloc *yyptr =
  990. (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
  991. if (! yyptr)
  992. goto yyexhaustedlab;
  993. YYSTACK_RELOCATE (yyss_alloc, yyss);
  994. YYSTACK_RELOCATE (yyvs_alloc, yyvs);
  995. # undef YYSTACK_RELOCATE
  996. if (yyss1 != yyssa)
  997. YYSTACK_FREE (yyss1);
  998. }
  999. # endif
  1000. yyssp = yyss + yysize - 1;
  1001. yyvsp = yyvs + yysize - 1;
  1002. YYDPRINTF ((stderr, "Stack size increased to %lu\n",
  1003. (unsigned long) yystacksize));
  1004. if (yyss + yystacksize - 1 <= yyssp)
  1005. YYABORT;
  1006. }
  1007. #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
  1008. YYDPRINTF ((stderr, "Entering state %d\n", yystate));
  1009. if (yystate == YYFINAL)
  1010. YYACCEPT;
  1011. goto yybackup;
  1012. /*-----------.
  1013. | yybackup. |
  1014. `-----------*/
  1015. yybackup:
  1016. /* Do appropriate processing given the current state. Read a
  1017. lookahead token if we need one and don't already have one. */
  1018. /* First try to decide what to do without reference to lookahead token. */
  1019. yyn = yypact[yystate];
  1020. if (yypact_value_is_default (yyn))
  1021. goto yydefault;
  1022. /* Not known => get a lookahead token if don't already have one. */
  1023. /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
  1024. if (yychar == YYEMPTY)
  1025. {
  1026. YYDPRINTF ((stderr, "Reading a token: "));
  1027. yychar = yylex (&yylval, yyscanner);
  1028. }
  1029. if (yychar <= YYEOF)
  1030. {
  1031. yychar = yytoken = YYEOF;
  1032. YYDPRINTF ((stderr, "Now at end of input.\n"));
  1033. }
  1034. else
  1035. {
  1036. yytoken = YYTRANSLATE (yychar);
  1037. YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
  1038. }
  1039. /* If the proper action on seeing token YYTOKEN is to reduce or to
  1040. detect an error, take that action. */
  1041. yyn += yytoken;
  1042. if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
  1043. goto yydefault;
  1044. yyn = yytable[yyn];
  1045. if (yyn <= 0)
  1046. {
  1047. if (yytable_value_is_error (yyn))
  1048. goto yyerrlab;
  1049. yyn = -yyn;
  1050. goto yyreduce;
  1051. }
  1052. /* Count tokens shifted since error; after three, turn off error
  1053. status. */
  1054. if (yyerrstatus)
  1055. yyerrstatus--;
  1056. /* Shift the lookahead token. */
  1057. YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
  1058. /* Discard the shifted token. */
  1059. yychar = YYEMPTY;
  1060. yystate = yyn;
  1061. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  1062. *++yyvsp = yylval;
  1063. YY_IGNORE_MAYBE_UNINITIALIZED_END
  1064. goto yynewstate;
  1065. /*-----------------------------------------------------------.
  1066. | yydefault -- do the default action for the current state. |
  1067. `-----------------------------------------------------------*/
  1068. yydefault:
  1069. yyn = yydefact[yystate];
  1070. if (yyn == 0)
  1071. goto yyerrlab;
  1072. goto yyreduce;
  1073. /*-----------------------------.
  1074. | yyreduce -- do a reduction. |
  1075. `-----------------------------*/
  1076. yyreduce:
  1077. /* yyn is the number of a rule to reduce with. */
  1078. yylen = yyr2[yyn];
  1079. /* If YYLEN is nonzero, implement the default value of the action:
  1080. '$$ = $1'.
  1081. Otherwise, the following line sets YYVAL to garbage.
  1082. This behavior is undocumented and Bison
  1083. users should not rely upon it. Assigning to YYVAL
  1084. unconditionally makes the parser a bit smaller, and it avoids a
  1085. GCC warning that YYVAL may be used uninitialized. */
  1086. yyval = yyvsp[1-yylen];
  1087. YY_REDUCE_PRINT (yyn);
  1088. switch (yyn)
  1089. {
  1090. case 2:
  1091. #line 77 "cmExprParser.y" /* yacc.c:1652 */
  1092. {
  1093. cmExpr_yyget_extra(yyscanner)->SetResult((yyvsp[0].Number));
  1094. }
  1095. #line 1301 "cmExprParser.cxx" /* yacc.c:1652 */
  1096. break;
  1097. case 3:
  1098. #line 82 "cmExprParser.y" /* yacc.c:1652 */
  1099. {
  1100. (yyval.Number) = (yyvsp[0].Number);
  1101. }
  1102. #line 1309 "cmExprParser.cxx" /* yacc.c:1652 */
  1103. break;
  1104. case 4:
  1105. #line 85 "cmExprParser.y" /* yacc.c:1652 */
  1106. {
  1107. (yyval.Number) = (yyvsp[-2].Number) | (yyvsp[0].Number);
  1108. }
  1109. #line 1317 "cmExprParser.cxx" /* yacc.c:1652 */
  1110. break;
  1111. case 5:
  1112. #line 90 "cmExprParser.y" /* yacc.c:1652 */
  1113. {
  1114. (yyval.Number) = (yyvsp[0].Number);
  1115. }
  1116. #line 1325 "cmExprParser.cxx" /* yacc.c:1652 */
  1117. break;
  1118. case 6:
  1119. #line 93 "cmExprParser.y" /* yacc.c:1652 */
  1120. {
  1121. (yyval.Number) = (yyvsp[-2].Number) ^ (yyvsp[0].Number);
  1122. }
  1123. #line 1333 "cmExprParser.cxx" /* yacc.c:1652 */
  1124. break;
  1125. case 7:
  1126. #line 98 "cmExprParser.y" /* yacc.c:1652 */
  1127. {
  1128. (yyval.Number) = (yyvsp[0].Number);
  1129. }
  1130. #line 1341 "cmExprParser.cxx" /* yacc.c:1652 */
  1131. break;
  1132. case 8:
  1133. #line 101 "cmExprParser.y" /* yacc.c:1652 */
  1134. {
  1135. (yyval.Number) = (yyvsp[-2].Number) & (yyvsp[0].Number);
  1136. }
  1137. #line 1349 "cmExprParser.cxx" /* yacc.c:1652 */
  1138. break;
  1139. case 9:
  1140. #line 106 "cmExprParser.y" /* yacc.c:1652 */
  1141. {
  1142. (yyval.Number) = (yyvsp[0].Number);
  1143. }
  1144. #line 1357 "cmExprParser.cxx" /* yacc.c:1652 */
  1145. break;
  1146. case 10:
  1147. #line 109 "cmExprParser.y" /* yacc.c:1652 */
  1148. {
  1149. (yyval.Number) = (yyvsp[-2].Number) << (yyvsp[0].Number);
  1150. }
  1151. #line 1365 "cmExprParser.cxx" /* yacc.c:1652 */
  1152. break;
  1153. case 11:
  1154. #line 112 "cmExprParser.y" /* yacc.c:1652 */
  1155. {
  1156. (yyval.Number) = (yyvsp[-2].Number) >> (yyvsp[0].Number);
  1157. }
  1158. #line 1373 "cmExprParser.cxx" /* yacc.c:1652 */
  1159. break;
  1160. case 12:
  1161. #line 117 "cmExprParser.y" /* yacc.c:1652 */
  1162. {
  1163. (yyval.Number) = (yyvsp[0].Number);
  1164. }
  1165. #line 1381 "cmExprParser.cxx" /* yacc.c:1652 */
  1166. break;
  1167. case 13:
  1168. #line 120 "cmExprParser.y" /* yacc.c:1652 */
  1169. {
  1170. (yyval.Number) = (yyvsp[-2].Number) + (yyvsp[0].Number);
  1171. }
  1172. #line 1389 "cmExprParser.cxx" /* yacc.c:1652 */
  1173. break;
  1174. case 14:
  1175. #line 123 "cmExprParser.y" /* yacc.c:1652 */
  1176. {
  1177. (yyval.Number) = (yyvsp[-2].Number) - (yyvsp[0].Number);
  1178. }
  1179. #line 1397 "cmExprParser.cxx" /* yacc.c:1652 */
  1180. break;
  1181. case 15:
  1182. #line 128 "cmExprParser.y" /* yacc.c:1652 */
  1183. {
  1184. (yyval.Number) = (yyvsp[0].Number);
  1185. }
  1186. #line 1405 "cmExprParser.cxx" /* yacc.c:1652 */
  1187. break;
  1188. case 16:
  1189. #line 131 "cmExprParser.y" /* yacc.c:1652 */
  1190. {
  1191. (yyval.Number) = (yyvsp[-2].Number) * (yyvsp[0].Number);
  1192. }
  1193. #line 1413 "cmExprParser.cxx" /* yacc.c:1652 */
  1194. break;
  1195. case 17:
  1196. #line 134 "cmExprParser.y" /* yacc.c:1652 */
  1197. {
  1198. if (yyvsp[0].Number == 0) {
  1199. throw std::overflow_error("divide by zero");
  1200. }
  1201. (yyval.Number) = (yyvsp[-2].Number) / (yyvsp[0].Number);
  1202. }
  1203. #line 1424 "cmExprParser.cxx" /* yacc.c:1652 */
  1204. break;
  1205. case 18:
  1206. #line 140 "cmExprParser.y" /* yacc.c:1652 */
  1207. {
  1208. (yyval.Number) = (yyvsp[-2].Number) % (yyvsp[0].Number);
  1209. }
  1210. #line 1432 "cmExprParser.cxx" /* yacc.c:1652 */
  1211. break;
  1212. case 19:
  1213. #line 145 "cmExprParser.y" /* yacc.c:1652 */
  1214. {
  1215. (yyval.Number) = (yyvsp[0].Number);
  1216. }
  1217. #line 1440 "cmExprParser.cxx" /* yacc.c:1652 */
  1218. break;
  1219. case 20:
  1220. #line 148 "cmExprParser.y" /* yacc.c:1652 */
  1221. {
  1222. (yyval.Number) = + (yyvsp[0].Number);
  1223. }
  1224. #line 1448 "cmExprParser.cxx" /* yacc.c:1652 */
  1225. break;
  1226. case 21:
  1227. #line 151 "cmExprParser.y" /* yacc.c:1652 */
  1228. {
  1229. (yyval.Number) = - (yyvsp[0].Number);
  1230. }
  1231. #line 1456 "cmExprParser.cxx" /* yacc.c:1652 */
  1232. break;
  1233. case 22:
  1234. #line 154 "cmExprParser.y" /* yacc.c:1652 */
  1235. {
  1236. (yyval.Number) = ~ (yyvsp[0].Number);
  1237. }
  1238. #line 1464 "cmExprParser.cxx" /* yacc.c:1652 */
  1239. break;
  1240. case 23:
  1241. #line 159 "cmExprParser.y" /* yacc.c:1652 */
  1242. {
  1243. (yyval.Number) = (yyvsp[0].Number);
  1244. }
  1245. #line 1472 "cmExprParser.cxx" /* yacc.c:1652 */
  1246. break;
  1247. case 24:
  1248. #line 162 "cmExprParser.y" /* yacc.c:1652 */
  1249. {
  1250. (yyval.Number) = (yyvsp[-1].Number);
  1251. }
  1252. #line 1480 "cmExprParser.cxx" /* yacc.c:1652 */
  1253. break;
  1254. #line 1484 "cmExprParser.cxx" /* yacc.c:1652 */
  1255. default: break;
  1256. }
  1257. /* User semantic actions sometimes alter yychar, and that requires
  1258. that yytoken be updated with the new translation. We take the
  1259. approach of translating immediately before every use of yytoken.
  1260. One alternative is translating here after every semantic action,
  1261. but that translation would be missed if the semantic action invokes
  1262. YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
  1263. if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
  1264. incorrect destructor might then be invoked immediately. In the
  1265. case of YYERROR or YYBACKUP, subsequent parser actions might lead
  1266. to an incorrect destructor call or verbose syntax error message
  1267. before the lookahead is translated. */
  1268. YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
  1269. YYPOPSTACK (yylen);
  1270. yylen = 0;
  1271. YY_STACK_PRINT (yyss, yyssp);
  1272. *++yyvsp = yyval;
  1273. /* Now 'shift' the result of the reduction. Determine what state
  1274. that goes to, based on the state we popped back to and the rule
  1275. number reduced by. */
  1276. {
  1277. const int yylhs = yyr1[yyn] - YYNTOKENS;
  1278. const int yyi = yypgoto[yylhs] + *yyssp;
  1279. yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
  1280. ? yytable[yyi]
  1281. : yydefgoto[yylhs]);
  1282. }
  1283. goto yynewstate;
  1284. /*--------------------------------------.
  1285. | yyerrlab -- here on detecting error. |
  1286. `--------------------------------------*/
  1287. yyerrlab:
  1288. /* Make sure we have latest lookahead translation. See comments at
  1289. user semantic actions for why this is necessary. */
  1290. yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
  1291. /* If not already recovering from an error, report this error. */
  1292. if (!yyerrstatus)
  1293. {
  1294. ++yynerrs;
  1295. #if ! YYERROR_VERBOSE
  1296. yyerror (yyscanner, YY_("syntax error"));
  1297. #else
  1298. # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
  1299. yyssp, yytoken)
  1300. {
  1301. char const *yymsgp = YY_("syntax error");
  1302. int yysyntax_error_status;
  1303. yysyntax_error_status = YYSYNTAX_ERROR;
  1304. if (yysyntax_error_status == 0)
  1305. yymsgp = yymsg;
  1306. else if (yysyntax_error_status == 1)
  1307. {
  1308. if (yymsg != yymsgbuf)
  1309. YYSTACK_FREE (yymsg);
  1310. yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
  1311. if (!yymsg)
  1312. {
  1313. yymsg = yymsgbuf;
  1314. yymsg_alloc = sizeof yymsgbuf;
  1315. yysyntax_error_status = 2;
  1316. }
  1317. else
  1318. {
  1319. yysyntax_error_status = YYSYNTAX_ERROR;
  1320. yymsgp = yymsg;
  1321. }
  1322. }
  1323. yyerror (yyscanner, yymsgp);
  1324. if (yysyntax_error_status == 2)
  1325. goto yyexhaustedlab;
  1326. }
  1327. # undef YYSYNTAX_ERROR
  1328. #endif
  1329. }
  1330. if (yyerrstatus == 3)
  1331. {
  1332. /* If just tried and failed to reuse lookahead token after an
  1333. error, discard it. */
  1334. if (yychar <= YYEOF)
  1335. {
  1336. /* Return failure if at end of input. */
  1337. if (yychar == YYEOF)
  1338. YYABORT;
  1339. }
  1340. else
  1341. {
  1342. yydestruct ("Error: discarding",
  1343. yytoken, &yylval, yyscanner);
  1344. yychar = YYEMPTY;
  1345. }
  1346. }
  1347. #if 0
  1348. /* Else will try to reuse lookahead token after shifting the error
  1349. token. */
  1350. goto yyerrlab1;
  1351. /*---------------------------------------------------.
  1352. | yyerrorlab -- error raised explicitly by YYERROR. |
  1353. `---------------------------------------------------*/
  1354. yyerrorlab:
  1355. /* Pacify compilers when the user code never invokes YYERROR and the
  1356. label yyerrorlab therefore never appears in user code. */
  1357. if (0)
  1358. YYERROR;
  1359. /* Do not reclaim the symbols of the rule whose action triggered
  1360. this YYERROR. */
  1361. YYPOPSTACK (yylen);
  1362. yylen = 0;
  1363. YY_STACK_PRINT (yyss, yyssp);
  1364. yystate = *yyssp;
  1365. goto yyerrlab1;
  1366. /*-------------------------------------------------------------.
  1367. | yyerrlab1 -- common code for both syntax error and YYERROR. |
  1368. `-------------------------------------------------------------*/
  1369. yyerrlab1:
  1370. #endif
  1371. yyerrstatus = 3; /* Each real token shifted decrements this. */
  1372. for (;;)
  1373. {
  1374. yyn = yypact[yystate];
  1375. if (!yypact_value_is_default (yyn))
  1376. {
  1377. yyn += YYTERROR;
  1378. if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
  1379. {
  1380. yyn = yytable[yyn];
  1381. if (0 < yyn)
  1382. break;
  1383. }
  1384. }
  1385. /* Pop the current state because it cannot handle the error token. */
  1386. if (yyssp == yyss)
  1387. YYABORT;
  1388. yydestruct ("Error: popping",
  1389. yystos[yystate], yyvsp, yyscanner);
  1390. YYPOPSTACK (1);
  1391. yystate = *yyssp;
  1392. YY_STACK_PRINT (yyss, yyssp);
  1393. }
  1394. YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  1395. *++yyvsp = yylval;
  1396. YY_IGNORE_MAYBE_UNINITIALIZED_END
  1397. /* Shift the error token. */
  1398. YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
  1399. yystate = yyn;
  1400. goto yynewstate;
  1401. /*-------------------------------------.
  1402. | yyacceptlab -- YYACCEPT comes here. |
  1403. `-------------------------------------*/
  1404. yyacceptlab:
  1405. yyresult = 0;
  1406. goto yyreturn;
  1407. /*-----------------------------------.
  1408. | yyabortlab -- YYABORT comes here. |
  1409. `-----------------------------------*/
  1410. yyabortlab:
  1411. yyresult = 1;
  1412. goto yyreturn;
  1413. #if !defined yyoverflow || YYERROR_VERBOSE
  1414. /*-------------------------------------------------.
  1415. | yyexhaustedlab -- memory exhaustion comes here. |
  1416. `-------------------------------------------------*/
  1417. yyexhaustedlab:
  1418. yyerror (yyscanner, YY_("memory exhausted"));
  1419. yyresult = 2;
  1420. /* Fall through. */
  1421. #endif
  1422. /*-----------------------------------------------------.
  1423. | yyreturn -- parsing is finished, return the result. |
  1424. `-----------------------------------------------------*/
  1425. yyreturn:
  1426. if (yychar != YYEMPTY)
  1427. {
  1428. /* Make sure we have latest lookahead translation. See comments at
  1429. user semantic actions for why this is necessary. */
  1430. yytoken = YYTRANSLATE (yychar);
  1431. yydestruct ("Cleanup: discarding lookahead",
  1432. yytoken, &yylval, yyscanner);
  1433. }
  1434. /* Do not reclaim the symbols of the rule whose action triggered
  1435. this YYABORT or YYACCEPT. */
  1436. YYPOPSTACK (yylen);
  1437. YY_STACK_PRINT (yyss, yyssp);
  1438. while (yyssp != yyss)
  1439. {
  1440. yydestruct ("Cleanup: popping",
  1441. yystos[*yyssp], yyvsp, yyscanner);
  1442. YYPOPSTACK (1);
  1443. }
  1444. #ifndef yyoverflow
  1445. if (yyss != yyssa)
  1446. YYSTACK_FREE (yyss);
  1447. #endif
  1448. #if YYERROR_VERBOSE
  1449. if (yymsg != yymsgbuf)
  1450. YYSTACK_FREE (yymsg);
  1451. #endif
  1452. return yyresult;
  1453. }
  1454. #line 167 "cmExprParser.y" /* yacc.c:1918 */
  1455. /* End of grammar */
  1456. /*--------------------------------------------------------------------------*/
  1457. void cmExpr_yyerror(yyscan_t yyscanner, const char* message)
  1458. {
  1459. cmExpr_yyget_extra(yyscanner)->Error(message);
  1460. }