cmExprParser.cxx 57 KB

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