diff --git a/src/easymesh/easymesh-parser.y b/src/easymesh/easymesh-parser.y index 6ce6bb0a..2f67c9ba 100644 --- a/src/easymesh/easymesh-parser.y +++ b/src/easymesh/easymesh-parser.y @@ -20,6 +20,10 @@ #include +/* HACK: workaround for Bison who insists on using exceptions */ +#define try if (true) +#define catch(...) if (false) +#define throw (void)0 %} %require "2.3" diff --git a/src/generated/easymesh-parser.cpp b/src/generated/easymesh-parser.cpp index dffc67b1..b40e613f 100644 --- a/src/generated/easymesh-parser.cpp +++ b/src/generated/easymesh-parser.cpp @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.5. */ +/* A Bison parser, made by GNU Bison 2.7.12-4996. */ /* Skeleton implementation for Bison LALR(1) parsers in C++ - Copyright (C) 2002-2011 Free Software Foundation, Inc. + Copyright (C) 2002-2013 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,8 +34,7 @@ #define yylex lollex /* First part of user declarations. */ - -/* Line 293 of lalr1.cc */ +/* Line 283 of lalr1.cc */ #line 1 "easymesh/easymesh-parser.y" // @@ -59,28 +58,38 @@ #include +/* HACK: workaround for Bison who insists on using exceptions */ +#define try if (true) +#define catch(...) if (false) +#define throw (void)0 - -/* Line 293 of lalr1.cc */ -#line 66 "generated/easymesh-parser.cpp" +/* Line 283 of lalr1.cc */ +#line 68 "generated/easymesh-parser.cpp" #include "easymesh-parser.h" /* User implementation prologue. */ - -/* Line 299 of lalr1.cc */ -#line 66 "easymesh/easymesh-parser.y" +/* Line 289 of lalr1.cc */ +#line 70 "easymesh/easymesh-parser.y" #include "easymesh/easymesh-compiler.h" #undef yylex #define yylex mc.m_lexer->lex - -/* Line 299 of lalr1.cc */ +/* Line 289 of lalr1.cc */ #line 83 "generated/easymesh-parser.cpp" + +# ifndef YY_NULL +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULL nullptr +# else +# define YY_NULL 0 +# endif +# endif + #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS @@ -93,25 +102,26 @@ # endif #endif +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. If N is 0, then set CURRENT to the empty location which ends the previous symbol: RHS[0] (always defined). */ -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (N) \ - { \ - (Current).begin = YYRHSLOC (Rhs, 1).begin; \ - (Current).end = YYRHSLOC (Rhs, N).end; \ - } \ - else \ - { \ - (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \ - } \ - while (false) -#endif +# ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (N) \ + { \ + (Current).begin = YYRHSLOC (Rhs, 1).begin; \ + (Current).end = YYRHSLOC (Rhs, N).end; \ + } \ + else \ + { \ + (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \ + } \ + while (/*CONSTCOND*/ false) +# endif + /* Suppress unused-variable warnings by "using" E. */ #define YYUSE(e) ((void) (e)) @@ -147,9 +157,9 @@ do { \ #else /* !YYDEBUG */ # define YYCDEBUG if (false) std::cerr -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) -# define YY_REDUCE_PRINT(Rule) -# define YY_STACK_PRINT() +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) YYUSE(Type) +# define YY_REDUCE_PRINT(Rule) static_cast(0) +# define YY_STACK_PRINT() static_cast(0) #endif /* !YYDEBUG */ @@ -163,9 +173,8 @@ do { \ namespace lol { - -/* Line 382 of lalr1.cc */ -#line 169 "generated/easymesh-parser.cpp" +/* Line 357 of lalr1.cc */ +#line 178 "generated/easymesh-parser.cpp" /* Return YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is @@ -231,11 +240,10 @@ namespace lol { { YYUSE (yylocationp); YYUSE (yyvaluep); - switch (yytype) - { - default: - break; - } + std::ostream& yyo = debug_stream (); + std::ostream& yyoutput = yyo; + YYUSE (yyoutput); + YYUSE (yytype); } @@ -259,14 +267,10 @@ namespace lol { YYUSE (yymsg); YYUSE (yyvaluep); - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + if (yymsg) + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - switch (yytype) - { - - default: - break; - } + YYUSE (yytype); } void @@ -323,17 +327,18 @@ namespace lol { int yychar = yyempty_; int yytoken = 0; - /* State. */ + // State. int yyn; int yylen = 0; int yystate = 0; - /* Error handling. */ + // Error handling. int yynerrs_ = 0; int yyerrstatus_ = 0; /// Semantic value of the lookahead. - semantic_type yylval; + static semantic_type yyval_default; + semantic_type yylval = yyval_default; /// Location of the lookahead. location_type yylloc; /// The locations where the error started and ended. @@ -346,6 +351,10 @@ namespace lol { int yyresult; + // FIXME: This shoud be completely indented. It is not yet to + // avoid gratuitous conflicts when merging into the master branch. + try + { YYCDEBUG << "Starting parse" << std::endl; @@ -353,9 +362,9 @@ namespace lol { yynewstate, since the latter expects the semantical and the location values to have been already stored, initialize these stacks with a primary value. */ - yystate_stack_ = state_stack_type (0); - yysemantic_stack_ = semantic_stack_type (0); - yylocation_stack_ = location_stack_type (0); + yystate_stack_.clear (); + yysemantic_stack_.clear (); + yylocation_stack_.clear (); yysemantic_stack_.push (yylval); yylocation_stack_.push (yylloc); @@ -381,11 +390,10 @@ namespace lol { /* Read a lookahead token. */ if (yychar == yyempty_) { - YYCDEBUG << "Reading a token: "; - yychar = yylex (&yylval, &yylloc); + YYCDEBUG << "Reading a token: "; + yychar = yylex (&yylval, &yylloc); } - /* Convert token to internal form. */ if (yychar <= yyeof_) { @@ -456,594 +464,517 @@ namespace lol { else yyval = yysemantic_stack_[0]; + // Compute the default @$. { slice slice (yylocation_stack_, yylen); YYLLOC_DEFAULT (yyloc, slice, yylen); } + + // Perform the reduction. YY_REDUCE_PRINT (yyn); switch (yyn) { - case 7: - -/* Line 690 of lalr1.cc */ -#line 90 "easymesh/easymesh-parser.y" + case 7: +/* Line 664 of lalr1.cc */ +#line 94 "easymesh/easymesh-parser.y" { mc.m_mesh.OpenBrace(); } break; case 8: - -/* Line 690 of lalr1.cc */ -#line 94 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 98 "easymesh/easymesh-parser.y" { mc.m_mesh.CloseBrace(); } break; case 14: - -/* Line 690 of lalr1.cc */ -#line 109 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 113 "easymesh/easymesh-parser.y" { mc.m_mesh.SetCurColor(vec4((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3)); } break; case 15: - -/* Line 690 of lalr1.cc */ -#line 110 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 114 "easymesh/easymesh-parser.y" { uint32_t x = (yysemantic_stack_[(2) - (2)].u32val); vec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff); mc.m_mesh.SetCurColor(vec4(v) * (1.f / 255)); } break; case 16: - -/* Line 690 of lalr1.cc */ -#line 113 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 117 "easymesh/easymesh-parser.y" { mc.m_mesh.SetCurColor2(vec4((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3)); } break; case 17: - -/* Line 690 of lalr1.cc */ -#line 114 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 118 "easymesh/easymesh-parser.y" { uint32_t x = (yysemantic_stack_[(2) - (2)].u32val); vec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff); mc.m_mesh.SetCurColor2(vec4(v) * (1.f / 255)); } break; case 18: - -/* Line 690 of lalr1.cc */ -#line 120 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 124 "easymesh/easymesh-parser.y" { mc.m_mesh.Chamfer((yysemantic_stack_[(2) - (2)].args).f0); } break; case 19: - -/* Line 690 of lalr1.cc */ -#line 121 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 125 "easymesh/easymesh-parser.y" { mc.m_mesh.Translate(vec3((yysemantic_stack_[(2) - (2)].args).f0, 0, 0)); } break; case 20: - -/* Line 690 of lalr1.cc */ -#line 122 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 126 "easymesh/easymesh-parser.y" { mc.m_mesh.Translate(vec3(0, (yysemantic_stack_[(2) - (2)].args).f0, 0)); } break; case 21: - -/* Line 690 of lalr1.cc */ -#line 123 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 127 "easymesh/easymesh-parser.y" { mc.m_mesh.Translate(vec3(0, 0, (yysemantic_stack_[(2) - (2)].args).f0)); } break; case 22: - -/* Line 690 of lalr1.cc */ -#line 124 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 128 "easymesh/easymesh-parser.y" { mc.m_mesh.Translate(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2)); } break; case 23: - -/* Line 690 of lalr1.cc */ -#line 125 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 129 "easymesh/easymesh-parser.y" { mc.m_mesh.RotateX((yysemantic_stack_[(2) - (2)].args).f0); } break; case 24: - -/* Line 690 of lalr1.cc */ -#line 126 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 130 "easymesh/easymesh-parser.y" { mc.m_mesh.RotateY((yysemantic_stack_[(2) - (2)].args).f0); } break; case 25: - -/* Line 690 of lalr1.cc */ -#line 127 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 131 "easymesh/easymesh-parser.y" { mc.m_mesh.RotateZ((yysemantic_stack_[(2) - (2)].args).f0); } break; case 26: - -/* Line 690 of lalr1.cc */ -#line 128 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 132 "easymesh/easymesh-parser.y" { mc.m_mesh.TaperX((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } break; case 27: - -/* Line 690 of lalr1.cc */ -#line 129 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 133 "easymesh/easymesh-parser.y" { mc.m_mesh.TaperX((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3); } break; case 28: - -/* Line 690 of lalr1.cc */ -#line 130 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 134 "easymesh/easymesh-parser.y" { mc.m_mesh.TaperY((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } break; case 29: - -/* Line 690 of lalr1.cc */ -#line 131 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 135 "easymesh/easymesh-parser.y" { mc.m_mesh.TaperY((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3); } break; case 30: - -/* Line 690 of lalr1.cc */ -#line 132 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 136 "easymesh/easymesh-parser.y" { mc.m_mesh.TaperZ((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } break; case 31: - -/* Line 690 of lalr1.cc */ -#line 133 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 137 "easymesh/easymesh-parser.y" { mc.m_mesh.TaperZ((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3); } break; case 32: - -/* Line 690 of lalr1.cc */ -#line 134 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 138 "easymesh/easymesh-parser.y" { mc.m_mesh.TwistX((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1); } break; case 33: - -/* Line 690 of lalr1.cc */ -#line 135 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 139 "easymesh/easymesh-parser.y" { mc.m_mesh.TwistY((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1); } break; case 34: - -/* Line 690 of lalr1.cc */ -#line 136 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 140 "easymesh/easymesh-parser.y" { mc.m_mesh.TwistZ((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1); } break; case 35: - -/* Line 690 of lalr1.cc */ -#line 137 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 141 "easymesh/easymesh-parser.y" { mc.m_mesh.ShearX((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } break; case 36: - -/* Line 690 of lalr1.cc */ -#line 138 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 142 "easymesh/easymesh-parser.y" { mc.m_mesh.ShearX((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3); } break; case 37: - -/* Line 690 of lalr1.cc */ -#line 139 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 143 "easymesh/easymesh-parser.y" { mc.m_mesh.ShearY((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } break; case 38: - -/* Line 690 of lalr1.cc */ -#line 140 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 144 "easymesh/easymesh-parser.y" { mc.m_mesh.ShearY((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3); } break; case 39: - -/* Line 690 of lalr1.cc */ -#line 141 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 145 "easymesh/easymesh-parser.y" { mc.m_mesh.ShearZ((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } break; case 40: - -/* Line 690 of lalr1.cc */ -#line 142 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 146 "easymesh/easymesh-parser.y" { mc.m_mesh.ShearZ((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3); } break; case 41: - -/* Line 690 of lalr1.cc */ -#line 143 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 147 "easymesh/easymesh-parser.y" { mc.m_mesh.StretchX((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } break; case 42: - -/* Line 690 of lalr1.cc */ -#line 144 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 148 "easymesh/easymesh-parser.y" { mc.m_mesh.StretchY((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } break; case 43: - -/* Line 690 of lalr1.cc */ -#line 145 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 149 "easymesh/easymesh-parser.y" { mc.m_mesh.StretchZ((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } break; case 44: - -/* Line 690 of lalr1.cc */ -#line 146 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 150 "easymesh/easymesh-parser.y" { mc.m_mesh.BendXY((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1); } break; case 45: - -/* Line 690 of lalr1.cc */ -#line 147 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 151 "easymesh/easymesh-parser.y" { mc.m_mesh.BendXZ((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1); } break; case 46: - -/* Line 690 of lalr1.cc */ -#line 148 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 152 "easymesh/easymesh-parser.y" { mc.m_mesh.BendYX((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1); } break; case 47: - -/* Line 690 of lalr1.cc */ -#line 149 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 153 "easymesh/easymesh-parser.y" { mc.m_mesh.BendYZ((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1); } break; case 48: - -/* Line 690 of lalr1.cc */ -#line 150 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 154 "easymesh/easymesh-parser.y" { mc.m_mesh.BendZX((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1); } break; case 49: - -/* Line 690 of lalr1.cc */ -#line 151 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 155 "easymesh/easymesh-parser.y" { mc.m_mesh.BendZY((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1); } break; case 50: - -/* Line 690 of lalr1.cc */ -#line 152 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 156 "easymesh/easymesh-parser.y" { mc.m_mesh.Scale(vec3((yysemantic_stack_[(2) - (2)].args).f0, 1.0, 1.0)); } break; case 51: - -/* Line 690 of lalr1.cc */ -#line 153 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 157 "easymesh/easymesh-parser.y" { mc.m_mesh.Scale(vec3(1.0, (yysemantic_stack_[(2) - (2)].args).f0, 1.0)); } break; case 52: - -/* Line 690 of lalr1.cc */ -#line 154 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 158 "easymesh/easymesh-parser.y" { mc.m_mesh.Scale(vec3(1.0, 1.0, (yysemantic_stack_[(2) - (2)].args).f0)); } break; case 53: - -/* Line 690 of lalr1.cc */ -#line 155 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 159 "easymesh/easymesh-parser.y" { mc.m_mesh.Scale(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2)); } break; case 54: - -/* Line 690 of lalr1.cc */ -#line 156 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 160 "easymesh/easymesh-parser.y" { mc.m_mesh.MirrorX(); } break; case 55: - -/* Line 690 of lalr1.cc */ -#line 157 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 161 "easymesh/easymesh-parser.y" { mc.m_mesh.MirrorY(); } break; case 56: - -/* Line 690 of lalr1.cc */ -#line 158 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 162 "easymesh/easymesh-parser.y" { mc.m_mesh.MirrorZ(); } break; case 57: - -/* Line 690 of lalr1.cc */ -#line 159 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 163 "easymesh/easymesh-parser.y" { mc.m_mesh.RadialJitter((yysemantic_stack_[(2) - (2)].args).f0); } break; case 58: - -/* Line 690 of lalr1.cc */ -#line 160 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 164 "easymesh/easymesh-parser.y" { mc.m_mesh.SplitTriangles((yysemantic_stack_[(2) - (2)].args).f0); } break; case 59: - -/* Line 690 of lalr1.cc */ -#line 161 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 165 "easymesh/easymesh-parser.y" { mc.m_mesh.SmoothMesh((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } break; case 60: - -/* Line 690 of lalr1.cc */ -#line 162 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 166 "easymesh/easymesh-parser.y" { mc.m_mesh.ToggleScaleWinding(); } break; case 61: - -/* Line 690 of lalr1.cc */ -#line 163 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 167 "easymesh/easymesh-parser.y" { mc.m_mesh.CsgUnion(); } break; case 62: - -/* Line 690 of lalr1.cc */ -#line 164 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 168 "easymesh/easymesh-parser.y" { mc.m_mesh.CsgSubstract(); } break; case 63: - -/* Line 690 of lalr1.cc */ -#line 165 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 169 "easymesh/easymesh-parser.y" { mc.m_mesh.CsgSubstractLoss(); } break; case 64: - -/* Line 690 of lalr1.cc */ -#line 166 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 170 "easymesh/easymesh-parser.y" { mc.m_mesh.CsgAnd(); } break; case 65: - -/* Line 690 of lalr1.cc */ -#line 167 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 171 "easymesh/easymesh-parser.y" { mc.m_mesh.CsgXor(); } break; case 66: - -/* Line 690 of lalr1.cc */ -#line 171 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 175 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendCylinder((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3, (int)(yysemantic_stack_[(2) - (2)].args).f4, (int)(yysemantic_stack_[(2) - (2)].args).f5, 0); } break; case 67: - -/* Line 690 of lalr1.cc */ -#line 174 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 178 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendCylinder((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3, (int)(yysemantic_stack_[(2) - (2)].args).f4, (int)(yysemantic_stack_[(2) - (2)].args).f5, (int)(yysemantic_stack_[(2) - (2)].args).f6); } break; case 68: - -/* Line 690 of lalr1.cc */ -#line 177 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 181 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2)); } break; case 69: - -/* Line 690 of lalr1.cc */ -#line 178 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 182 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendSmoothChamfBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2), (yysemantic_stack_[(2) - (2)].args).f3); } break; case 70: - -/* Line 690 of lalr1.cc */ -#line 180 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 184 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendFlatChamfBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2), (yysemantic_stack_[(2) - (2)].args).f3); } break; case 71: - -/* Line 690 of lalr1.cc */ -#line 182 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 186 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendSphere((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1); } break; case 72: - -/* Line 690 of lalr1.cc */ -#line 183 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 187 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendCapsule((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } break; case 73: - -/* Line 690 of lalr1.cc */ -#line 184 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 188 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendTorus((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } break; case 74: - -/* Line 690 of lalr1.cc */ -#line 185 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 189 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendStar((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (int)(yysemantic_stack_[(2) - (2)].args).f3, (int)(yysemantic_stack_[(2) - (2)].args).f4); } break; case 75: - -/* Line 690 of lalr1.cc */ -#line 187 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 191 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendExpandedStar((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3); } break; case 76: - -/* Line 690 of lalr1.cc */ -#line 189 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 193 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendDisc((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (int)(yysemantic_stack_[(2) - (2)].args).f2); } break; case 77: - -/* Line 690 of lalr1.cc */ -#line 190 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 194 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendSimpleTriangle((yysemantic_stack_[(2) - (2)].args).f0, (int)(yysemantic_stack_[(2) - (2)].args).f1); } break; case 78: - -/* Line 690 of lalr1.cc */ -#line 191 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 195 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendSimpleQuad((yysemantic_stack_[(2) - (2)].args).f0, (int)(yysemantic_stack_[(2) - (2)].args).f1); } break; case 79: - -/* Line 690 of lalr1.cc */ -#line 192 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 196 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendCog((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3, (yysemantic_stack_[(2) - (2)].args).f4, (yysemantic_stack_[(2) - (2)].args).f5, (yysemantic_stack_[(2) - (2)].args).f6, (yysemantic_stack_[(2) - (2)].args).f7, (yysemantic_stack_[(2) - (2)].args).f8, (int)(yysemantic_stack_[(2) - (2)].args).f9); } break; case 80: - -/* Line 690 of lalr1.cc */ -#line 197 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 201 "easymesh/easymesh-parser.y" { (yyval.args).f0 = (yysemantic_stack_[(1) - (1)].fval); } break; case 81: - -/* Line 690 of lalr1.cc */ -#line 198 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 202 "easymesh/easymesh-parser.y" { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f1 = (yysemantic_stack_[(2) - (2)].fval); } break; case 82: - -/* Line 690 of lalr1.cc */ -#line 199 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 203 "easymesh/easymesh-parser.y" { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f2 = (yysemantic_stack_[(2) - (2)].fval); } break; case 83: - -/* Line 690 of lalr1.cc */ -#line 200 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 204 "easymesh/easymesh-parser.y" { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f3 = (yysemantic_stack_[(2) - (2)].fval); } break; case 84: - -/* Line 690 of lalr1.cc */ -#line 201 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 205 "easymesh/easymesh-parser.y" { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f4 = (yysemantic_stack_[(2) - (2)].fval); } break; case 85: - -/* Line 690 of lalr1.cc */ -#line 202 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 206 "easymesh/easymesh-parser.y" { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f5 = (yysemantic_stack_[(2) - (2)].fval); } break; case 86: - -/* Line 690 of lalr1.cc */ -#line 203 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 207 "easymesh/easymesh-parser.y" { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f6 = (yysemantic_stack_[(2) - (2)].fval); } break; case 87: - -/* Line 690 of lalr1.cc */ -#line 204 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 208 "easymesh/easymesh-parser.y" { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f7 = (yysemantic_stack_[(2) - (2)].fval); } break; case 88: - -/* Line 690 of lalr1.cc */ -#line 205 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 209 "easymesh/easymesh-parser.y" { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f8 = (yysemantic_stack_[(2) - (2)].fval); } break; case 89: - -/* Line 690 of lalr1.cc */ -#line 206 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 210 "easymesh/easymesh-parser.y" { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f9 = (yysemantic_stack_[(2) - (2)].fval); } break; case 90: - -/* Line 690 of lalr1.cc */ -#line 209 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 213 "easymesh/easymesh-parser.y" { (yyval.fval) = (yysemantic_stack_[(1) - (1)].fval); } break; case 91: - -/* Line 690 of lalr1.cc */ -#line 210 "easymesh/easymesh-parser.y" +/* Line 664 of lalr1.cc */ +#line 214 "easymesh/easymesh-parser.y" { (yyval.fval) = -(yysemantic_stack_[(2) - (2)].fval); } break; - -/* Line 690 of lalr1.cc */ -#line 1044 "generated/easymesh-parser.cpp" - default: - break; +/* Line 664 of lalr1.cc */ +#line 974 "generated/easymesh-parser.cpp" + default: + break; } + /* User semantic actions sometimes alter yychar, and that requires that yytoken be updated with the new translation. We take the approach of translating immediately before every use of yytoken. @@ -1094,20 +1025,19 @@ namespace lol { yyerror_range[1] = yylloc; if (yyerrstatus_ == 3) { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - if (yychar <= yyeof_) - { - /* Return failure if at end of input. */ - if (yychar == yyeof_) - YYABORT; - } - else - { - yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc); - yychar = yyempty_; - } + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + if (yychar <= yyeof_) + { + /* Return failure if at end of input. */ + if (yychar == yyeof_) + YYABORT; + } + else + { + yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc); + yychar = yyempty_; + } } /* Else will try to reuse lookahead token after shifting the error @@ -1156,7 +1086,7 @@ namespace lol { /* Pop the current state because it cannot handle the error token. */ if (yystate_stack_.height () == 1) - YYABORT; + YYABORT; yyerror_range[1] = yylocation_stack_[0]; yydestruct_ ("Error: popping", @@ -1204,16 +1134,42 @@ namespace lol { /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ yypop_ (yylen); - while (yystate_stack_.height () != 1) + while (1 < yystate_stack_.height ()) { - yydestruct_ ("Cleanup: popping", - yystos_[yystate_stack_[0]], - &yysemantic_stack_[0], - &yylocation_stack_[0]); - yypop_ (); + yydestruct_ ("Cleanup: popping", + yystos_[yystate_stack_[0]], + &yysemantic_stack_[0], + &yylocation_stack_[0]); + yypop_ (); } return yyresult; + } + catch (...) + { + YYCDEBUG << "Exception caught: cleaning lookahead and stack" + << std::endl; + // Do not try to display the values of the reclaimed symbols, + // as their printer might throw an exception. + if (yychar != yyempty_) + { + /* Make sure we have latest lookahead translation. See + comments at user semantic actions for why this is + necessary. */ + yytoken = yytranslate_ (yychar); + yydestruct_ (YY_NULL, yytoken, &yylval, &yylloc); + } + + while (1 < yystate_stack_.height ()) + { + yydestruct_ (YY_NULL, + yystos_[yystate_stack_[0]], + &yysemantic_stack_[0], + &yylocation_stack_[0]); + yypop_ (); + } + throw; + } } // Generate an error message. @@ -1282,7 +1238,7 @@ namespace lol { } } - char const* yyformat = 0; + char const* yyformat = YY_NULL; switch (yycount) { #define YYCASE_(N, S) \ @@ -1520,7 +1476,7 @@ namespace lol { 1, 2 }; -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE + /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at \a yyntokens_, nonterminals. */ const char* @@ -1543,9 +1499,8 @@ namespace lol { "mesh_open", "mesh_close", "mesh_command_list", "mesh_command", "color_command", "transform_command", "primitive_command", "args1", "args2", "args3", "args4", "args5", "args6", "args7", "args8", "args9", - "args10", "number", 0 + "args10", "number", YY_NULL }; -#endif #if YYDEBUG /* YYRHS -- A `-1'-separated list of the rules' RHS. */ @@ -1601,16 +1556,16 @@ namespace lol { const unsigned char EasyMeshParser::yyrline_[] = { - 0, 76, 76, 80, 81, 85, 86, 90, 94, 98, - 99, 103, 104, 105, 109, 110, 113, 114, 120, 121, - 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, - 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, - 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, - 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, - 162, 163, 164, 165, 166, 167, 171, 174, 177, 178, - 180, 182, 183, 184, 185, 187, 189, 190, 191, 192, - 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, - 209, 210 + 0, 80, 80, 84, 85, 89, 90, 94, 98, 102, + 103, 107, 108, 109, 113, 114, 117, 118, 124, 125, + 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, + 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, + 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, + 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, + 166, 167, 168, 169, 170, 171, 175, 178, 181, 182, + 184, 186, 187, 188, 189, 191, 193, 194, 195, 196, + 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, + 213, 214 }; // Print the state stack on the debug stream. @@ -1703,13 +1658,10 @@ namespace lol { } // lol - +/* Line 1135 of lalr1.cc */ +#line 1663 "generated/easymesh-parser.cpp" /* Line 1136 of lalr1.cc */ -#line 1709 "generated/easymesh-parser.cpp" - - -/* Line 1138 of lalr1.cc */ -#line 213 "easymesh/easymesh-parser.y" +#line 217 "easymesh/easymesh-parser.y" void lol::EasyMeshParser::error(const EasyMeshParser::location_type& l, @@ -1718,4 +1670,3 @@ void lol::EasyMeshParser::error(const EasyMeshParser::location_type& l, mc.Error(l, m); } - diff --git a/src/generated/easymesh-parser.h b/src/generated/easymesh-parser.h index 44f7de49..0cef2dfa 100644 --- a/src/generated/easymesh-parser.h +++ b/src/generated/easymesh-parser.h @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.5. */ +/* A Bison parser, made by GNU Bison 2.7.12-4996. */ /* Skeleton interface for Bison LALR(1) parsers in C++ - Copyright (C) 2002-2011 Free Software Foundation, Inc. + Copyright (C) 2002-2013 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,10 +30,15 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ +/** + ** \file generated/easymesh-parser.h + ** Define the lol::parser class. + */ + /* C++ LALR(1) parser skeleton written by Akim Demaille. */ -#ifndef PARSER_HEADER_H -# define PARSER_HEADER_H +#ifndef YY_LOL_GENERATED_EASYMESH_PARSER_H_INCLUDED +# define YY_LOL_GENERATED_EASYMESH_PARSER_H_INCLUDED @@ -47,24 +52,10 @@ # define YYDEBUG 1 #endif -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 1 -#endif - -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 -#endif - namespace lol { - -/* Line 35 of lalr1.cc */ -#line 68 "generated/easymesh-parser.h" +/* Line 33 of lalr1.cc */ +#line 59 "generated/easymesh-parser.h" /// A Bison parser. class EasyMeshParser @@ -74,9 +65,8 @@ namespace lol { #ifndef YYSTYPE union semantic_type { - -/* Line 35 of lalr1.cc */ -#line 36 "easymesh/easymesh-parser.y" +/* Line 33 of lalr1.cc */ +#line 40 "easymesh/easymesh-parser.y" float fval; /* Can't use uin32_t here for some reason */ @@ -84,9 +74,8 @@ namespace lol { struct { float f0, f1, f2, f3, f4, f5, f6, f7, f8, f9; } args; - -/* Line 35 of lalr1.cc */ -#line 90 "generated/easymesh-parser.h" +/* Line 33 of lalr1.cc */ +#line 79 "generated/easymesh-parser.h" }; #else typedef YYSTYPE semantic_type; @@ -188,6 +177,10 @@ namespace lol { #endif private: + /// This class is not copyable. + EasyMeshParser (const EasyMeshParser&); + EasyMeshParser& operator= (const EasyMeshParser&); + /// Report a syntax error. /// \param loc where the syntax error is found. /// \param msg a description of the syntax error. @@ -271,16 +264,14 @@ namespace lol { /// For a rule, its LHS. static const unsigned char yyr1_[]; /// For a rule, its RHS length. - static const unsigned char yyr2_[]; - -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE - /// For a symbol, its name in clear. - static const char* const yytname_[]; -#endif + static const unsigned char yyr2_[]; /// Convert the symbol name \a n to a form suitable for a diagnostic. static std::string yytnamerr_ (const char *n); + + /// For a symbol, its name in clear. + static const char* const yytname_[]; #if YYDEBUG /// A type to store symbol numbers and -1. typedef signed char rhs_number_type; @@ -307,6 +298,7 @@ namespace lol { /// \brief Reclaim the memory associated to a symbol. /// \param yymsg Why this token is reclaimed. + /// If null, do not display the symbol, just free it. /// \param yytype The symbol type. /// \param yyvaluep Its semantic value. /// \param yylocationp Its location. @@ -336,10 +328,9 @@ namespace lol { }; } // lol - -/* Line 35 of lalr1.cc */ -#line 342 "generated/easymesh-parser.h" +/* Line 33 of lalr1.cc */ +#line 333 "generated/easymesh-parser.h" -#endif /* ! defined PARSER_HEADER_H */ +#endif /* !YY_LOL_GENERATED_EASYMESH_PARSER_H_INCLUDED */ diff --git a/src/generated/easymesh-scanner.cpp b/src/generated/easymesh-scanner.cpp index cc1586aa..ad8d8a24 100644 --- a/src/generated/easymesh-scanner.cpp +++ b/src/generated/easymesh-scanner.cpp @@ -1003,7 +1003,7 @@ case 58: YY_RULE_SETUP #line 112 "easymesh/easymesh-scanner.l" { - uint32_t tmp = std::strtol(yytext + 1, NULL, 16); + uint32_t tmp = std::strtol(yytext + 1, nullptr, 16); yylval->u32val = 0x11000000u * (tmp >> 8) | 0x00110000u * ((tmp >> 4) & 0xf) | 0x00001100u * (tmp & 0xf) @@ -1014,7 +1014,7 @@ case 59: YY_RULE_SETUP #line 119 "easymesh/easymesh-scanner.l" { - uint32_t tmp = std::strtol(yytext + 1, NULL, 16); + uint32_t tmp = std::strtol(yytext + 1, nullptr, 16); yylval->u32val = 0x11000000u * (tmp >> 12) | 0x00110000u * ((tmp >> 8) & 0xf) | 0x00001100u * ((tmp >> 4) & 0xf) @@ -1026,14 +1026,14 @@ YY_RULE_SETUP #line 126 "easymesh/easymesh-scanner.l" { yylval->u32val = 0xffu - | 0x100u * (uint32_t)std::strtol(yytext + 1, NULL, 16); + | 0x100u * (uint32_t)std::strtol(yytext + 1, nullptr, 16); return token::COLOR; } YY_BREAK case 61: YY_RULE_SETUP #line 130 "easymesh/easymesh-scanner.l" { - yylval->u32val = (uint32_t)std::strtol(yytext + 1, NULL, 16); + yylval->u32val = (uint32_t)std::strtol(yytext + 1, nullptr, 16); return token::COLOR; } YY_BREAK case 62: diff --git a/src/generated/location.hh b/src/generated/location.hh index 76061106..442725b4 100644 --- a/src/generated/location.hh +++ b/src/generated/location.hh @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.5. */ +/* A Bison parser, made by GNU Bison 2.7.12-4996. */ /* Locations for Bison parsers in C++ - Copyright (C) 2002-2007, 2009-2011 Free Software Foundation, Inc. + Copyright (C) 2002-2007, 2009-2013 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,39 +31,55 @@ version 2.2 of Bison. */ /** - ** \file location.hh + ** \file generated/location.hh ** Define the lol::location class. */ -#ifndef BISON_LOCATION_HH -# define BISON_LOCATION_HH +#ifndef YY_LOL_GENERATED_LOCATION_HH_INCLUDED +# define YY_LOL_GENERATED_LOCATION_HH_INCLUDED -# include -# include # include "position.hh" namespace lol { - -/* Line 162 of location.cc */ -#line 50 "generated/location.hh" +/* Line 166 of location.cc */ +#line 47 "generated/location.hh" /// Abstract a location. class location { public: - /// Construct a location. - location () - : begin (), end () + /// Construct a location from \a b to \a e. + location (const position& b, const position& e) + : begin (b) + , end (e) + { + } + + /// Construct a 0-width location in \a p. + explicit location (const position& p = position ()) + : begin (p) + , end (p) + { + } + + /// Construct a 0-width location in \a f, \a l, \a c. + explicit location (std::string* f, + unsigned int l = 1u, + unsigned int c = 1u) + : begin (f, l, c) + , end (f, l, c) { } /// Initialization. - inline void initialize (std::string* fn) + void initialize (std::string* f = YY_NULL, + unsigned int l = 1u, + unsigned int c = 1u) { - begin.initialize (fn); + begin.initialize (f, l, c); end = begin; } @@ -71,19 +87,19 @@ namespace lol { ** \{ */ public: /// Reset initial location to final location. - inline void step () + void step () { begin = end; } /// Extend the current location to the COUNT next columns. - inline void columns (unsigned int count = 1) + void columns (unsigned int count = 1) { end += count; } /// Extend the current location to the COUNT next lines. - inline void lines (unsigned int count = 1) + void lines (unsigned int count = 1) { end.lines (count); } @@ -140,7 +156,9 @@ namespace lol { ** ** Avoid duplicate information. */ - inline std::ostream& operator<< (std::ostream& ostr, const location& loc) + template + inline std::basic_ostream& + operator<< (std::basic_ostream& ostr, const location& loc) { position last = loc.end - 1; ostr << loc.begin; @@ -157,8 +175,7 @@ namespace lol { } // lol +/* Line 296 of location.cc */ +#line 180 "generated/location.hh" -/* Line 271 of location.cc */ -#line 163 "generated/location.hh" - -#endif // not BISON_LOCATION_HH +#endif /* !YY_LOL_GENERATED_LOCATION_HH_INCLUDED */ diff --git a/src/generated/lolfx-parser.cpp b/src/generated/lolfx-parser.cpp index 9c73389d..3a98ba13 100644 --- a/src/generated/lolfx-parser.cpp +++ b/src/generated/lolfx-parser.cpp @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.5. */ +/* A Bison parser, made by GNU Bison 2.7.12-4996. */ /* Skeleton implementation for Bison LALR(1) parsers in C++ - Copyright (C) 2002-2011 Free Software Foundation, Inc. + Copyright (C) 2002-2013 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,8 +34,7 @@ #define yylex lollex /* First part of user declarations. */ - -/* Line 293 of lalr1.cc */ +/* Line 283 of lalr1.cc */ #line 1 "gpu/lolfx-parser.y" // @@ -56,28 +55,38 @@ #include +/* HACK: workaround for Bison who insists on using exceptions */ +#define try if (true) +#define catch(...) if (false) +#define throw (void)0 - -/* Line 293 of lalr1.cc */ -#line 63 "generated/lolfx-parser.cpp" +/* Line 283 of lalr1.cc */ +#line 65 "generated/lolfx-parser.cpp" #include "lolfx-parser.h" /* User implementation prologue. */ - -/* Line 299 of lalr1.cc */ -#line 241 "gpu/lolfx-parser.y" +/* Line 289 of lalr1.cc */ +#line 245 "gpu/lolfx-parser.y" #include "gpu/lolfx-compiler.h" #undef yylex #define yylex mc.m_lexer->lex - -/* Line 299 of lalr1.cc */ +/* Line 289 of lalr1.cc */ #line 80 "generated/lolfx-parser.cpp" + +# ifndef YY_NULL +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULL nullptr +# else +# define YY_NULL 0 +# endif +# endif + #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS @@ -90,25 +99,26 @@ # endif #endif +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. If N is 0, then set CURRENT to the empty location which ends the previous symbol: RHS[0] (always defined). */ -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (N) \ - { \ - (Current).begin = YYRHSLOC (Rhs, 1).begin; \ - (Current).end = YYRHSLOC (Rhs, N).end; \ - } \ - else \ - { \ - (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \ - } \ - while (false) -#endif +# ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (N) \ + { \ + (Current).begin = YYRHSLOC (Rhs, 1).begin; \ + (Current).end = YYRHSLOC (Rhs, N).end; \ + } \ + else \ + { \ + (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \ + } \ + while (/*CONSTCOND*/ false) +# endif + /* Suppress unused-variable warnings by "using" E. */ #define YYUSE(e) ((void) (e)) @@ -144,9 +154,9 @@ do { \ #else /* !YYDEBUG */ # define YYCDEBUG if (false) std::cerr -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) -# define YY_REDUCE_PRINT(Rule) -# define YY_STACK_PRINT() +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) YYUSE(Type) +# define YY_REDUCE_PRINT(Rule) static_cast(0) +# define YY_STACK_PRINT() static_cast(0) #endif /* !YYDEBUG */ @@ -160,9 +170,8 @@ do { \ namespace lol { - -/* Line 382 of lalr1.cc */ -#line 166 "generated/lolfx-parser.cpp" +/* Line 357 of lalr1.cc */ +#line 175 "generated/lolfx-parser.cpp" /* Return YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is @@ -228,11 +237,10 @@ namespace lol { { YYUSE (yylocationp); YYUSE (yyvaluep); - switch (yytype) - { - default: - break; - } + std::ostream& yyo = debug_stream (); + std::ostream& yyoutput = yyo; + YYUSE (yyoutput); + YYUSE (yytype); } @@ -256,14 +264,10 @@ namespace lol { YYUSE (yymsg); YYUSE (yyvaluep); - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + if (yymsg) + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - switch (yytype) - { - - default: - break; - } + YYUSE (yytype); } void @@ -320,17 +324,18 @@ namespace lol { int yychar = yyempty_; int yytoken = 0; - /* State. */ + // State. int yyn; int yylen = 0; int yystate = 0; - /* Error handling. */ + // Error handling. int yynerrs_ = 0; int yyerrstatus_ = 0; /// Semantic value of the lookahead. - semantic_type yylval; + static semantic_type yyval_default; + semantic_type yylval = yyval_default; /// Location of the lookahead. location_type yylloc; /// The locations where the error started and ended. @@ -343,6 +348,10 @@ namespace lol { int yyresult; + // FIXME: This shoud be completely indented. It is not yet to + // avoid gratuitous conflicts when merging into the master branch. + try + { YYCDEBUG << "Starting parse" << std::endl; @@ -350,9 +359,9 @@ namespace lol { yynewstate, since the latter expects the semantical and the location values to have been already stored, initialize these stacks with a primary value. */ - yystate_stack_ = state_stack_type (0); - yysemantic_stack_ = semantic_stack_type (0); - yylocation_stack_ = location_stack_type (0); + yystate_stack_.clear (); + yysemantic_stack_.clear (); + yylocation_stack_.clear (); yysemantic_stack_.push (yylval); yylocation_stack_.push (yylloc); @@ -378,11 +387,10 @@ namespace lol { /* Read a lookahead token. */ if (yychar == yyempty_) { - YYCDEBUG << "Reading a token: "; - yychar = yylex (&yylval, &yylloc); + YYCDEBUG << "Reading a token: "; + yychar = yylex (&yylval, &yylloc); } - /* Convert token to internal form. */ if (yychar <= yyeof_) { @@ -453,55 +461,53 @@ namespace lol { else yyval = yysemantic_stack_[0]; + // Compute the default @$. { slice slice (yylocation_stack_, yylen); YYLLOC_DEFAULT (yyloc, slice, yylen); } + + // Perform the reduction. YY_REDUCE_PRINT (yyn); switch (yyn) { - case 202: - -/* Line 690 of lalr1.cc */ -#line 728 "gpu/lolfx-parser.y" + case 202: +/* Line 664 of lalr1.cc */ +#line 732 "gpu/lolfx-parser.y" { std::cout << "New tech " << std::endl; } break; case 203: - -/* Line 690 of lalr1.cc */ -#line 736 "gpu/lolfx-parser.y" +/* Line 664 of lalr1.cc */ +#line 740 "gpu/lolfx-parser.y" { std::cout << "New name " << (yysemantic_stack_[(1) - (1)].sval) << std::endl; } break; case 204: - -/* Line 690 of lalr1.cc */ -#line 737 "gpu/lolfx-parser.y" +/* Line 664 of lalr1.cc */ +#line 741 "gpu/lolfx-parser.y" { std::cout << "New name " << (yysemantic_stack_[(1) - (1)].sval) << std::endl; } break; case 207: - -/* Line 690 of lalr1.cc */ -#line 750 "gpu/lolfx-parser.y" +/* Line 664 of lalr1.cc */ +#line 754 "gpu/lolfx-parser.y" { std::cout << "New pass " << std::endl; } break; case 226: - -/* Line 690 of lalr1.cc */ -#line 786 "gpu/lolfx-parser.y" +/* Line 664 of lalr1.cc */ +#line 790 "gpu/lolfx-parser.y" { std::cout << "new shader" << std::endl; } break; - -/* Line 690 of lalr1.cc */ -#line 502 "generated/lolfx-parser.cpp" - default: - break; +/* Line 664 of lalr1.cc */ +#line 507 "generated/lolfx-parser.cpp" + default: + break; } + /* User semantic actions sometimes alter yychar, and that requires that yytoken be updated with the new translation. We take the approach of translating immediately before every use of yytoken. @@ -552,20 +558,19 @@ namespace lol { yyerror_range[1] = yylloc; if (yyerrstatus_ == 3) { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - if (yychar <= yyeof_) - { - /* Return failure if at end of input. */ - if (yychar == yyeof_) - YYABORT; - } - else - { - yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc); - yychar = yyempty_; - } + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + if (yychar <= yyeof_) + { + /* Return failure if at end of input. */ + if (yychar == yyeof_) + YYABORT; + } + else + { + yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc); + yychar = yyempty_; + } } /* Else will try to reuse lookahead token after shifting the error @@ -614,7 +619,7 @@ namespace lol { /* Pop the current state because it cannot handle the error token. */ if (yystate_stack_.height () == 1) - YYABORT; + YYABORT; yyerror_range[1] = yylocation_stack_[0]; yydestruct_ ("Error: popping", @@ -662,16 +667,42 @@ namespace lol { /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ yypop_ (yylen); - while (yystate_stack_.height () != 1) + while (1 < yystate_stack_.height ()) { - yydestruct_ ("Cleanup: popping", - yystos_[yystate_stack_[0]], - &yysemantic_stack_[0], - &yylocation_stack_[0]); - yypop_ (); + yydestruct_ ("Cleanup: popping", + yystos_[yystate_stack_[0]], + &yysemantic_stack_[0], + &yylocation_stack_[0]); + yypop_ (); } return yyresult; + } + catch (...) + { + YYCDEBUG << "Exception caught: cleaning lookahead and stack" + << std::endl; + // Do not try to display the values of the reclaimed symbols, + // as their printer might throw an exception. + if (yychar != yyempty_) + { + /* Make sure we have latest lookahead translation. See + comments at user semantic actions for why this is + necessary. */ + yytoken = yytranslate_ (yychar); + yydestruct_ (YY_NULL, yytoken, &yylval, &yylloc); + } + + while (1 < yystate_stack_.height ()) + { + yydestruct_ (YY_NULL, + yystos_[yystate_stack_[0]], + &yysemantic_stack_[0], + &yylocation_stack_[0]); + yypop_ (); + } + throw; + } } // Generate an error message. @@ -740,7 +771,7 @@ namespace lol { } } - char const* yyformat = 0; + char const* yyformat = YY_NULL; switch (yycount) { #define YYCASE_(N, S) \ @@ -3359,7 +3390,7 @@ namespace lol { 1, 2, 1, 1, 2 }; -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE + /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at \a yyntokens_, nonterminals. */ const char* @@ -3512,9 +3543,8 @@ namespace lol { "glsl_iteration_statement", "glsl_for_init_statement", "glsl_conditionopt", "glsl_for_rest_statement", "glsl_jump_statement", "glsl_translation_unit", "glsl_external_declaration", - "glsl_function_definition", 0 + "glsl_function_definition", YY_NULL }; -#endif #if YYDEBUG /* YYRHS -- A `-1'-separated list of the rules' RHS. */ @@ -3711,54 +3741,54 @@ namespace lol { const unsigned short int LolFxParser::yyrline_[] = { - 0, 255, 271, 272, 273, 274, 275, 276, 277, 278, - 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, - 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, - 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, - 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, - 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, - 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, - 339, 340, 341, 342, 343, 344, 345, 508, 509, 510, - 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, - 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, - 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, - 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, - 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, - 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, - 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, - 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, - 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, - 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, - 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, - 621, 622, 623, 624, 625, 626, 627, 710, 714, 715, - 719, 720, 728, 736, 737, 745, 746, 750, 754, 755, - 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, - 770, 771, 772, 773, 774, 782, 786, 790, 791, 795, - 803, 807, 808, 809, 810, 811, 812, 816, 817, 818, - 819, 820, 821, 825, 829, 833, 834, 838, 839, 843, - 844, 848, 849, 853, 857, 858, 859, 863, 864, 865, - 866, 870, 871, 872, 873, 877, 878, 879, 880, 884, - 885, 886, 890, 891, 892, 896, 897, 898, 899, 900, - 904, 905, 906, 910, 911, 915, 916, 920, 921, 925, - 926, 930, 931, 935, 936, 940, 941, 945, 946, 950, - 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, - 964, 965, 969, 973, 974, 975, 976, 977, 978, 979, - 980, 984, 988, 989, 993, 994, 998, 1002, 1003, 1007, - 1008, 1012, 1013, 1014, 1015, 1019, 1020, 1023, 1025, 1026, - 1027, 1028, 1029, 1033, 1037, 1038, 1039, 1040, 1041, 1042, - 1043, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1058, - 1059, 1063, 1067, 1068, 1069, 1073, 1077, 1078, 1082, 1083, - 1087, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1102, - 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, - 1113, 1117, 1118, 1122, 1123, 1124, 1127, 1128, 1132, 1133, - 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, - 1144, 1148, 1149, 1150, 1154, 1155, 1159, 1160, 1164, 1165, - 1169, 1170, 1174, 1175, 1176, 1180, 1184, 1188, 1189, 1193, - 1194, 1195, 1196, 1197, 1198, 1199, 1203, 1204, 1208, 1209, - 1213, 1214, 1218, 1219, 1223, 1224, 1228, 1232, 1233, 1237, - 1238, 1242, 1245, 1247, 1251, 1252, 1256, 1257, 1258, 1262, - 1263, 1267, 1268, 1272, 1273, 1277, 1278, 1279, 1280, 1281, - 1285, 1286, 1290, 1291, 1295 + 0, 259, 275, 276, 277, 278, 279, 280, 281, 282, + 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, + 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, + 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, + 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, + 343, 344, 345, 346, 347, 348, 349, 512, 513, 514, + 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, + 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, + 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, + 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, + 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, + 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, + 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, + 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, + 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, + 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, + 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, + 625, 626, 627, 628, 629, 630, 631, 714, 718, 719, + 723, 724, 732, 740, 741, 749, 750, 754, 758, 759, + 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, + 774, 775, 776, 777, 778, 786, 790, 794, 795, 799, + 807, 811, 812, 813, 814, 815, 816, 820, 821, 822, + 823, 824, 825, 829, 833, 837, 838, 842, 843, 847, + 848, 852, 853, 857, 861, 862, 863, 867, 868, 869, + 870, 874, 875, 876, 877, 881, 882, 883, 884, 888, + 889, 890, 894, 895, 896, 900, 901, 902, 903, 904, + 908, 909, 910, 914, 915, 919, 920, 924, 925, 929, + 930, 934, 935, 939, 940, 944, 945, 949, 950, 954, + 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, + 968, 969, 973, 977, 978, 979, 980, 981, 982, 983, + 984, 988, 992, 993, 997, 998, 1002, 1006, 1007, 1011, + 1012, 1016, 1017, 1018, 1019, 1023, 1024, 1027, 1029, 1030, + 1031, 1032, 1033, 1037, 1041, 1042, 1043, 1044, 1045, 1046, + 1047, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1062, + 1063, 1067, 1071, 1072, 1073, 1077, 1081, 1082, 1086, 1087, + 1091, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1106, + 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, + 1117, 1121, 1122, 1126, 1127, 1128, 1131, 1132, 1136, 1137, + 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, + 1148, 1152, 1153, 1154, 1158, 1159, 1163, 1164, 1168, 1169, + 1173, 1174, 1178, 1179, 1180, 1184, 1188, 1192, 1193, 1197, + 1198, 1199, 1200, 1201, 1202, 1203, 1207, 1208, 1212, 1213, + 1217, 1218, 1222, 1223, 1227, 1228, 1232, 1236, 1237, 1241, + 1242, 1246, 1249, 1251, 1255, 1256, 1260, 1261, 1262, 1266, + 1267, 1271, 1272, 1276, 1277, 1281, 1282, 1283, 1284, 1285, + 1289, 1290, 1294, 1295, 1299 }; // Print the state stack on the debug stream. @@ -3889,13 +3919,10 @@ namespace lol { } // lol - +/* Line 1135 of lalr1.cc */ +#line 3924 "generated/lolfx-parser.cpp" /* Line 1136 of lalr1.cc */ -#line 3895 "generated/lolfx-parser.cpp" - - -/* Line 1138 of lalr1.cc */ -#line 1298 "gpu/lolfx-parser.y" +#line 1302 "gpu/lolfx-parser.y" void lol::LolFxParser::error(const LolFxParser::location_type& l, @@ -3904,4 +3931,3 @@ void lol::LolFxParser::error(const LolFxParser::location_type& l, mc.Error(l, m); } - diff --git a/src/generated/lolfx-parser.h b/src/generated/lolfx-parser.h index c41899dc..cfe7c778 100644 --- a/src/generated/lolfx-parser.h +++ b/src/generated/lolfx-parser.h @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.5. */ +/* A Bison parser, made by GNU Bison 2.7.12-4996. */ /* Skeleton interface for Bison LALR(1) parsers in C++ - Copyright (C) 2002-2011 Free Software Foundation, Inc. + Copyright (C) 2002-2013 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,10 +30,15 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ +/** + ** \file generated/lolfx-parser.h + ** Define the lol::parser class. + */ + /* C++ LALR(1) parser skeleton written by Akim Demaille. */ -#ifndef PARSER_HEADER_H -# define PARSER_HEADER_H +#ifndef YY_LOL_GENERATED_LOLFX_PARSER_H_INCLUDED +# define YY_LOL_GENERATED_LOLFX_PARSER_H_INCLUDED @@ -47,24 +52,10 @@ # define YYDEBUG 1 #endif -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 1 -#endif - -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 -#endif - namespace lol { - -/* Line 35 of lalr1.cc */ -#line 68 "generated/lolfx-parser.h" +/* Line 33 of lalr1.cc */ +#line 59 "generated/lolfx-parser.h" /// A Bison parser. class LolFxParser @@ -74,9 +65,8 @@ namespace lol { #ifndef YYSTYPE union semantic_type { - -/* Line 35 of lalr1.cc */ -#line 34 "gpu/lolfx-parser.y" +/* Line 33 of lalr1.cc */ +#line 38 "gpu/lolfx-parser.y" int ival; unsigned uval; @@ -84,9 +74,8 @@ namespace lol { char *sval; - -/* Line 35 of lalr1.cc */ -#line 90 "generated/lolfx-parser.h" +/* Line 33 of lalr1.cc */ +#line 79 "generated/lolfx-parser.h" }; #else typedef YYSTYPE semantic_type; @@ -563,6 +552,10 @@ namespace lol { #endif private: + /// This class is not copyable. + LolFxParser (const LolFxParser&); + LolFxParser& operator= (const LolFxParser&); + /// Report a syntax error. /// \param loc where the syntax error is found. /// \param msg a description of the syntax error. @@ -646,16 +639,14 @@ namespace lol { /// For a rule, its LHS. static const unsigned short int yyr1_[]; /// For a rule, its RHS length. - static const unsigned char yyr2_[]; - -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE - /// For a symbol, its name in clear. - static const char* const yytname_[]; -#endif + static const unsigned char yyr2_[]; /// Convert the symbol name \a n to a form suitable for a diagnostic. static std::string yytnamerr_ (const char *n); + + /// For a symbol, its name in clear. + static const char* const yytname_[]; #if YYDEBUG /// A type to store symbol numbers and -1. typedef short int rhs_number_type; @@ -682,6 +673,7 @@ namespace lol { /// \brief Reclaim the memory associated to a symbol. /// \param yymsg Why this token is reclaimed. + /// If null, do not display the symbol, just free it. /// \param yytype The symbol type. /// \param yyvaluep Its semantic value. /// \param yylocationp Its location. @@ -711,10 +703,9 @@ namespace lol { }; } // lol - -/* Line 35 of lalr1.cc */ -#line 717 "generated/lolfx-parser.h" +/* Line 33 of lalr1.cc */ +#line 708 "generated/lolfx-parser.h" -#endif /* ! defined PARSER_HEADER_H */ +#endif /* !YY_LOL_GENERATED_LOLFX_PARSER_H_INCLUDED */ diff --git a/src/generated/position.hh b/src/generated/position.hh index 5a706fc4..c30401ac 100644 --- a/src/generated/position.hh +++ b/src/generated/position.hh @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.5. */ +/* A Bison parser, made by GNU Bison 2.7.12-4996. */ /* Positions for Bison parsers in C++ - Copyright (C) 2002-2007, 2009-2011 Free Software Foundation, Inc. + Copyright (C) 2002-2007, 2009-2013 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,60 +31,71 @@ version 2.2 of Bison. */ /** - ** \file position.hh + ** \file generated/position.hh ** Define the lol::position class. */ -#ifndef BISON_POSITION_HH -# define BISON_POSITION_HH +#ifndef YY_LOL_GENERATED_POSITION_HH_INCLUDED +# define YY_LOL_GENERATED_POSITION_HH_INCLUDED +# include // std::max # include # include -# include +# ifndef YY_NULL +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULL nullptr +# else +# define YY_NULL 0 +# endif +# endif -namespace lol { -/* Line 37 of location.cc */ -#line 50 "generated/position.hh" +namespace lol { +/* Line 36 of location.cc */ +#line 57 "generated/position.hh" /// Abstract a position. class position { public: /// Construct a position. - position () - : filename (0), line (1), column (1) + explicit position (std::string* f = YY_NULL, + unsigned int l = 1u, + unsigned int c = 1u) + : filename (f) + , line (l) + , column (c) { } /// Initialization. - inline void initialize (std::string* fn) + void initialize (std::string* fn = YY_NULL, + unsigned int l = 1u, + unsigned int c = 1u) { filename = fn; - line = 1; - column = 1; + line = l; + column = c; } /** \name Line and Column related manipulators ** \{ */ - public: /// (line related) Advance to the COUNT next lines. - inline void lines (int count = 1) + void lines (int count = 1) { - column = 1; + column = 1u; line += count; } /// (column related) Advance to the COUNT next columns. - inline void columns (int count = 1) + void columns (int count = 1) { column = std::max (1u, column + count); } /** \} */ - public: /// File name to which this position refers. std::string* filename; /// Current line number. @@ -94,7 +105,7 @@ namespace lol { }; /// Add and assign a position. - inline const position& + inline position& operator+= (position& res, const int width) { res.columns (width); @@ -110,7 +121,7 @@ namespace lol { } /// Add and assign a position. - inline const position& + inline position& operator-= (position& res, const int width) { return res += -width; @@ -145,8 +156,9 @@ namespace lol { ** \param ostr the destination output stream ** \param pos a reference to the position to redirect */ - inline std::ostream& - operator<< (std::ostream& ostr, const position& pos) + template + inline std::basic_ostream& + operator<< (std::basic_ostream& ostr, const position& pos) { if (pos.filename) ostr << *pos.filename << ':'; @@ -155,7 +167,6 @@ namespace lol { } // lol - -/* Line 144 of location.cc */ -#line 161 "generated/position.hh" -#endif // not BISON_POSITION_HH +/* Line 148 of location.cc */ +#line 172 "generated/position.hh" +#endif /* !YY_LOL_GENERATED_POSITION_HH_INCLUDED */ diff --git a/src/generated/stack.hh b/src/generated/stack.hh index e5d1f9cf..df42446e 100644 --- a/src/generated/stack.hh +++ b/src/generated/stack.hh @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.5. */ +/* A Bison parser, made by GNU Bison 2.7.12-4996. */ /* Stack handling for Bison parsers in C++ - Copyright (C) 2002-2011 Free Software Foundation, Inc. + Copyright (C) 2002-2013 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,21 +30,24 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ -#ifndef BISON_STACK_HH -# define BISON_STACK_HH +/** + ** \file generated/stack.hh + ** Define the lol::stack class. + */ -#include +#ifndef YY_LOL_GENERATED_STACK_HH_INCLUDED +# define YY_LOL_GENERATED_STACK_HH_INCLUDED +# include -namespace lol { -/* Line 1149 of lalr1.cc */ -#line 43 "generated/stack.hh" +namespace lol { +/* Line 34 of stack.hh */ +#line 47 "generated/stack.hh" template > class stack { public: - // Hide our reversed order. typedef typename S::reverse_iterator iterator; typedef typename S::const_reverse_iterator const_iterator; @@ -83,7 +86,13 @@ namespace lol { pop (unsigned int n = 1) { for (; n; --n) - seq_.pop_front (); + seq_.pop_front (); + } + + void + clear () + { + seq_.clear (); } inline @@ -97,7 +106,8 @@ namespace lol { inline const_iterator end () const { return seq_.rend (); } private: - + stack (const stack&); + stack& operator= (const stack&); S seq_; }; @@ -106,10 +116,9 @@ namespace lol { class slice { public: - - slice (const S& stack, - unsigned int range) : stack_ (stack), - range_ (range) + slice (const S& stack, unsigned int range) + : stack_ (stack) + , range_ (range) { } @@ -121,15 +130,12 @@ namespace lol { } private: - const S& stack_; unsigned int range_; }; } // lol +/* Line 124 of stack.hh */ +#line 140 "generated/stack.hh" -/* Line 1235 of lalr1.cc */ -#line 133 "generated/stack.hh" - -#endif // not BISON_STACK_HH[]dnl - +#endif /* !YY_LOL_GENERATED_STACK_HH_INCLUDED */ diff --git a/src/gpu/lolfx-parser.y b/src/gpu/lolfx-parser.y index 6b84fea0..6d4669da 100644 --- a/src/gpu/lolfx-parser.y +++ b/src/gpu/lolfx-parser.y @@ -17,6 +17,10 @@ #include +/* HACK: workaround for Bison who insists on using exceptions */ +#define try if (true) +#define catch(...) if (false) +#define throw (void)0 %} %require "2.3"