cmExprParser.cxx 57 KB

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