cmExprParser.cxx 57 KB

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