cmExprParser.cxx 57 KB

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