您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

1161 行
34 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 HAVE_CONFIG_H
  41. # include "config.h"
  42. #endif
  43. #include <lol/engine.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 76 "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 12:
  349. /* Line 677 of lalr1.cc */
  350. #line 116 "scenesetup-parser.y"
  351. { uc.m_sstp.m_lights << new Light(); uc.m_last_cmd = "ADDLIGHT"; }
  352. break;
  353. case 13:
  354. /* Line 677 of lalr1.cc */
  355. #line 117 "scenesetup-parser.y"
  356. { uc.m_sstp.m_lights << new Light(); uc.m_last_cmd = "ADDLIGHT";
  357. uc.m_sstp.m_lights.Last()->SetType(LightType((yysemantic_stack_[(2) - (2)].fval))); }
  358. break;
  359. case 14:
  360. /* Line 677 of lalr1.cc */
  361. #line 119 "scenesetup-parser.y"
  362. { uc.m_sstp.m_lights << new Light(); uc.m_last_cmd = "ADDLIGHT";
  363. uc.m_sstp.m_lights.Last()->SetType(FindValue<LightType>((yysemantic_stack_[(2) - (2)].svval))); }
  364. break;
  365. case 15:
  366. /* Line 677 of lalr1.cc */
  367. #line 124 "scenesetup-parser.y"
  368. { if (uc.m_last_cmd == "ADDLIGHT")
  369. uc.m_sstp.m_lights.Last()->SetPosition(vec3((yysemantic_stack_[(2) - (2)].vval)[0], (yysemantic_stack_[(2) - (2)].vval)[1], (yysemantic_stack_[(2) - (2)].vval)[2])); }
  370. break;
  371. case 16:
  372. /* Line 677 of lalr1.cc */
  373. #line 126 "scenesetup-parser.y"
  374. { if (uc.m_last_cmd == "ADDLIGHT")
  375. { /* */ } }
  376. break;
  377. case 17:
  378. /* Line 677 of lalr1.cc */
  379. #line 128 "scenesetup-parser.y"
  380. { if (uc.m_last_cmd == "ADDLIGHT")
  381. 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])); }
  382. break;
  383. case 18:
  384. /* Line 677 of lalr1.cc */
  385. #line 130 "scenesetup-parser.y"
  386. { uint32_t x = (yysemantic_stack_[(2) - (2)].u32val);
  387. ivec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff);
  388. vec4 vv = vec4(v) * (1.f / 255.f);
  389. if (uc.m_last_cmd == "ADDLIGHT")
  390. uc.m_sstp.m_lights.Last()->SetColor(vv); }
  391. break;
  392. case 19:
  393. /* Line 677 of lalr1.cc */
  394. #line 138 "scenesetup-parser.y"
  395. { 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]); }
  396. break;
  397. case 20:
  398. /* Line 677 of lalr1.cc */
  399. #line 139 "scenesetup-parser.y"
  400. { uc.m_sstp.m_clear_color = vec4((yysemantic_stack_[(5) - (2)].vval)[0], (yysemantic_stack_[(5) - (2)].vval)[1], (yysemantic_stack_[(5) - (2)].vval)[2], 1.f); }
  401. break;
  402. case 21:
  403. /* Line 677 of lalr1.cc */
  404. #line 140 "scenesetup-parser.y"
  405. { uint32_t x = (yysemantic_stack_[(2) - (2)].u32val); ivec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff);
  406. uc.m_sstp.m_clear_color = vec4(v) * (1.f / 255.f); }
  407. break;
  408. case 22:
  409. /* Line 677 of lalr1.cc */
  410. #line 142 "scenesetup-parser.y"
  411. { uc.m_sstp.m_show_gizmo = (yysemantic_stack_[(2) - (2)].bval); }
  412. break;
  413. case 23:
  414. /* Line 677 of lalr1.cc */
  415. #line 143 "scenesetup-parser.y"
  416. { uc.m_sstp.m_show_lights = (yysemantic_stack_[(2) - (2)].bval); }
  417. break;
  418. case 24:
  419. /* Line 677 of lalr1.cc */
  420. #line 147 "scenesetup-parser.y"
  421. { uc.m_sstp.m_custom_cmd.Push((yysemantic_stack_[(3) - (2)].svval), (yysemantic_stack_[(3) - (3)].sval)); }
  422. break;
  423. case 25:
  424. /* Line 677 of lalr1.cc */
  425. #line 153 "scenesetup-parser.y"
  426. { (yyval.fval) = (yysemantic_stack_[(1) - (1)].fval); }
  427. break;
  428. case 26:
  429. /* Line 677 of lalr1.cc */
  430. #line 154 "scenesetup-parser.y"
  431. { (yyval.fval) = -(yysemantic_stack_[(2) - (2)].fval); }
  432. break;
  433. case 27:
  434. /* Line 677 of lalr1.cc */
  435. #line 155 "scenesetup-parser.y"
  436. { (yyval.fval) = (float)(yysemantic_stack_[(1) - (1)].ival); }
  437. break;
  438. case 28:
  439. /* Line 677 of lalr1.cc */
  440. #line 156 "scenesetup-parser.y"
  441. { (yyval.fval) = -(float)(yysemantic_stack_[(2) - (2)].ival); }
  442. break;
  443. case 29:
  444. /* Line 677 of lalr1.cc */
  445. #line 160 "scenesetup-parser.y"
  446. { (yyval.ival) = (yysemantic_stack_[(1) - (1)].ival); }
  447. break;
  448. case 30:
  449. /* Line 677 of lalr1.cc */
  450. #line 161 "scenesetup-parser.y"
  451. { (yyval.ival) = -(yysemantic_stack_[(2) - (2)].ival); }
  452. break;
  453. case 31:
  454. /* Line 677 of lalr1.cc */
  455. #line 162 "scenesetup-parser.y"
  456. { (yyval.ival) = (int)(yysemantic_stack_[(1) - (1)].fval); }
  457. break;
  458. case 32:
  459. /* Line 677 of lalr1.cc */
  460. #line 163 "scenesetup-parser.y"
  461. { (yyval.ival) = -(int)(yysemantic_stack_[(2) - (2)].fval); }
  462. break;
  463. case 33:
  464. /* Line 677 of lalr1.cc */
  465. #line 168 "scenesetup-parser.y"
  466. { (yyval.vval)[0] = (yysemantic_stack_[(3) - (2)].fval); (yyval.vval)[1] = (yysemantic_stack_[(3) - (2)].fval); (yyval.vval)[2] = (yysemantic_stack_[(3) - (2)].fval); }
  467. break;
  468. case 34:
  469. /* Line 677 of lalr1.cc */
  470. #line 169 "scenesetup-parser.y"
  471. { (yyval.vval)[0] = (yysemantic_stack_[(5) - (2)].fval); (yyval.vval)[1] = (yysemantic_stack_[(5) - (3)].fval); (yyval.vval)[2] = (yysemantic_stack_[(5) - (4)].fval); }
  472. break;
  473. case 35:
  474. /* Line 677 of lalr1.cc */
  475. #line 178 "scenesetup-parser.y"
  476. { (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); }
  477. break;
  478. case 36:
  479. /* Line 677 of lalr1.cc */
  480. #line 179 "scenesetup-parser.y"
  481. { (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); }
  482. break;
  483. case 37:
  484. /* Line 677 of lalr1.cc */
  485. #line 184 "scenesetup-parser.y"
  486. { (yyval.bval) = (yysemantic_stack_[(1) - (1)].bval); }
  487. break;
  488. case 38:
  489. /* Line 677 of lalr1.cc */
  490. #line 185 "scenesetup-parser.y"
  491. { (yyval.bval) = !!(yysemantic_stack_[(1) - (1)].ival); }
  492. break;
  493. case 39:
  494. /* Line 677 of lalr1.cc */
  495. #line 186 "scenesetup-parser.y"
  496. { (yyval.bval) = !!(yysemantic_stack_[(1) - (1)].fval); }
  497. break;
  498. case 40:
  499. /* Line 677 of lalr1.cc */
  500. #line 190 "scenesetup-parser.y"
  501. { (yyval.svval) = (yysemantic_stack_[(1) - (1)].svval); }
  502. break;
  503. case 41:
  504. /* Line 677 of lalr1.cc */
  505. #line 194 "scenesetup-parser.y"
  506. { String t = (yysemantic_stack_[(1) - (1)].sval);
  507. t.Replace('"', ' ', true);
  508. free((yysemantic_stack_[(1) - (1)].sval));
  509. (yyval.sval) = strdup((const char *)t.C()); }
  510. break;
  511. case 42:
  512. /* Line 677 of lalr1.cc */
  513. #line 198 "scenesetup-parser.y"
  514. { String t = (yysemantic_stack_[(2) - (1)].sval);
  515. t += (yysemantic_stack_[(2) - (2)].sval);
  516. t.Replace('"', ' ', true);
  517. free((yysemantic_stack_[(2) - (1)].sval));
  518. free((yysemantic_stack_[(2) - (2)].sval));
  519. (yyval.sval) = strdup((const char *)t.C()); }
  520. break;
  521. /* Line 677 of lalr1.cc */
  522. #line 677 "generated/scenesetup-parser.cpp"
  523. default:
  524. break;
  525. }
  526. YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc);
  527. yypop_ (yylen);
  528. yylen = 0;
  529. YY_STACK_PRINT ();
  530. yysemantic_stack_.push (yyval);
  531. yylocation_stack_.push (yyloc);
  532. /* Shift the result of the reduction. */
  533. yyn = yyr1_[yyn];
  534. yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0];
  535. if (0 <= yystate && yystate <= yylast_
  536. && yycheck_[yystate] == yystate_stack_[0])
  537. yystate = yytable_[yystate];
  538. else
  539. yystate = yydefgoto_[yyn - yyntokens_];
  540. goto yynewstate;
  541. /*------------------------------------.
  542. | yyerrlab -- here on detecting error |
  543. `------------------------------------*/
  544. yyerrlab:
  545. /* If not already recovering from an error, report this error. */
  546. if (!yyerrstatus_)
  547. {
  548. ++yynerrs_;
  549. error (yylloc, yysyntax_error_ (yystate, yytoken));
  550. }
  551. yyerror_range[0] = yylloc;
  552. if (yyerrstatus_ == 3)
  553. {
  554. /* If just tried and failed to reuse lookahead token after an
  555. error, discard it. */
  556. if (yychar <= yyeof_)
  557. {
  558. /* Return failure if at end of input. */
  559. if (yychar == yyeof_)
  560. YYABORT;
  561. }
  562. else
  563. {
  564. yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc);
  565. yychar = yyempty_;
  566. }
  567. }
  568. /* Else will try to reuse lookahead token after shifting the error
  569. token. */
  570. goto yyerrlab1;
  571. /*---------------------------------------------------.
  572. | yyerrorlab -- error raised explicitly by YYERROR. |
  573. `---------------------------------------------------*/
  574. yyerrorlab:
  575. /* Pacify compilers like GCC when the user code never invokes
  576. YYERROR and the label yyerrorlab therefore never appears in user
  577. code. */
  578. if (false)
  579. goto yyerrorlab;
  580. yyerror_range[0] = yylocation_stack_[yylen - 1];
  581. /* Do not reclaim the symbols of the rule which action triggered
  582. this YYERROR. */
  583. yypop_ (yylen);
  584. yylen = 0;
  585. yystate = yystate_stack_[0];
  586. goto yyerrlab1;
  587. /*-------------------------------------------------------------.
  588. | yyerrlab1 -- common code for both syntax error and YYERROR. |
  589. `-------------------------------------------------------------*/
  590. yyerrlab1:
  591. yyerrstatus_ = 3; /* Each real token shifted decrements this. */
  592. for (;;)
  593. {
  594. yyn = yypact_[yystate];
  595. if (yyn != yypact_ninf_)
  596. {
  597. yyn += yyterror_;
  598. if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
  599. {
  600. yyn = yytable_[yyn];
  601. if (0 < yyn)
  602. break;
  603. }
  604. }
  605. /* Pop the current state because it cannot handle the error token. */
  606. if (yystate_stack_.height () == 1)
  607. YYABORT;
  608. yyerror_range[0] = yylocation_stack_[0];
  609. yydestruct_ ("Error: popping",
  610. yystos_[yystate],
  611. &yysemantic_stack_[0], &yylocation_stack_[0]);
  612. yypop_ ();
  613. yystate = yystate_stack_[0];
  614. YY_STACK_PRINT ();
  615. }
  616. yyerror_range[1] = yylloc;
  617. // Using YYLLOC is tempting, but would change the location of
  618. // the lookahead. YYLOC is available though.
  619. YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
  620. yysemantic_stack_.push (yylval);
  621. yylocation_stack_.push (yyloc);
  622. /* Shift the error token. */
  623. YY_SYMBOL_PRINT ("Shifting", yystos_[yyn],
  624. &yysemantic_stack_[0], &yylocation_stack_[0]);
  625. yystate = yyn;
  626. goto yynewstate;
  627. /* Accept. */
  628. yyacceptlab:
  629. yyresult = 0;
  630. goto yyreturn;
  631. /* Abort. */
  632. yyabortlab:
  633. yyresult = 1;
  634. goto yyreturn;
  635. yyreturn:
  636. if (yychar != yyempty_)
  637. yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc);
  638. /* Do not reclaim the symbols of the rule which action triggered
  639. this YYABORT or YYACCEPT. */
  640. yypop_ (yylen);
  641. while (yystate_stack_.height () != 1)
  642. {
  643. yydestruct_ ("Cleanup: popping",
  644. yystos_[yystate_stack_[0]],
  645. &yysemantic_stack_[0],
  646. &yylocation_stack_[0]);
  647. yypop_ ();
  648. }
  649. return yyresult;
  650. }
  651. // Generate an error message.
  652. std::string
  653. SceneSetupParser::yysyntax_error_ (int yystate, int tok)
  654. {
  655. std::string res;
  656. YYUSE (yystate);
  657. #if YYERROR_VERBOSE
  658. int yyn = yypact_[yystate];
  659. if (yypact_ninf_ < yyn && yyn <= yylast_)
  660. {
  661. /* Start YYX at -YYN if negative to avoid negative indexes in
  662. YYCHECK. */
  663. int yyxbegin = yyn < 0 ? -yyn : 0;
  664. /* Stay within bounds of both yycheck and yytname. */
  665. int yychecklim = yylast_ - yyn + 1;
  666. int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
  667. int count = 0;
  668. for (int x = yyxbegin; x < yyxend; ++x)
  669. if (yycheck_[x + yyn] == x && x != yyterror_)
  670. ++count;
  671. // FIXME: This method of building the message is not compatible
  672. // with internationalization. It should work like yacc.c does it.
  673. // That is, first build a string that looks like this:
  674. // "syntax error, unexpected %s or %s or %s"
  675. // Then, invoke YY_ on this string.
  676. // Finally, use the string as a format to output
  677. // yytname_[tok], etc.
  678. // Until this gets fixed, this message appears in English only.
  679. res = "syntax error, unexpected ";
  680. res += yytnamerr_ (yytname_[tok]);
  681. if (count < 5)
  682. {
  683. count = 0;
  684. for (int x = yyxbegin; x < yyxend; ++x)
  685. if (yycheck_[x + yyn] == x && x != yyterror_)
  686. {
  687. res += (!count++) ? ", expecting " : " or ";
  688. res += yytnamerr_ (yytname_[x]);
  689. }
  690. }
  691. }
  692. else
  693. #endif
  694. res = YY_("syntax error");
  695. return res;
  696. }
  697. /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
  698. STATE-NUM. */
  699. const signed char SceneSetupParser::yypact_ninf_ = -21;
  700. const signed char
  701. SceneSetupParser::yypact_[] =
  702. {
  703. 38, 6, -18, -18, -6, -2, 37, 37, -13, 7,
  704. 21, 38, 38, -21, -21, -21, -21, -21, -21, -21,
  705. -21, 17, -21, -21, 19, -21, -21, -21, 19, -21,
  706. -21, -21, -21, -21, -21, -21, -21, 8, -21, -21,
  707. -21, -21, -21, -21, 17, -21, -21, -8, -4, 18,
  708. 8, -21, -21, -21, -21, 19, -21, 19, -18, -21,
  709. 13, 19, -21, -21, 31, -21
  710. };
  711. /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
  712. doesn't specify something else to do. Zero means the default is an
  713. error. */
  714. const unsigned char
  715. SceneSetupParser::yydefact_[] =
  716. {
  717. 0, 12, 0, 0, 0, 0, 0, 0, 0, 0,
  718. 0, 3, 5, 6, 8, 9, 10, 11, 25, 27,
  719. 40, 0, 13, 14, 0, 15, 16, 18, 0, 17,
  720. 21, 19, 39, 38, 37, 22, 23, 0, 1, 2,
  721. 4, 7, 25, 27, 0, 26, 28, 0, 0, 0,
  722. 41, 24, 26, 28, 33, 0, 35, 0, 0, 42,
  723. 0, 0, 20, 34, 0, 36
  724. };
  725. /* YYPGOTO[NTERM-NUM]. */
  726. const signed char
  727. SceneSetupParser::yypgoto_[] =
  728. {
  729. -21, -21, 28, -21, -21, 41, -21, -21, -21, -21,
  730. -21, -20, -15, -3, 35, 49, 50, 9
  731. };
  732. /* YYDEFGOTO[NTERM-NUM]. */
  733. const signed char
  734. SceneSetupParser::yydefgoto_[] =
  735. {
  736. -1, 9, 10, 11, 12, 13, 14, 15, 16, 49,
  737. 17, 22, 46, 25, 29, 35, 23, 51
  738. };
  739. /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
  740. positive, shift that token. If negative, reduce the rule which
  741. number is the opposite. If zero, do what YYDEFACT says. */
  742. const signed char SceneSetupParser::yytable_ninf_ = -1;
  743. const unsigned char
  744. SceneSetupParser::yytable_[] =
  745. {
  746. 26, 45, 24, 20, 47, 18, 19, 38, 48, 18,
  747. 19, 21, 27, 54, 28, 21, 30, 56, 28, 18,
  748. 19, 39, 20, 50, 52, 21, 58, 55, 57, 53,
  749. 42, 43, 18, 19, 63, 60, 44, 61, 21, 40,
  750. 31, 64, 1, 2, 3, 4, 5, 6, 7, 8,
  751. 32, 33, 65, 41, 34, 62, 36, 0, 37, 59
  752. };
  753. /* YYCHECK. */
  754. const signed char
  755. SceneSetupParser::yycheck_[] =
  756. {
  757. 3, 21, 20, 16, 24, 13, 14, 0, 28, 13,
  758. 14, 19, 18, 21, 20, 19, 18, 21, 20, 13,
  759. 14, 0, 16, 15, 44, 19, 8, 47, 48, 44,
  760. 13, 14, 13, 14, 21, 55, 19, 57, 19, 11,
  761. 5, 61, 4, 5, 6, 7, 8, 9, 10, 11,
  762. 13, 14, 21, 12, 17, 58, 7, -1, 8, 50
  763. };
  764. /* STOS_[STATE-NUM] -- The (internal number of the) accessing
  765. symbol of state STATE-NUM. */
  766. const unsigned char
  767. SceneSetupParser::yystos_[] =
  768. {
  769. 0, 4, 5, 6, 7, 8, 9, 10, 11, 23,
  770. 24, 25, 26, 27, 28, 29, 30, 32, 13, 14,
  771. 16, 19, 33, 38, 20, 35, 35, 18, 20, 36,
  772. 18, 36, 13, 14, 17, 37, 37, 38, 0, 0,
  773. 24, 27, 13, 14, 19, 33, 34, 33, 33, 31,
  774. 15, 39, 33, 34, 21, 33, 21, 33, 8, 39,
  775. 33, 33, 35, 21, 33, 21
  776. };
  777. #if YYDEBUG
  778. /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
  779. to YYLEX-NUM. */
  780. const unsigned short int
  781. SceneSetupParser::yytoken_number_[] =
  782. {
  783. 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
  784. 265, 266, 267, 268, 269, 270, 271, 272, 273, 45,
  785. 40, 41
  786. };
  787. #endif
  788. /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
  789. const unsigned char
  790. SceneSetupParser::yyr1_[] =
  791. {
  792. 0, 22, 23, 24, 24, 25, 26, 26, 27, 27,
  793. 27, 27, 28, 28, 28, 29, 29, 29, 29, 31,
  794. 30, 30, 30, 30, 32, 33, 33, 33, 33, 34,
  795. 34, 34, 34, 35, 35, 36, 36, 37, 37, 37,
  796. 38, 39, 39
  797. };
  798. /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
  799. const unsigned char
  800. SceneSetupParser::yyr2_[] =
  801. {
  802. 0, 2, 2, 1, 2, 1, 1, 2, 1, 1,
  803. 1, 1, 1, 2, 2, 2, 2, 2, 2, 0,
  804. 5, 2, 2, 2, 3, 1, 2, 1, 2, 1,
  805. 2, 1, 2, 3, 5, 3, 6, 1, 1, 1,
  806. 1, 1, 2
  807. };
  808. #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
  809. /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
  810. First, the terminals, then, starting at \a yyntokens_, nonterminals. */
  811. const char*
  812. const SceneSetupParser::yytname_[] =
  813. {
  814. "T_END", "error", "$undefined", "T_COLOR", "T_ADDLIGHT",
  815. "T_OBJPOSITION", "T_OBJLOOKAT", "T_OBJCOLOR", "T_CLEARCOLOR",
  816. "T_SHOWGIZMO", "T_SHOWLIGHT", "T_CUSTOMCMD", "T_ERROR", "F_NUMBER",
  817. "I_NUMBER", "STRING", "STRING_VAR", "BOOLEAN", "COLOR", "'-'", "'('",
  818. "')'", "$accept", "sstp_description", "sstp_expression_list",
  819. "sstp_expression", "sstp_command_list", "sstp_command", "light_command",
  820. "setup_command", "scene_command", "$@1", "custom_command", "fv", "iv",
  821. "v3", "v4", "bv", "svv", "sv", 0
  822. };
  823. #endif
  824. #if YYDEBUG
  825. /* YYRHS -- A `-1'-separated list of the rules' RHS. */
  826. const SceneSetupParser::rhs_number_type
  827. SceneSetupParser::yyrhs_[] =
  828. {
  829. 23, 0, -1, 24, 0, -1, 25, -1, 25, 24,
  830. -1, 26, -1, 27, -1, 26, 27, -1, 28, -1,
  831. 29, -1, 30, -1, 32, -1, 4, -1, 4, 33,
  832. -1, 4, 38, -1, 5, 35, -1, 6, 35, -1,
  833. 7, 36, -1, 7, 18, -1, -1, 8, 36, 31,
  834. 8, 35, -1, 8, 18, -1, 9, 37, -1, 10,
  835. 37, -1, 11, 38, 39, -1, 13, -1, 19, 33,
  836. -1, 14, -1, 19, 34, -1, 14, -1, 19, 34,
  837. -1, 13, -1, 19, 33, -1, 20, 33, 21, -1,
  838. 20, 33, 33, 33, 21, -1, 20, 33, 21, -1,
  839. 20, 33, 33, 33, 33, 21, -1, 17, -1, 14,
  840. -1, 13, -1, 16, -1, 15, -1, 15, 39, -1
  841. };
  842. /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
  843. YYRHS. */
  844. const unsigned char
  845. SceneSetupParser::yyprhs_[] =
  846. {
  847. 0, 0, 3, 6, 8, 11, 13, 15, 18, 20,
  848. 22, 24, 26, 28, 31, 34, 37, 40, 43, 46,
  849. 47, 53, 56, 59, 62, 66, 68, 71, 73, 76,
  850. 78, 81, 83, 86, 90, 96, 100, 107, 109, 111,
  851. 113, 115, 117
  852. };
  853. /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
  854. const unsigned char
  855. SceneSetupParser::yyrline_[] =
  856. {
  857. 0, 91, 91, 95, 96, 100, 104, 105, 109, 110,
  858. 111, 112, 116, 117, 119, 124, 126, 128, 130, 138,
  859. 138, 140, 142, 143, 147, 153, 154, 155, 156, 160,
  860. 161, 162, 163, 168, 169, 178, 179, 184, 185, 186,
  861. 190, 194, 198
  862. };
  863. // Print the state stack on the debug stream.
  864. void
  865. SceneSetupParser::yystack_print_ ()
  866. {
  867. *yycdebug_ << "Stack now";
  868. for (state_stack_type::const_iterator i = yystate_stack_.begin ();
  869. i != yystate_stack_.end (); ++i)
  870. *yycdebug_ << ' ' << *i;
  871. *yycdebug_ << std::endl;
  872. }
  873. // Report on the debug stream that the rule \a yyrule is going to be reduced.
  874. void
  875. SceneSetupParser::yy_reduce_print_ (int yyrule)
  876. {
  877. unsigned int yylno = yyrline_[yyrule];
  878. int yynrhs = yyr2_[yyrule];
  879. /* Print the symbols being reduced, and their result. */
  880. *yycdebug_ << "Reducing stack by rule " << yyrule - 1
  881. << " (line " << yylno << "):" << std::endl;
  882. /* The symbols being reduced. */
  883. for (int yyi = 0; yyi < yynrhs; yyi++)
  884. YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
  885. yyrhs_[yyprhs_[yyrule] + yyi],
  886. &(yysemantic_stack_[(yynrhs) - (yyi + 1)]),
  887. &(yylocation_stack_[(yynrhs) - (yyi + 1)]));
  888. }
  889. #endif // YYDEBUG
  890. /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
  891. SceneSetupParser::token_number_type
  892. SceneSetupParser::yytranslate_ (int t)
  893. {
  894. static
  895. const token_number_type
  896. translate_table[] =
  897. {
  898. 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  899. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  900. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  901. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  902. 20, 21, 2, 2, 2, 19, 2, 2, 2, 2,
  903. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  904. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  905. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  906. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  907. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  908. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  909. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  910. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  911. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  912. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  913. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  914. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  915. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  916. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  917. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  918. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  919. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  920. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  921. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  922. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  923. 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
  924. 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  925. 15, 16, 17, 18
  926. };
  927. if ((unsigned int) t <= yyuser_token_number_max_)
  928. return translate_table[t];
  929. else
  930. return yyundef_token_;
  931. }
  932. const int SceneSetupParser::yyeof_ = 0;
  933. const int SceneSetupParser::yylast_ = 59;
  934. const int SceneSetupParser::yynnts_ = 18;
  935. const int SceneSetupParser::yyempty_ = -2;
  936. const int SceneSetupParser::yyfinal_ = 38;
  937. const int SceneSetupParser::yyterror_ = 1;
  938. const int SceneSetupParser::yyerrcode_ = 256;
  939. const int SceneSetupParser::yyntokens_ = 22;
  940. const unsigned int SceneSetupParser::yyuser_token_number_max_ = 273;
  941. const SceneSetupParser::token_number_type SceneSetupParser::yyundef_token_ = 2;
  942. } // lol
  943. /* Line 1053 of lalr1.cc */
  944. #line 1148 "generated/scenesetup-parser.cpp"
  945. /* Line 1055 of lalr1.cc */
  946. #line 206 "scenesetup-parser.y"
  947. void lol::SceneSetupParser::error(const SceneSetupParser::location_type& l,
  948. const std::string& m)
  949. {
  950. uc.Error(l, m);
  951. }