You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

scenesetup-parser.cpp 32 KiB

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