Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1098 рядки
32 KiB

  1. /* A Bison parser, made by GNU Bison 2.4.2. */
  2. /* Skeleton implementation for Bison LALR(1) parsers in C++
  3. Copyright (C) 2002-2010 Free Software Foundation, Inc.
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. /* As a special exception, you may create a larger work that contains
  15. part or all of the Bison parser skeleton and distribute that work
  16. under terms of your choice, so long as that work isn't itself a
  17. parser generator using the skeleton or a modified version thereof
  18. as a parser skeleton. Alternatively, if you modify or redistribute
  19. the parser skeleton itself, you may (at your option) remove this
  20. special exception, which will cause the skeleton and the resulting
  21. Bison output files to be licensed under the GNU General Public
  22. License without this special exception.
  23. This special exception was added by the Free Software Foundation in
  24. version 2.2 of Bison. */
  25. // Take the name prefix into account.
  26. #define yylex lollex
  27. /* First part of user declarations. */
  28. /* Line 310 of lalr1.cc */
  29. #line 1 "scenesetup-parser.y"
  30. //
  31. // Lol Engine
  32. //
  33. // Copyright: (c) 2013 Benjamin "Touky" Huet <huet.benjamin@gmail.com>
  34. // (c) 2013 Sam Hocevar <sam@hocevar.net>
  35. // This program is free software; you can redistribute it and/or
  36. // modify it under the terms of the Do What The Fuck You Want To
  37. // Public License, Version 2, as published by Sam Hocevar. See
  38. // http://www.wtfpl.net/ for more details.
  39. //
  40. #if defined HAVE_CONFIG_H
  41. # include "config.h"
  42. #endif
  43. #include "core.h"
  44. #include "../scenesetup.h"
  45. /* Line 310 of lalr1.cc */
  46. #line 63 "generated/scenesetup-parser.cpp"
  47. #include "scenesetup-parser.h"
  48. /* User implementation prologue. */
  49. /* Line 316 of lalr1.cc */
  50. #line 75 "scenesetup-parser.y"
  51. #include "../scenesetup-compiler.h"
  52. #undef yylex
  53. #define yylex uc.m_lexer->lex
  54. /* HACK: workaround for Bison who insists on using exceptions */
  55. #define try if (true)
  56. #define catch(...) if (false)
  57. #define throw (void)0
  58. /* Line 316 of lalr1.cc */
  59. #line 85 "generated/scenesetup-parser.cpp"
  60. #ifndef YY_
  61. # if defined YYENABLE_NLS && YYENABLE_NLS
  62. # if ENABLE_NLS
  63. # include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
  64. # define YY_(msgid) dgettext ("bison-runtime", msgid)
  65. # endif
  66. # endif
  67. # ifndef YY_
  68. # define YY_(msgid) msgid
  69. # endif
  70. #endif
  71. /* Suppress unused-variable warnings by "using" E. */
  72. #define YYUSE(e) ((void) (e))
  73. /* Enable debugging if requested. */
  74. #if YYDEBUG
  75. /* A pseudo ostream that takes yydebug_ into account. */
  76. # define YYCDEBUG if (yydebug_) (*yycdebug_)
  77. # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
  78. do { \
  79. if (yydebug_) \
  80. { \
  81. *yycdebug_ << Title << ' '; \
  82. yy_symbol_print_ ((Type), (Value), (Location)); \
  83. *yycdebug_ << std::endl; \
  84. } \
  85. } while (false)
  86. # define YY_REDUCE_PRINT(Rule) \
  87. do { \
  88. if (yydebug_) \
  89. yy_reduce_print_ (Rule); \
  90. } while (false)
  91. # define YY_STACK_PRINT() \
  92. do { \
  93. if (yydebug_) \
  94. yystack_print_ (); \
  95. } while (false)
  96. #else /* !YYDEBUG */
  97. # define YYCDEBUG if (false) std::cerr
  98. # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
  99. # define YY_REDUCE_PRINT(Rule)
  100. # define YY_STACK_PRINT()
  101. #endif /* !YYDEBUG */
  102. #define yyerrok (yyerrstatus_ = 0)
  103. #define yyclearin (yychar = yyempty_)
  104. #define YYACCEPT goto yyacceptlab
  105. #define YYABORT goto yyabortlab
  106. #define YYERROR goto yyerrorlab
  107. #define YYRECOVERING() (!!yyerrstatus_)
  108. namespace lol {
  109. /* Line 379 of lalr1.cc */
  110. #line 151 "generated/scenesetup-parser.cpp"
  111. #if YYERROR_VERBOSE
  112. /* Return YYSTR after stripping away unnecessary quotes and
  113. backslashes, so that it's suitable for yyerror. The heuristic is
  114. that double-quoting is unnecessary unless the string contains an
  115. apostrophe, a comma, or backslash (other than backslash-backslash).
  116. YYSTR is taken from yytname. */
  117. std::string
  118. SceneSetupParser::yytnamerr_ (const char *yystr)
  119. {
  120. if (*yystr == '"')
  121. {
  122. std::string yyr = "";
  123. char const *yyp = yystr;
  124. for (;;)
  125. switch (*++yyp)
  126. {
  127. case '\'':
  128. case ',':
  129. goto do_not_strip_quotes;
  130. case '\\':
  131. if (*++yyp != '\\')
  132. goto do_not_strip_quotes;
  133. /* Fall through. */
  134. default:
  135. yyr += *yyp;
  136. break;
  137. case '"':
  138. return yyr;
  139. }
  140. do_not_strip_quotes: ;
  141. }
  142. return yystr;
  143. }
  144. #endif
  145. /// Build a parser object.
  146. SceneSetupParser::SceneSetupParser (class SceneSetupCompiler& uc_yyarg)
  147. :
  148. #if YYDEBUG
  149. yydebug_ (false),
  150. yycdebug_ (&std::cerr),
  151. #endif
  152. uc (uc_yyarg)
  153. {
  154. }
  155. SceneSetupParser::~SceneSetupParser ()
  156. {
  157. }
  158. #if YYDEBUG
  159. /*--------------------------------.
  160. | Print this symbol on YYOUTPUT. |
  161. `--------------------------------*/
  162. inline void
  163. SceneSetupParser::yy_symbol_value_print_ (int yytype,
  164. const semantic_type* yyvaluep, const location_type* yylocationp)
  165. {
  166. YYUSE (yylocationp);
  167. YYUSE (yyvaluep);
  168. switch (yytype)
  169. {
  170. default:
  171. break;
  172. }
  173. }
  174. void
  175. SceneSetupParser::yy_symbol_print_ (int yytype,
  176. const semantic_type* yyvaluep, const location_type* yylocationp)
  177. {
  178. *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm")
  179. << ' ' << yytname_[yytype] << " ("
  180. << *yylocationp << ": ";
  181. yy_symbol_value_print_ (yytype, yyvaluep, yylocationp);
  182. *yycdebug_ << ')';
  183. }
  184. #endif
  185. void
  186. SceneSetupParser::yydestruct_ (const char* yymsg,
  187. int yytype, semantic_type* yyvaluep, location_type* yylocationp)
  188. {
  189. YYUSE (yylocationp);
  190. YYUSE (yymsg);
  191. YYUSE (yyvaluep);
  192. YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
  193. switch (yytype)
  194. {
  195. default:
  196. break;
  197. }
  198. }
  199. void
  200. SceneSetupParser::yypop_ (unsigned int n)
  201. {
  202. yystate_stack_.pop (n);
  203. yysemantic_stack_.pop (n);
  204. yylocation_stack_.pop (n);
  205. }
  206. #if YYDEBUG
  207. std::ostream&
  208. SceneSetupParser::debug_stream () const
  209. {
  210. return *yycdebug_;
  211. }
  212. void
  213. SceneSetupParser::set_debug_stream (std::ostream& o)
  214. {
  215. yycdebug_ = &o;
  216. }
  217. SceneSetupParser::debug_level_type
  218. SceneSetupParser::debug_level () const
  219. {
  220. return yydebug_;
  221. }
  222. void
  223. SceneSetupParser::set_debug_level (debug_level_type l)
  224. {
  225. yydebug_ = l;
  226. }
  227. #endif
  228. int
  229. SceneSetupParser::parse ()
  230. {
  231. /// Lookahead and lookahead in internal form.
  232. int yychar = yyempty_;
  233. int yytoken = 0;
  234. /* State. */
  235. int yyn;
  236. int yylen = 0;
  237. int yystate = 0;
  238. /* Error handling. */
  239. int yynerrs_ = 0;
  240. int yyerrstatus_ = 0;
  241. /// Semantic value of the lookahead.
  242. semantic_type yylval;
  243. /// Location of the lookahead.
  244. location_type yylloc;
  245. /// The locations where the error started and ended.
  246. location_type yyerror_range[2];
  247. /// $$.
  248. semantic_type yyval;
  249. /// @$.
  250. location_type yyloc;
  251. int yyresult;
  252. YYCDEBUG << "Starting parse" << std::endl;
  253. /* Initialize the stacks. The initial state will be pushed in
  254. yynewstate, since the latter expects the semantical and the
  255. location values to have been already stored, initialize these
  256. stacks with a primary value. */
  257. yystate_stack_ = state_stack_type (0);
  258. yysemantic_stack_ = semantic_stack_type (0);
  259. yylocation_stack_ = location_stack_type (0);
  260. yysemantic_stack_.push (yylval);
  261. yylocation_stack_.push (yylloc);
  262. /* New state. */
  263. yynewstate:
  264. yystate_stack_.push (yystate);
  265. YYCDEBUG << "Entering state " << yystate << std::endl;
  266. /* Accept? */
  267. if (yystate == yyfinal_)
  268. goto yyacceptlab;
  269. goto yybackup;
  270. /* Backup. */
  271. yybackup:
  272. /* Try to take a decision without lookahead. */
  273. yyn = yypact_[yystate];
  274. if (yyn == yypact_ninf_)
  275. goto yydefault;
  276. /* Read a lookahead token. */
  277. if (yychar == yyempty_)
  278. {
  279. YYCDEBUG << "Reading a token: ";
  280. yychar = yylex (&yylval, &yylloc);
  281. }
  282. /* Convert token to internal form. */
  283. if (yychar <= yyeof_)
  284. {
  285. yychar = yytoken = yyeof_;
  286. YYCDEBUG << "Now at end of input." << std::endl;
  287. }
  288. else
  289. {
  290. yytoken = yytranslate_ (yychar);
  291. YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
  292. }
  293. /* If the proper action on seeing token YYTOKEN is to reduce or to
  294. detect an error, take that action. */
  295. yyn += yytoken;
  296. if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken)
  297. goto yydefault;
  298. /* Reduce or error. */
  299. yyn = yytable_[yyn];
  300. if (yyn <= 0)
  301. {
  302. if (yyn == 0 || yyn == yytable_ninf_)
  303. goto yyerrlab;
  304. yyn = -yyn;
  305. goto yyreduce;
  306. }
  307. /* Shift the lookahead token. */
  308. YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
  309. /* Discard the token being shifted. */
  310. yychar = yyempty_;
  311. yysemantic_stack_.push (yylval);
  312. yylocation_stack_.push (yylloc);
  313. /* Count tokens shifted since error; after three, turn off error
  314. status. */
  315. if (yyerrstatus_)
  316. --yyerrstatus_;
  317. yystate = yyn;
  318. goto yynewstate;
  319. /*-----------------------------------------------------------.
  320. | yydefault -- do the default action for the current state. |
  321. `-----------------------------------------------------------*/
  322. yydefault:
  323. yyn = yydefact_[yystate];
  324. if (yyn == 0)
  325. goto yyerrlab;
  326. goto yyreduce;
  327. /*-----------------------------.
  328. | yyreduce -- Do a reduction. |
  329. `-----------------------------*/
  330. yyreduce:
  331. yylen = yyr2_[yyn];
  332. /* If YYLEN is nonzero, implement the default value of the action:
  333. `$$ = $1'. Otherwise, use the top of the stack.
  334. Otherwise, the following line sets YYVAL to garbage.
  335. This behavior is undocumented and Bison
  336. users should not rely upon it. */
  337. if (yylen)
  338. yyval = yysemantic_stack_[yylen - 1];
  339. else
  340. yyval = yysemantic_stack_[0];
  341. {
  342. slice<location_type, location_stack_type> slice (yylocation_stack_, yylen);
  343. YYLLOC_DEFAULT (yyloc, slice, yylen);
  344. }
  345. YY_REDUCE_PRINT (yyn);
  346. switch (yyn)
  347. {
  348. case 11:
  349. /* Line 677 of lalr1.cc */
  350. #line 114 "scenesetup-parser.y"
  351. { uc.m_sstp.m_lights << new Light(); uc.m_last_cmd = "ADDLIGHT"; }
  352. break;
  353. case 12:
  354. /* Line 677 of lalr1.cc */
  355. #line 115 "scenesetup-parser.y"
  356. { uc.m_sstp.m_lights << new Light(); uc.m_last_cmd = "ADDLIGHT";
  357. uc.m_sstp.m_lights.Last()->SetPosition(vec4(vec3::zero, (yysemantic_stack_[(2) - (2)].fval))); }
  358. break;
  359. case 13:
  360. /* Line 677 of lalr1.cc */
  361. #line 120 "scenesetup-parser.y"
  362. { if (uc.m_last_cmd == "ADDLIGHT")
  363. uc.m_sstp.m_lights.Last()->SetPosition(vec4(vec3((yysemantic_stack_[(2) - (2)].vval)[0], (yysemantic_stack_[(2) - (2)].vval)[1], (yysemantic_stack_[(2) - (2)].vval)[2]), uc.m_sstp.m_lights.Last()->GetPosition().w)); }
  364. break;
  365. case 14:
  366. /* Line 677 of lalr1.cc */
  367. #line 122 "scenesetup-parser.y"
  368. { if (uc.m_last_cmd == "ADDLIGHT")
  369. { /* */ } }
  370. break;
  371. case 15:
  372. /* Line 677 of lalr1.cc */
  373. #line 124 "scenesetup-parser.y"
  374. { if (uc.m_last_cmd == "ADDLIGHT")
  375. uc.m_sstp.m_lights.Last()->SetColor(vec4((yysemantic_stack_[(2) - (2)].vval)[0], (yysemantic_stack_[(2) - (2)].vval)[1], (yysemantic_stack_[(2) - (2)].vval)[2], (yysemantic_stack_[(2) - (2)].vval)[3])); }
  376. break;
  377. case 16:
  378. /* Line 677 of lalr1.cc */
  379. #line 126 "scenesetup-parser.y"
  380. { uint32_t x = (yysemantic_stack_[(2) - (2)].u32val);
  381. ivec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff);
  382. vec4 vv = vec4(v) * (1.f / 255.f);
  383. if (uc.m_last_cmd == "ADDLIGHT")
  384. uc.m_sstp.m_lights.Last()->SetColor(vv); }
  385. break;
  386. case 17:
  387. /* Line 677 of lalr1.cc */
  388. #line 131 "scenesetup-parser.y"
  389. { uc.m_sstp.m_clear_color = vec4((yysemantic_stack_[(2) - (2)].vval)[0], (yysemantic_stack_[(2) - (2)].vval)[1], (yysemantic_stack_[(2) - (2)].vval)[2], (yysemantic_stack_[(2) - (2)].vval)[3]); }
  390. break;
  391. case 18:
  392. /* Line 677 of lalr1.cc */
  393. #line 132 "scenesetup-parser.y"
  394. { uint32_t x = (yysemantic_stack_[(2) - (2)].u32val); ivec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff);
  395. uc.m_sstp.m_clear_color = vec4(v) * (1.f / 255.f); }
  396. break;
  397. case 19:
  398. /* Line 677 of lalr1.cc */
  399. #line 137 "scenesetup-parser.y"
  400. { uc.m_sstp.m_custom_cmd.Push((yysemantic_stack_[(3) - (2)].svval), (yysemantic_stack_[(3) - (3)].sval)); }
  401. break;
  402. case 20:
  403. /* Line 677 of lalr1.cc */
  404. #line 143 "scenesetup-parser.y"
  405. { (yyval.fval) = (yysemantic_stack_[(1) - (1)].fval); }
  406. break;
  407. case 21:
  408. /* Line 677 of lalr1.cc */
  409. #line 144 "scenesetup-parser.y"
  410. { (yyval.fval) = -(yysemantic_stack_[(2) - (2)].fval); }
  411. break;
  412. case 22:
  413. /* Line 677 of lalr1.cc */
  414. #line 145 "scenesetup-parser.y"
  415. { (yyval.fval) = (float)(yysemantic_stack_[(1) - (1)].ival); }
  416. break;
  417. case 23:
  418. /* Line 677 of lalr1.cc */
  419. #line 146 "scenesetup-parser.y"
  420. { (yyval.fval) = -(float)(yysemantic_stack_[(2) - (2)].ival); }
  421. break;
  422. case 24:
  423. /* Line 677 of lalr1.cc */
  424. #line 150 "scenesetup-parser.y"
  425. { (yyval.ival) = (yysemantic_stack_[(1) - (1)].ival); }
  426. break;
  427. case 25:
  428. /* Line 677 of lalr1.cc */
  429. #line 151 "scenesetup-parser.y"
  430. { (yyval.ival) = -(yysemantic_stack_[(2) - (2)].ival); }
  431. break;
  432. case 26:
  433. /* Line 677 of lalr1.cc */
  434. #line 152 "scenesetup-parser.y"
  435. { (yyval.ival) = (int)(yysemantic_stack_[(1) - (1)].fval); }
  436. break;
  437. case 27:
  438. /* Line 677 of lalr1.cc */
  439. #line 153 "scenesetup-parser.y"
  440. { (yyval.ival) = -(int)(yysemantic_stack_[(2) - (2)].fval); }
  441. break;
  442. case 28:
  443. /* Line 677 of lalr1.cc */
  444. #line 158 "scenesetup-parser.y"
  445. { (yyval.vval)[0] = (yysemantic_stack_[(3) - (2)].fval); (yyval.vval)[1] = (yysemantic_stack_[(3) - (2)].fval); (yyval.vval)[2] = (yysemantic_stack_[(3) - (2)].fval); }
  446. break;
  447. case 29:
  448. /* Line 677 of lalr1.cc */
  449. #line 159 "scenesetup-parser.y"
  450. { (yyval.vval)[0] = (yysemantic_stack_[(5) - (2)].fval); (yyval.vval)[1] = (yysemantic_stack_[(5) - (3)].fval); (yyval.vval)[2] = (yysemantic_stack_[(5) - (4)].fval); }
  451. break;
  452. case 30:
  453. /* Line 677 of lalr1.cc */
  454. #line 168 "scenesetup-parser.y"
  455. { (yyval.vval)[0] = (yysemantic_stack_[(3) - (2)].fval); (yyval.vval)[1] = (yysemantic_stack_[(3) - (2)].fval); (yyval.vval)[2] = (yysemantic_stack_[(3) - (2)].fval); (yyval.vval)[3] = (yysemantic_stack_[(3) - (2)].fval); }
  456. break;
  457. case 31:
  458. /* Line 677 of lalr1.cc */
  459. #line 169 "scenesetup-parser.y"
  460. { (yyval.vval)[0] = (yysemantic_stack_[(6) - (2)].fval); (yyval.vval)[1] = (yysemantic_stack_[(6) - (3)].fval); (yyval.vval)[2] = (yysemantic_stack_[(6) - (4)].fval); (yyval.vval)[3] = (yysemantic_stack_[(6) - (5)].fval); }
  461. break;
  462. case 32:
  463. /* Line 677 of lalr1.cc */
  464. #line 180 "scenesetup-parser.y"
  465. { (yyval.svval) = (yysemantic_stack_[(1) - (1)].svval); }
  466. break;
  467. case 33:
  468. /* Line 677 of lalr1.cc */
  469. #line 184 "scenesetup-parser.y"
  470. { String t = (yysemantic_stack_[(1) - (1)].sval);
  471. t.Replace('"', ' ', true);
  472. free((yysemantic_stack_[(1) - (1)].sval));
  473. (yyval.sval) = strdup((const char *)t.C()); }
  474. break;
  475. case 34:
  476. /* Line 677 of lalr1.cc */
  477. #line 188 "scenesetup-parser.y"
  478. { String t = (yysemantic_stack_[(2) - (1)].sval);
  479. t += (yysemantic_stack_[(2) - (2)].sval);
  480. t.Replace('"', ' ', true);
  481. free((yysemantic_stack_[(2) - (1)].sval));
  482. free((yysemantic_stack_[(2) - (2)].sval));
  483. (yyval.sval) = strdup((const char *)t.C()); }
  484. break;
  485. /* Line 677 of lalr1.cc */
  486. #line 627 "generated/scenesetup-parser.cpp"
  487. default:
  488. break;
  489. }
  490. YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc);
  491. yypop_ (yylen);
  492. yylen = 0;
  493. YY_STACK_PRINT ();
  494. yysemantic_stack_.push (yyval);
  495. yylocation_stack_.push (yyloc);
  496. /* Shift the result of the reduction. */
  497. yyn = yyr1_[yyn];
  498. yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0];
  499. if (0 <= yystate && yystate <= yylast_
  500. && yycheck_[yystate] == yystate_stack_[0])
  501. yystate = yytable_[yystate];
  502. else
  503. yystate = yydefgoto_[yyn - yyntokens_];
  504. goto yynewstate;
  505. /*------------------------------------.
  506. | yyerrlab -- here on detecting error |
  507. `------------------------------------*/
  508. yyerrlab:
  509. /* If not already recovering from an error, report this error. */
  510. if (!yyerrstatus_)
  511. {
  512. ++yynerrs_;
  513. error (yylloc, yysyntax_error_ (yystate, yytoken));
  514. }
  515. yyerror_range[0] = yylloc;
  516. if (yyerrstatus_ == 3)
  517. {
  518. /* If just tried and failed to reuse lookahead token after an
  519. error, discard it. */
  520. if (yychar <= yyeof_)
  521. {
  522. /* Return failure if at end of input. */
  523. if (yychar == yyeof_)
  524. YYABORT;
  525. }
  526. else
  527. {
  528. yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc);
  529. yychar = yyempty_;
  530. }
  531. }
  532. /* Else will try to reuse lookahead token after shifting the error
  533. token. */
  534. goto yyerrlab1;
  535. /*---------------------------------------------------.
  536. | yyerrorlab -- error raised explicitly by YYERROR. |
  537. `---------------------------------------------------*/
  538. yyerrorlab:
  539. /* Pacify compilers like GCC when the user code never invokes
  540. YYERROR and the label yyerrorlab therefore never appears in user
  541. code. */
  542. if (false)
  543. goto yyerrorlab;
  544. yyerror_range[0] = yylocation_stack_[yylen - 1];
  545. /* Do not reclaim the symbols of the rule which action triggered
  546. this YYERROR. */
  547. yypop_ (yylen);
  548. yylen = 0;
  549. yystate = yystate_stack_[0];
  550. goto yyerrlab1;
  551. /*-------------------------------------------------------------.
  552. | yyerrlab1 -- common code for both syntax error and YYERROR. |
  553. `-------------------------------------------------------------*/
  554. yyerrlab1:
  555. yyerrstatus_ = 3; /* Each real token shifted decrements this. */
  556. for (;;)
  557. {
  558. yyn = yypact_[yystate];
  559. if (yyn != yypact_ninf_)
  560. {
  561. yyn += yyterror_;
  562. if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
  563. {
  564. yyn = yytable_[yyn];
  565. if (0 < yyn)
  566. break;
  567. }
  568. }
  569. /* Pop the current state because it cannot handle the error token. */
  570. if (yystate_stack_.height () == 1)
  571. YYABORT;
  572. yyerror_range[0] = yylocation_stack_[0];
  573. yydestruct_ ("Error: popping",
  574. yystos_[yystate],
  575. &yysemantic_stack_[0], &yylocation_stack_[0]);
  576. yypop_ ();
  577. yystate = yystate_stack_[0];
  578. YY_STACK_PRINT ();
  579. }
  580. yyerror_range[1] = yylloc;
  581. // Using YYLLOC is tempting, but would change the location of
  582. // the lookahead. YYLOC is available though.
  583. YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
  584. yysemantic_stack_.push (yylval);
  585. yylocation_stack_.push (yyloc);
  586. /* Shift the error token. */
  587. YY_SYMBOL_PRINT ("Shifting", yystos_[yyn],
  588. &yysemantic_stack_[0], &yylocation_stack_[0]);
  589. yystate = yyn;
  590. goto yynewstate;
  591. /* Accept. */
  592. yyacceptlab:
  593. yyresult = 0;
  594. goto yyreturn;
  595. /* Abort. */
  596. yyabortlab:
  597. yyresult = 1;
  598. goto yyreturn;
  599. yyreturn:
  600. if (yychar != yyempty_)
  601. yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc);
  602. /* Do not reclaim the symbols of the rule which action triggered
  603. this YYABORT or YYACCEPT. */
  604. yypop_ (yylen);
  605. while (yystate_stack_.height () != 1)
  606. {
  607. yydestruct_ ("Cleanup: popping",
  608. yystos_[yystate_stack_[0]],
  609. &yysemantic_stack_[0],
  610. &yylocation_stack_[0]);
  611. yypop_ ();
  612. }
  613. return yyresult;
  614. }
  615. // Generate an error message.
  616. std::string
  617. SceneSetupParser::yysyntax_error_ (int yystate, int tok)
  618. {
  619. std::string res;
  620. YYUSE (yystate);
  621. #if YYERROR_VERBOSE
  622. int yyn = yypact_[yystate];
  623. if (yypact_ninf_ < yyn && yyn <= yylast_)
  624. {
  625. /* Start YYX at -YYN if negative to avoid negative indexes in
  626. YYCHECK. */
  627. int yyxbegin = yyn < 0 ? -yyn : 0;
  628. /* Stay within bounds of both yycheck and yytname. */
  629. int yychecklim = yylast_ - yyn + 1;
  630. int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
  631. int count = 0;
  632. for (int x = yyxbegin; x < yyxend; ++x)
  633. if (yycheck_[x + yyn] == x && x != yyterror_)
  634. ++count;
  635. // FIXME: This method of building the message is not compatible
  636. // with internationalization. It should work like yacc.c does it.
  637. // That is, first build a string that looks like this:
  638. // "syntax error, unexpected %s or %s or %s"
  639. // Then, invoke YY_ on this string.
  640. // Finally, use the string as a format to output
  641. // yytname_[tok], etc.
  642. // Until this gets fixed, this message appears in English only.
  643. res = "syntax error, unexpected ";
  644. res += yytnamerr_ (yytname_[tok]);
  645. if (count < 5)
  646. {
  647. count = 0;
  648. for (int x = yyxbegin; x < yyxend; ++x)
  649. if (yycheck_[x + yyn] == x && x != yyterror_)
  650. {
  651. res += (!count++) ? ", expecting " : " or ";
  652. res += yytnamerr_ (yytname_[x]);
  653. }
  654. }
  655. }
  656. else
  657. #endif
  658. res = YY_("syntax error");
  659. return res;
  660. }
  661. /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
  662. STATE-NUM. */
  663. const signed char SceneSetupParser::yypact_ninf_ = -18;
  664. const signed char
  665. SceneSetupParser::yypact_[] =
  666. {
  667. 30, 8, -13, -13, -6, -2, 3, 1, 26, 30,
  668. 30, -18, -18, -18, -18, -18, -18, 12, -18, 8,
  669. -18, -18, -18, 8, -18, -18, -18, -18, 14, -18,
  670. -18, -18, -18, -18, -18, 12, -18, -18, -8, -4,
  671. 14, -18, -18, -18, -18, 8, -18, 8, -18, 13,
  672. 8, -18, 21, -18
  673. };
  674. /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
  675. doesn't specify something else to do. Zero means the default is an
  676. error. */
  677. const unsigned char
  678. SceneSetupParser::yydefact_[] =
  679. {
  680. 0, 11, 0, 0, 0, 0, 0, 0, 0, 3,
  681. 5, 6, 8, 9, 10, 20, 22, 0, 12, 0,
  682. 13, 14, 16, 0, 15, 18, 17, 32, 0, 1,
  683. 2, 4, 7, 20, 22, 0, 21, 23, 0, 0,
  684. 33, 19, 21, 23, 28, 0, 30, 0, 34, 0,
  685. 0, 29, 0, 31
  686. };
  687. /* YYPGOTO[NTERM-NUM]. */
  688. const signed char
  689. SceneSetupParser::yypgoto_[] =
  690. {
  691. -18, -18, 22, -18, -18, 31, -18, -18, -18, -17,
  692. 7, 40, 39, -18, 5
  693. };
  694. /* YYDEFGOTO[NTERM-NUM]. */
  695. const signed char
  696. SceneSetupParser::yydefgoto_[] =
  697. {
  698. -1, 7, 8, 9, 10, 11, 12, 13, 14, 18,
  699. 37, 20, 24, 28, 41
  700. };
  701. /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
  702. positive, shift that token. If negative, reduce the rule which
  703. number is the opposite. If zero, do what YYDEFACT says. */
  704. const signed char SceneSetupParser::yytable_ninf_ = -1;
  705. const unsigned char
  706. SceneSetupParser::yytable_[] =
  707. {
  708. 36, 29, 38, 15, 16, 19, 39, 15, 16, 17,
  709. 22, 44, 23, 17, 25, 46, 23, 27, 42, 15,
  710. 16, 45, 47, 33, 34, 17, 30, 40, 49, 35,
  711. 50, 31, 51, 52, 1, 2, 3, 4, 5, 6,
  712. 53, 32, 43, 21, 26, 48
  713. };
  714. /* YYCHECK. */
  715. const unsigned char
  716. SceneSetupParser::yycheck_[] =
  717. {
  718. 17, 0, 19, 11, 12, 18, 23, 11, 12, 17,
  719. 16, 19, 18, 17, 16, 19, 18, 14, 35, 11,
  720. 12, 38, 39, 11, 12, 17, 0, 13, 45, 17,
  721. 47, 9, 19, 50, 4, 5, 6, 7, 8, 9,
  722. 19, 10, 35, 3, 5, 40
  723. };
  724. /* STOS_[STATE-NUM] -- The (internal number of the) accessing
  725. symbol of state STATE-NUM. */
  726. const unsigned char
  727. SceneSetupParser::yystos_[] =
  728. {
  729. 0, 4, 5, 6, 7, 8, 9, 21, 22, 23,
  730. 24, 25, 26, 27, 28, 11, 12, 17, 29, 18,
  731. 31, 31, 16, 18, 32, 16, 32, 14, 33, 0,
  732. 0, 22, 25, 11, 12, 17, 29, 30, 29, 29,
  733. 13, 34, 29, 30, 19, 29, 19, 29, 34, 29,
  734. 29, 19, 29, 19
  735. };
  736. #if YYDEBUG
  737. /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
  738. to YYLEX-NUM. */
  739. const unsigned short int
  740. SceneSetupParser::yytoken_number_[] =
  741. {
  742. 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
  743. 265, 266, 267, 268, 269, 270, 271, 45, 40, 41
  744. };
  745. #endif
  746. /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
  747. const unsigned char
  748. SceneSetupParser::yyr1_[] =
  749. {
  750. 0, 20, 21, 22, 22, 23, 24, 24, 25, 25,
  751. 25, 26, 26, 27, 27, 27, 27, 27, 27, 28,
  752. 29, 29, 29, 29, 30, 30, 30, 30, 31, 31,
  753. 32, 32, 33, 34, 34
  754. };
  755. /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
  756. const unsigned char
  757. SceneSetupParser::yyr2_[] =
  758. {
  759. 0, 2, 2, 1, 2, 1, 1, 2, 1, 1,
  760. 1, 1, 2, 2, 2, 2, 2, 2, 2, 3,
  761. 1, 2, 1, 2, 1, 2, 1, 2, 3, 5,
  762. 3, 6, 1, 1, 2
  763. };
  764. #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
  765. /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
  766. First, the terminals, then, starting at \a yyntokens_, nonterminals. */
  767. const char*
  768. const SceneSetupParser::yytname_[] =
  769. {
  770. "T_END", "error", "$undefined", "T_COLOR", "T_ADDLIGHT",
  771. "T_OBJPOSITION", "T_OBJLOOKAT", "T_OBJCOLOR", "T_CLEARCOLOR",
  772. "T_CUSTOMCMD", "T_ERROR", "F_NUMBER", "I_NUMBER", "STRING", "STRING_VAR",
  773. "BOOLEAN", "COLOR", "'-'", "'('", "')'", "$accept", "sstp_description",
  774. "sstp_expression_list", "sstp_expression", "sstp_command_list",
  775. "sstp_command", "light_command", "setup_command", "custom_command", "fv",
  776. "iv", "v3", "v4", "svv", "sv", 0
  777. };
  778. #endif
  779. #if YYDEBUG
  780. /* YYRHS -- A `-1'-separated list of the rules' RHS. */
  781. const SceneSetupParser::rhs_number_type
  782. SceneSetupParser::yyrhs_[] =
  783. {
  784. 21, 0, -1, 22, 0, -1, 23, -1, 23, 22,
  785. -1, 24, -1, 25, -1, 24, 25, -1, 26, -1,
  786. 27, -1, 28, -1, 4, -1, 4, 29, -1, 5,
  787. 31, -1, 6, 31, -1, 7, 32, -1, 7, 16,
  788. -1, 8, 32, -1, 8, 16, -1, 9, 33, 34,
  789. -1, 11, -1, 17, 29, -1, 12, -1, 17, 30,
  790. -1, 12, -1, 17, 30, -1, 11, -1, 17, 29,
  791. -1, 18, 29, 19, -1, 18, 29, 29, 29, 19,
  792. -1, 18, 29, 19, -1, 18, 29, 29, 29, 29,
  793. 19, -1, 14, -1, 13, -1, 13, 34, -1
  794. };
  795. /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
  796. YYRHS. */
  797. const unsigned char
  798. SceneSetupParser::yyprhs_[] =
  799. {
  800. 0, 0, 3, 6, 8, 11, 13, 15, 18, 20,
  801. 22, 24, 26, 29, 32, 35, 38, 41, 44, 47,
  802. 51, 53, 56, 58, 61, 63, 66, 68, 71, 75,
  803. 81, 85, 92, 94, 96
  804. };
  805. /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
  806. const unsigned char
  807. SceneSetupParser::yyrline_[] =
  808. {
  809. 0, 90, 90, 94, 95, 99, 103, 104, 108, 109,
  810. 110, 114, 115, 120, 122, 124, 126, 131, 132, 137,
  811. 143, 144, 145, 146, 150, 151, 152, 153, 158, 159,
  812. 168, 169, 180, 184, 188
  813. };
  814. // Print the state stack on the debug stream.
  815. void
  816. SceneSetupParser::yystack_print_ ()
  817. {
  818. *yycdebug_ << "Stack now";
  819. for (state_stack_type::const_iterator i = yystate_stack_.begin ();
  820. i != yystate_stack_.end (); ++i)
  821. *yycdebug_ << ' ' << *i;
  822. *yycdebug_ << std::endl;
  823. }
  824. // Report on the debug stream that the rule \a yyrule is going to be reduced.
  825. void
  826. SceneSetupParser::yy_reduce_print_ (int yyrule)
  827. {
  828. unsigned int yylno = yyrline_[yyrule];
  829. int yynrhs = yyr2_[yyrule];
  830. /* Print the symbols being reduced, and their result. */
  831. *yycdebug_ << "Reducing stack by rule " << yyrule - 1
  832. << " (line " << yylno << "):" << std::endl;
  833. /* The symbols being reduced. */
  834. for (int yyi = 0; yyi < yynrhs; yyi++)
  835. YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
  836. yyrhs_[yyprhs_[yyrule] + yyi],
  837. &(yysemantic_stack_[(yynrhs) - (yyi + 1)]),
  838. &(yylocation_stack_[(yynrhs) - (yyi + 1)]));
  839. }
  840. #endif // YYDEBUG
  841. /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
  842. SceneSetupParser::token_number_type
  843. SceneSetupParser::yytranslate_ (int t)
  844. {
  845. static
  846. const token_number_type
  847. translate_table[] =
  848. {
  849. 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  850. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  851. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  852. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  853. 18, 19, 2, 2, 2, 17, 2, 2, 2, 2,
  854. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  855. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  856. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  857. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  858. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  859. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  860. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  861. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  862. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  863. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  864. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  865. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  866. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  867. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  868. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  869. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  870. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  871. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  872. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  873. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  874. 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
  875. 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  876. 15, 16
  877. };
  878. if ((unsigned int) t <= yyuser_token_number_max_)
  879. return translate_table[t];
  880. else
  881. return yyundef_token_;
  882. }
  883. const int SceneSetupParser::yyeof_ = 0;
  884. const int SceneSetupParser::yylast_ = 45;
  885. const int SceneSetupParser::yynnts_ = 15;
  886. const int SceneSetupParser::yyempty_ = -2;
  887. const int SceneSetupParser::yyfinal_ = 29;
  888. const int SceneSetupParser::yyterror_ = 1;
  889. const int SceneSetupParser::yyerrcode_ = 256;
  890. const int SceneSetupParser::yyntokens_ = 20;
  891. const unsigned int SceneSetupParser::yyuser_token_number_max_ = 271;
  892. const SceneSetupParser::token_number_type SceneSetupParser::yyundef_token_ = 2;
  893. } // lol
  894. /* Line 1053 of lalr1.cc */
  895. #line 1085 "generated/scenesetup-parser.cpp"
  896. /* Line 1055 of lalr1.cc */
  897. #line 196 "scenesetup-parser.y"
  898. void lol::SceneSetupParser::error(const SceneSetupParser::location_type& l,
  899. const std::string& m)
  900. {
  901. uc.Error(l, m);
  902. }