Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

scenesetup-parser.cpp 34 KiB

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