cmExprParser.cxx 57 KB

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