cmExprParser.cxx 50 KB

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