From 78c949b2d5a5a5a5fbbb4ab202942cf5919ac3ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20=E2=80=98Touky=E2=80=99=20Huet?= Date: Thu, 19 Sep 2013 09:59:59 +0000 Subject: [PATCH] URO : Added URO parser/scanner etc for custom command setup. EzMesh : parser/scanner regen (with older bison cause windows). --- src/generated/easymesh-parser.cpp | 634 ++++++++++++++---------------- src/generated/easymesh-parser.h | 108 +++-- src/generated/location.hh | 63 ++- src/generated/lolfx-parser.cpp | 409 +++++++------------ src/generated/lolfx-parser.h | 108 +++-- src/generated/position.hh | 65 ++- src/generated/stack.hh | 48 +-- 7 files changed, 653 insertions(+), 782 deletions(-) diff --git a/src/generated/easymesh-parser.cpp b/src/generated/easymesh-parser.cpp index fd9e4b22..7baed239 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.7.12-4996. */ +/* A Bison parser, made by GNU Bison 2.4.2. */ /* Skeleton implementation for Bison LALR(1) parsers in C++ - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2010 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,7 +34,8 @@ #define yylex lollex /* First part of user declarations. */ -/* Line 283 of lalr1.cc */ + +/* Line 310 of lalr1.cc */ #line 1 "easymesh/easymesh-parser.y" // @@ -58,14 +59,16 @@ #include -/* Line 283 of lalr1.cc */ -#line 63 "generated/easymesh-parser.cpp" + +/* Line 310 of lalr1.cc */ +#line 65 "generated/easymesh-parser.cpp" #include "easymesh-parser.h" /* User implementation prologue. */ -/* Line 289 of lalr1.cc */ + +/* Line 316 of lalr1.cc */ #line 65 "easymesh/easymesh-parser.y" #include "easymesh/easymesh-compiler.h" @@ -78,17 +81,9 @@ #define catch(...) if (false) #define throw (void)0 -/* 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 +/* Line 316 of lalr1.cc */ +#line 87 "generated/easymesh-parser.cpp" #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS @@ -102,27 +97,6 @@ # 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). */ - -# 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)) @@ -157,9 +131,9 @@ do { \ #else /* !YYDEBUG */ # define YYCDEBUG if (false) std::cerr -# 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) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_REDUCE_PRINT(Rule) +# define YY_STACK_PRINT() #endif /* !YYDEBUG */ @@ -173,8 +147,10 @@ do { \ namespace lol { -/* Line 357 of lalr1.cc */ -#line 178 "generated/easymesh-parser.cpp" + +/* Line 379 of lalr1.cc */ +#line 153 "generated/easymesh-parser.cpp" +#if YYERROR_VERBOSE /* Return YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is @@ -213,6 +189,7 @@ namespace lol { return yystr; } +#endif /// Build a parser object. EasyMeshParser::EasyMeshParser (class EasyMeshCompiler& mc_yyarg) @@ -240,10 +217,11 @@ namespace lol { { YYUSE (yylocationp); YYUSE (yyvaluep); - std::ostream& yyo = debug_stream (); - std::ostream& yyoutput = yyo; - YYUSE (yyoutput); - YYUSE (yytype); + switch (yytype) + { + default: + break; + } } @@ -267,10 +245,14 @@ namespace lol { YYUSE (yymsg); YYUSE (yyvaluep); - if (yymsg) - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - YYUSE (yytype); + switch (yytype) + { + + default: + break; + } } void @@ -308,18 +290,6 @@ namespace lol { } #endif - inline bool - EasyMeshParser::yy_pact_value_is_default_ (int yyvalue) - { - return yyvalue == yypact_ninf_; - } - - inline bool - EasyMeshParser::yy_table_value_is_error_ (int yyvalue) - { - return yyvalue == yytable_ninf_; - } - int EasyMeshParser::parse () { @@ -327,22 +297,21 @@ 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. - static semantic_type yyval_default; - semantic_type yylval = yyval_default; + semantic_type yylval; /// Location of the lookahead. location_type yylloc; /// The locations where the error started and ended. - location_type yyerror_range[3]; + location_type yyerror_range[2]; /// $$. semantic_type yyval; @@ -351,10 +320,6 @@ 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; @@ -362,9 +327,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_.clear (); - yysemantic_stack_.clear (); - yylocation_stack_.clear (); + yystate_stack_ = state_stack_type (0); + yysemantic_stack_ = semantic_stack_type (0); + yylocation_stack_ = location_stack_type (0); yysemantic_stack_.push (yylval); yylocation_stack_.push (yylloc); @@ -384,16 +349,17 @@ namespace lol { /* Try to take a decision without lookahead. */ yyn = yypact_[yystate]; - if (yy_pact_value_is_default_ (yyn)) + if (yyn == yypact_ninf_) goto yydefault; /* 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_) { @@ -416,8 +382,8 @@ namespace lol { yyn = yytable_[yyn]; if (yyn <= 0) { - if (yy_table_value_is_error_ (yyn)) - goto yyerrlab; + if (yyn == 0 || yyn == yytable_ninf_) + goto yyerrlab; yyn = -yyn; goto yyreduce; } @@ -464,36 +430,37 @@ 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 664 of lalr1.cc */ + case 7: + +/* Line 677 of lalr1.cc */ #line 94 "easymesh/easymesh-parser.y" { mc.m_mesh.OpenBrace(); } break; case 8: -/* Line 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 98 "easymesh/easymesh-parser.y" { mc.m_mesh.CloseBrace(); } break; case 14: -/* Line 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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); @@ -501,13 +468,15 @@ namespace lol { break; case 16: -/* Line 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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); @@ -515,295 +484,344 @@ namespace lol { break; case 18: -/* Line 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 124 "easymesh/easymesh-parser.y" { mc.m_mesh.Chamfer((yysemantic_stack_[(2) - (2)].args).f0); } break; case 19: -/* Line 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 129 "easymesh/easymesh-parser.y" { mc.m_mesh.RotateX((yysemantic_stack_[(2) - (2)].args).f0); } break; case 24: -/* Line 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 130 "easymesh/easymesh-parser.y" { mc.m_mesh.RotateY((yysemantic_stack_[(2) - (2)].args).f0); } break; case 25: -/* Line 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 131 "easymesh/easymesh-parser.y" { mc.m_mesh.RotateZ((yysemantic_stack_[(2) - (2)].args).f0); } break; case 26: -/* Line 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 160 "easymesh/easymesh-parser.y" { mc.m_mesh.MirrorX(); } break; case 55: -/* Line 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 161 "easymesh/easymesh-parser.y" { mc.m_mesh.MirrorY(); } break; case 56: -/* Line 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 162 "easymesh/easymesh-parser.y" { mc.m_mesh.MirrorZ(); } break; case 57: -/* Line 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 163 "easymesh/easymesh-parser.y" { mc.m_mesh.RadialJitter((yysemantic_stack_[(2) - (2)].args).f0); } break; case 58: -/* Line 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 164 "easymesh/easymesh-parser.y" { mc.m_mesh.SplitTriangles((yysemantic_stack_[(2) - (2)].args).f0); } break; case 59: -/* Line 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 166 "easymesh/easymesh-parser.y" { mc.m_mesh.ToggleScaleWinding(); } break; case 61: -/* Line 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 167 "easymesh/easymesh-parser.y" { mc.m_mesh.CsgUnion(); } break; case 62: -/* Line 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 168 "easymesh/easymesh-parser.y" { mc.m_mesh.CsgSubstract(); } break; case 63: -/* Line 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 169 "easymesh/easymesh-parser.y" { mc.m_mesh.CsgSubstractLoss(); } break; case 64: -/* Line 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 170 "easymesh/easymesh-parser.y" { mc.m_mesh.CsgAnd(); } break; case 65: -/* Line 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 171 "easymesh/easymesh-parser.y" { mc.m_mesh.CsgXor(); } break; case 66: -/* Line 664 of lalr1.cc */ + +/* Line 677 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, @@ -811,7 +829,8 @@ namespace lol { break; case 67: -/* Line 664 of lalr1.cc */ + +/* Line 677 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, @@ -819,77 +838,89 @@ namespace lol { break; case 68: -/* Line 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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, @@ -897,95 +928,96 @@ namespace lol { break; case 80: -/* Line 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 201 "easymesh/easymesh-parser.y" { (yyval.args).f0 = (yysemantic_stack_[(1) - (1)].fval); } break; case 81: -/* Line 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 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 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 213 "easymesh/easymesh-parser.y" { (yyval.fval) = (yysemantic_stack_[(1) - (1)].fval); } break; case 91: -/* Line 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 214 "easymesh/easymesh-parser.y" { (yyval.fval) = -(yysemantic_stack_[(2) - (2)].fval); } 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. - One alternative is translating here after every semantic action, - but that translation would be missed if the semantic action - invokes YYABORT, YYACCEPT, or YYERROR immediately after altering - yychar. In the case of YYABORT or YYACCEPT, an incorrect - destructor might then be invoked immediately. In the case of - YYERROR, subsequent parser actions might lead to an incorrect - destructor call or verbose syntax error message before the - lookahead is translated. */ +/* Line 677 of lalr1.cc */ +#line 1018 "generated/easymesh-parser.cpp" + default: + break; + } YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc); yypop_ (yylen); @@ -1009,35 +1041,30 @@ namespace lol { | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = yytranslate_ (yychar); - /* If not already recovering from an error, report this error. */ if (!yyerrstatus_) { ++yynerrs_; - if (yychar == yyempty_) - yytoken = yyempty_; error (yylloc, yysyntax_error_ (yystate, yytoken)); } - yyerror_range[1] = yylloc; + yyerror_range[0] = 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 @@ -1056,7 +1083,7 @@ namespace lol { if (false) goto yyerrorlab; - yyerror_range[1] = yylocation_stack_[yylen - 1]; + yyerror_range[0] = yylocation_stack_[yylen - 1]; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ yypop_ (yylen); @@ -1073,7 +1100,7 @@ namespace lol { for (;;) { yyn = yypact_[yystate]; - if (!yy_pact_value_is_default_ (yyn)) + if (yyn != yypact_ninf_) { yyn += yyterror_; if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) @@ -1086,9 +1113,9 @@ 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]; + yyerror_range[0] = yylocation_stack_[0]; yydestruct_ ("Error: popping", yystos_[yystate], &yysemantic_stack_[0], &yylocation_stack_[0]); @@ -1097,10 +1124,10 @@ namespace lol { YY_STACK_PRINT (); } - yyerror_range[2] = yylloc; + yyerror_range[1] = yylloc; // Using YYLLOC is tempting, but would change the location of // the lookahead. YYLOC is available though. - YYLLOC_DEFAULT (yyloc, yyerror_range, 2); + YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); yysemantic_stack_.push (yylval); yylocation_stack_.push (yyloc); @@ -1123,148 +1150,70 @@ namespace lol { yyreturn: 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_ ("Cleanup: discarding lookahead", yytoken, &yylval, - &yylloc); - } + yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ yypop_ (yylen); - while (1 < yystate_stack_.height ()) + while (yystate_stack_.height () != 1) { - 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. std::string - EasyMeshParser::yysyntax_error_ (int yystate, int yytoken) + EasyMeshParser::yysyntax_error_ (int yystate, int tok) { - std::string yyres; - // Number of reported tokens (one for the "unexpected", one per - // "expected"). - size_t yycount = 0; - // Its maximum. - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - // Arguments of yyformat. - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - - /* There are many possibilities here to consider: - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yytoken) is - if this state is a consistent state with a default action. - Thus, detecting the absence of a lookahead is sufficient to - determine that there is no unexpected or expected token to - report. In that case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is - a consistent state with a default action. There might have - been a previous inconsistent state, consistent state with a - non-default action, or user semantic action that manipulated - yychar. - - Of course, the expected token list depends on states to have - correct lookahead information, and it depends on the parser not - to perform extra reductions after fetching a lookahead from the - scanner and before detecting a syntax error. Thus, state - merging (from LALR or IELR) and default reductions corrupt the - expected token list. However, the list is correct for - canonical LR with one exception: it will still contain any - token that will not be accepted due to an error action in a - later state. - */ - if (yytoken != yyempty_) - { - yyarg[yycount++] = yytname_[yytoken]; - int yyn = yypact_[yystate]; - if (!yy_pact_value_is_default_ (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = yylast_ - yyn + 1; - int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; - for (int yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_ - && !yy_table_value_is_error_ (yytable_[yyx + yyn])) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - break; - } - else - yyarg[yycount++] = yytname_[yyx]; - } - } - } - - char const* yyformat = YY_NULL; - switch (yycount) + std::string res; + YYUSE (yystate); +#if YYERROR_VERBOSE + int yyn = yypact_[yystate]; + if (yypact_ninf_ < yyn && yyn <= yylast_) { -#define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -#undef YYCASE_ + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = yylast_ - yyn + 1; + int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; + int count = 0; + for (int x = yyxbegin; x < yyxend; ++x) + if (yycheck_[x + yyn] == x && x != yyterror_) + ++count; + + // FIXME: This method of building the message is not compatible + // with internationalization. It should work like yacc.c does it. + // That is, first build a string that looks like this: + // "syntax error, unexpected %s or %s or %s" + // Then, invoke YY_ on this string. + // Finally, use the string as a format to output + // yytname_[tok], etc. + // Until this gets fixed, this message appears in English only. + res = "syntax error, unexpected "; + res += yytnamerr_ (yytname_[tok]); + if (count < 5) + { + count = 0; + for (int x = yyxbegin; x < yyxend; ++x) + if (yycheck_[x + yyn] == x && x != yyterror_) + { + res += (!count++) ? ", expecting " : " or "; + res += yytnamerr_ (yytname_[x]); + } + } } - - // Argument number. - size_t yyi = 0; - for (char const* yyp = yyformat; *yyp; ++yyp) - if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount) - { - yyres += yytnamerr_ (yyarg[yyi++]); - ++yyp; - } - else - yyres += *yyp; - return yyres; + else +#endif + res = YY_("syntax error"); + return res; } @@ -1292,9 +1241,9 @@ namespace lol { -71, -71, -71, -71 }; - /* YYDEFACT[S] -- default reduction number in state S. Performed when - YYTABLE doesn't specify something else to do. Zero means the - default is an error. */ + /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE + doesn't specify something else to do. Zero means the default is an + error. */ const unsigned char EasyMeshParser::yydefact_[] = { @@ -1336,7 +1285,7 @@ namespace lol { /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which - number is the opposite. If YYTABLE_NINF_, syntax error. */ + number is the opposite. If zero, do what YYDEFACT says. */ const signed char EasyMeshParser::yytable_ninf_ = -1; const unsigned char EasyMeshParser::yytable_[] = @@ -1476,7 +1425,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* @@ -1499,8 +1448,9 @@ 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", YY_NULL + "args10", "number", 0 }; +#endif #if YYDEBUG /* YYRHS -- A `-1'-separated list of the rules' RHS. */ @@ -1658,9 +1608,12 @@ namespace lol { } // lol -/* Line 1135 of lalr1.cc */ -#line 1663 "generated/easymesh-parser.cpp" -/* Line 1136 of lalr1.cc */ + +/* Line 1053 of lalr1.cc */ +#line 1614 "generated/easymesh-parser.cpp" + + +/* Line 1055 of lalr1.cc */ #line 217 "easymesh/easymesh-parser.y" @@ -1670,3 +1623,4 @@ 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 df43cdd2..0c3c3e00 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.7.12-4996. */ +/* A Bison parser, made by GNU Bison 2.4.2. */ /* Skeleton interface for Bison LALR(1) parsers in C++ - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2010 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,30 @@ 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 YY_LOL_GENERATED_EASYMESH_PARSER_H_INCLUDED -# define YY_LOL_GENERATED_EASYMESH_PARSER_H_INCLUDED +#ifndef PARSER_HEADER_H +# define PARSER_HEADER_H #include #include #include "stack.hh" + + +namespace lol { + +/* Line 34 of lalr1.cc */ +#line 49 "generated/easymesh-parser.h" + class position; + class location; + +} // lol + +/* Line 34 of lalr1.cc */ +#line 56 "generated/easymesh-parser.h" + #include "location.hh" /* Enabling traces. */ @@ -52,10 +61,43 @@ # 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 + +/* 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). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ +do { \ + if (N) \ + { \ + (Current).begin = (Rhs)[1].begin; \ + (Current).end = (Rhs)[N].end; \ + } \ + else \ + { \ + (Current).begin = (Current).end = (Rhs)[0].end; \ + } \ +} while (false) +#endif + namespace lol { -/* Line 33 of lalr1.cc */ -#line 59 "generated/easymesh-parser.h" + +/* Line 34 of lalr1.cc */ +#line 101 "generated/easymesh-parser.h" /// A Bison parser. class EasyMeshParser @@ -65,7 +107,8 @@ namespace lol { #ifndef YYSTYPE union semantic_type { -/* Line 33 of lalr1.cc */ + +/* Line 34 of lalr1.cc */ #line 35 "easymesh/easymesh-parser.y" float fval; @@ -74,8 +117,9 @@ namespace lol { struct { float f0, f1, f2, f3, f4, f5, f6, f7, f8, f9; } args; -/* Line 33 of lalr1.cc */ -#line 79 "generated/easymesh-parser.h" + +/* Line 34 of lalr1.cc */ +#line 123 "generated/easymesh-parser.h" }; #else typedef YYSTYPE semantic_type; @@ -177,10 +221,6 @@ 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. @@ -225,14 +265,6 @@ namespace lol { /// The location stack. location_stack_type yylocation_stack_; - /// Whether the given \c yypact_ value indicates a defaulted state. - /// \param yyvalue the value to check - static bool yy_pact_value_is_default_ (int yyvalue); - - /// Whether the given \c yytable_ value indicates a syntax error. - /// \param yyvalue the value to check - static bool yy_table_value_is_error_ (int yyvalue); - /// Internal symbol numbers. typedef unsigned char token_number_type; /* Tables. */ @@ -240,7 +272,7 @@ namespace lol { static const signed char yypact_[]; static const signed char yypact_ninf_; - /// For a state, default reduction number. + /// For a state, default rule to reduce. /// Unless\a yytable_ specifies something else to do. /// Zero means the default is an error. static const unsigned char yydefact_[]; @@ -264,14 +296,18 @@ namespace lol { /// For a rule, its LHS. static const unsigned char yyr1_[]; /// For a rule, its RHS length. - 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); - + static const unsigned char yyr2_[]; +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /// For a symbol, its name in clear. static const char* const yytname_[]; +#endif + +#if YYERROR_VERBOSE + /// Convert the symbol name \a n to a form suitable for a diagnostic. + virtual std::string yytnamerr_ (const char *n); +#endif + #if YYDEBUG /// A type to store symbol numbers and -1. typedef signed char rhs_number_type; @@ -298,7 +334,6 @@ 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. @@ -328,9 +363,10 @@ namespace lol { }; } // lol -/* Line 33 of lalr1.cc */ -#line 333 "generated/easymesh-parser.h" + +/* Line 34 of lalr1.cc */ +#line 369 "generated/easymesh-parser.h" -#endif /* !YY_LOL_GENERATED_EASYMESH_PARSER_H_INCLUDED */ +#endif /* ! defined PARSER_HEADER_H */ diff --git a/src/generated/location.hh b/src/generated/location.hh index 442725b4..0b3d1b94 100644 --- a/src/generated/location.hh +++ b/src/generated/location.hh @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.7.12-4996. */ +/* A Bison parser, made by GNU Bison 2.4.2. */ /* Locations for Bison parsers in C++ - Copyright (C) 2002-2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2007, 2009-2010 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,55 +31,39 @@ version 2.2 of Bison. */ /** - ** \file generated/location.hh + ** \file location.hh ** Define the lol::location class. */ -#ifndef YY_LOL_GENERATED_LOCATION_HH_INCLUDED -# define YY_LOL_GENERATED_LOCATION_HH_INCLUDED +#ifndef BISON_LOCATION_HH +# define BISON_LOCATION_HH +# include +# include # include "position.hh" namespace lol { -/* Line 166 of location.cc */ -#line 47 "generated/location.hh" + +/* Line 162 of location.cc */ +#line 50 "generated/location.hh" /// Abstract a location. class location { public: - /// 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) + /// Construct a location. + location () + : begin (), end () { } /// Initialization. - void initialize (std::string* f = YY_NULL, - unsigned int l = 1u, - unsigned int c = 1u) + inline void initialize (std::string* fn) { - begin.initialize (f, l, c); + begin.initialize (fn); end = begin; } @@ -87,19 +71,19 @@ namespace lol { ** \{ */ public: /// Reset initial location to final location. - void step () + inline void step () { begin = end; } /// Extend the current location to the COUNT next columns. - void columns (unsigned int count = 1) + inline void columns (unsigned int count = 1) { end += count; } /// Extend the current location to the COUNT next lines. - void lines (unsigned int count = 1) + inline void lines (unsigned int count = 1) { end.lines (count); } @@ -156,9 +140,7 @@ namespace lol { ** ** Avoid duplicate information. */ - template - inline std::basic_ostream& - operator<< (std::basic_ostream& ostr, const location& loc) + inline std::ostream& operator<< (std::ostream& ostr, const location& loc) { position last = loc.end - 1; ostr << loc.begin; @@ -175,7 +157,8 @@ namespace lol { } // lol -/* Line 296 of location.cc */ -#line 180 "generated/location.hh" -#endif /* !YY_LOL_GENERATED_LOCATION_HH_INCLUDED */ +/* Line 271 of location.cc */ +#line 163 "generated/location.hh" + +#endif // not BISON_LOCATION_HH diff --git a/src/generated/lolfx-parser.cpp b/src/generated/lolfx-parser.cpp index 3d137284..20a5ce8c 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.7.12-4996. */ +/* A Bison parser, made by GNU Bison 2.4.2. */ /* Skeleton implementation for Bison LALR(1) parsers in C++ - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2010 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,7 +34,8 @@ #define yylex lollex /* First part of user declarations. */ -/* Line 283 of lalr1.cc */ + +/* Line 310 of lalr1.cc */ #line 1 "gpu/lolfx-parser.y" // @@ -56,14 +57,16 @@ #include -/* Line 283 of lalr1.cc */ -#line 61 "generated/lolfx-parser.cpp" + +/* Line 310 of lalr1.cc */ +#line 63 "generated/lolfx-parser.cpp" #include "lolfx-parser.h" /* User implementation prologue. */ -/* Line 289 of lalr1.cc */ + +/* Line 316 of lalr1.cc */ #line 241 "gpu/lolfx-parser.y" #include "gpu/lolfx-compiler.h" @@ -76,17 +79,9 @@ #define catch(...) if (false) #define throw (void)0 -/* Line 289 of lalr1.cc */ -#line 81 "generated/lolfx-parser.cpp" - -# ifndef YY_NULL -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULL nullptr -# else -# define YY_NULL 0 -# endif -# endif +/* Line 316 of lalr1.cc */ +#line 85 "generated/lolfx-parser.cpp" #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS @@ -100,27 +95,6 @@ # 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). */ - -# 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)) @@ -155,9 +129,9 @@ do { \ #else /* !YYDEBUG */ # define YYCDEBUG if (false) std::cerr -# 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) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_REDUCE_PRINT(Rule) +# define YY_STACK_PRINT() #endif /* !YYDEBUG */ @@ -171,8 +145,10 @@ do { \ namespace lol { -/* Line 357 of lalr1.cc */ -#line 176 "generated/lolfx-parser.cpp" + +/* Line 379 of lalr1.cc */ +#line 151 "generated/lolfx-parser.cpp" +#if YYERROR_VERBOSE /* Return YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is @@ -211,6 +187,7 @@ namespace lol { return yystr; } +#endif /// Build a parser object. LolFxParser::LolFxParser (class LolFxCompiler& mc_yyarg) @@ -238,10 +215,11 @@ namespace lol { { YYUSE (yylocationp); YYUSE (yyvaluep); - std::ostream& yyo = debug_stream (); - std::ostream& yyoutput = yyo; - YYUSE (yyoutput); - YYUSE (yytype); + switch (yytype) + { + default: + break; + } } @@ -265,10 +243,14 @@ namespace lol { YYUSE (yymsg); YYUSE (yyvaluep); - if (yymsg) - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - YYUSE (yytype); + switch (yytype) + { + + default: + break; + } } void @@ -306,18 +288,6 @@ namespace lol { } #endif - inline bool - LolFxParser::yy_pact_value_is_default_ (int yyvalue) - { - return yyvalue == yypact_ninf_; - } - - inline bool - LolFxParser::yy_table_value_is_error_ (int yyvalue) - { - return yyvalue == yytable_ninf_; - } - int LolFxParser::parse () { @@ -325,22 +295,21 @@ 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. - static semantic_type yyval_default; - semantic_type yylval = yyval_default; + semantic_type yylval; /// Location of the lookahead. location_type yylloc; /// The locations where the error started and ended. - location_type yyerror_range[3]; + location_type yyerror_range[2]; /// $$. semantic_type yyval; @@ -349,10 +318,6 @@ 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; @@ -360,9 +325,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_.clear (); - yysemantic_stack_.clear (); - yylocation_stack_.clear (); + yystate_stack_ = state_stack_type (0); + yysemantic_stack_ = semantic_stack_type (0); + yylocation_stack_ = location_stack_type (0); yysemantic_stack_.push (yylval); yylocation_stack_.push (yylloc); @@ -382,16 +347,17 @@ namespace lol { /* Try to take a decision without lookahead. */ yyn = yypact_[yystate]; - if (yy_pact_value_is_default_ (yyn)) + if (yyn == yypact_ninf_) goto yydefault; /* 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_) { @@ -414,8 +380,8 @@ namespace lol { yyn = yytable_[yyn]; if (yyn <= 0) { - if (yy_table_value_is_error_ (yyn)) - goto yyerrlab; + if (yyn == 0 || yyn == yytable_ninf_) + goto yyerrlab; yyn = -yyn; goto yyreduce; } @@ -462,64 +428,55 @@ 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 206: -/* Line 664 of lalr1.cc */ + case 206: + +/* Line 677 of lalr1.cc */ #line 734 "gpu/lolfx-parser.y" { std::cout << "New tech " << std::endl; } break; case 207: -/* Line 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 742 "gpu/lolfx-parser.y" { std::cout << "New name " << (yysemantic_stack_[(1) - (1)].sval) << std::endl; } break; case 208: -/* Line 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 743 "gpu/lolfx-parser.y" { std::cout << "New name " << (yysemantic_stack_[(1) - (1)].sval) << std::endl; } break; case 211: -/* Line 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 756 "gpu/lolfx-parser.y" { std::cout << "New pass " << std::endl; } break; case 230: -/* Line 664 of lalr1.cc */ + +/* Line 677 of lalr1.cc */ #line 792 "gpu/lolfx-parser.y" { std::cout << "new shader" << std::endl; } break; -/* Line 664 of lalr1.cc */ -#line 508 "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. - One alternative is translating here after every semantic action, - but that translation would be missed if the semantic action - invokes YYABORT, YYACCEPT, or YYERROR immediately after altering - yychar. In the case of YYABORT or YYACCEPT, an incorrect - destructor might then be invoked immediately. In the case of - YYERROR, subsequent parser actions might lead to an incorrect - destructor call or verbose syntax error message before the - lookahead is translated. */ +/* Line 677 of lalr1.cc */ +#line 477 "generated/lolfx-parser.cpp" + default: + break; + } YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc); yypop_ (yylen); @@ -543,35 +500,30 @@ namespace lol { | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = yytranslate_ (yychar); - /* If not already recovering from an error, report this error. */ if (!yyerrstatus_) { ++yynerrs_; - if (yychar == yyempty_) - yytoken = yyempty_; error (yylloc, yysyntax_error_ (yystate, yytoken)); } - yyerror_range[1] = yylloc; + yyerror_range[0] = 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 @@ -590,7 +542,7 @@ namespace lol { if (false) goto yyerrorlab; - yyerror_range[1] = yylocation_stack_[yylen - 1]; + yyerror_range[0] = yylocation_stack_[yylen - 1]; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ yypop_ (yylen); @@ -607,7 +559,7 @@ namespace lol { for (;;) { yyn = yypact_[yystate]; - if (!yy_pact_value_is_default_ (yyn)) + if (yyn != yypact_ninf_) { yyn += yyterror_; if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) @@ -620,9 +572,9 @@ 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]; + yyerror_range[0] = yylocation_stack_[0]; yydestruct_ ("Error: popping", yystos_[yystate], &yysemantic_stack_[0], &yylocation_stack_[0]); @@ -631,10 +583,10 @@ namespace lol { YY_STACK_PRINT (); } - yyerror_range[2] = yylloc; + yyerror_range[1] = yylloc; // Using YYLLOC is tempting, but would change the location of // the lookahead. YYLOC is available though. - YYLLOC_DEFAULT (yyloc, yyerror_range, 2); + YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); yysemantic_stack_.push (yylval); yylocation_stack_.push (yyloc); @@ -657,148 +609,70 @@ namespace lol { yyreturn: 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_ ("Cleanup: discarding lookahead", yytoken, &yylval, - &yylloc); - } + yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ yypop_ (yylen); - while (1 < yystate_stack_.height ()) + while (yystate_stack_.height () != 1) { - 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. std::string - LolFxParser::yysyntax_error_ (int yystate, int yytoken) + LolFxParser::yysyntax_error_ (int yystate, int tok) { - std::string yyres; - // Number of reported tokens (one for the "unexpected", one per - // "expected"). - size_t yycount = 0; - // Its maximum. - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - // Arguments of yyformat. - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - - /* There are many possibilities here to consider: - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yytoken) is - if this state is a consistent state with a default action. - Thus, detecting the absence of a lookahead is sufficient to - determine that there is no unexpected or expected token to - report. In that case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is - a consistent state with a default action. There might have - been a previous inconsistent state, consistent state with a - non-default action, or user semantic action that manipulated - yychar. - - Of course, the expected token list depends on states to have - correct lookahead information, and it depends on the parser not - to perform extra reductions after fetching a lookahead from the - scanner and before detecting a syntax error. Thus, state - merging (from LALR or IELR) and default reductions corrupt the - expected token list. However, the list is correct for - canonical LR with one exception: it will still contain any - token that will not be accepted due to an error action in a - later state. - */ - if (yytoken != yyempty_) - { - yyarg[yycount++] = yytname_[yytoken]; - int yyn = yypact_[yystate]; - if (!yy_pact_value_is_default_ (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = yylast_ - yyn + 1; - int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; - for (int yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_ - && !yy_table_value_is_error_ (yytable_[yyx + yyn])) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - break; - } - else - yyarg[yycount++] = yytname_[yyx]; - } - } - } - - char const* yyformat = YY_NULL; - switch (yycount) + std::string res; + YYUSE (yystate); +#if YYERROR_VERBOSE + int yyn = yypact_[yystate]; + if (yypact_ninf_ < yyn && yyn <= yylast_) { -#define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -#undef YYCASE_ + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = yylast_ - yyn + 1; + int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; + int count = 0; + for (int x = yyxbegin; x < yyxend; ++x) + if (yycheck_[x + yyn] == x && x != yyterror_) + ++count; + + // FIXME: This method of building the message is not compatible + // with internationalization. It should work like yacc.c does it. + // That is, first build a string that looks like this: + // "syntax error, unexpected %s or %s or %s" + // Then, invoke YY_ on this string. + // Finally, use the string as a format to output + // yytname_[tok], etc. + // Until this gets fixed, this message appears in English only. + res = "syntax error, unexpected "; + res += yytnamerr_ (yytname_[tok]); + if (count < 5) + { + count = 0; + for (int x = yyxbegin; x < yyxend; ++x) + if (yycheck_[x + yyn] == x && x != yyterror_) + { + res += (!count++) ? ", expecting " : " or "; + res += yytnamerr_ (yytname_[x]); + } + } } - - // Argument number. - size_t yyi = 0; - for (char const* yyp = yyformat; *yyp; ++yyp) - if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount) - { - yyres += yytnamerr_ (yyarg[yyi++]); - ++yyp; - } - else - yyres += *yyp; - return yyres; + else +#endif + res = YY_("syntax error"); + return res; } @@ -877,9 +751,9 @@ namespace lol { 23, -557, -73, -70, -69, -68, -557, -557, -557, -557 }; - /* YYDEFACT[S] -- default reduction number in state S. Performed when - YYTABLE doesn't specify something else to do. Zero means the - default is an error. */ + /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE + doesn't specify something else to do. Zero means the default is an + error. */ const unsigned short int LolFxParser::yydefact_[] = { @@ -986,7 +860,7 @@ namespace lol { /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which - number is the opposite. If YYTABLE_NINF_, syntax error. */ + number is the opposite. If zero, do what YYDEFACT says. */ const short int LolFxParser::yytable_ninf_ = -327; const short int LolFxParser::yytable_[] = @@ -3487,7 +3361,7 @@ namespace lol { 2, 2, 3, 2, 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* @@ -3640,8 +3514,9 @@ 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", YY_NULL + "glsl_function_definition", 0 }; +#endif #if YYDEBUG /* YYRHS -- A `-1'-separated list of the rules' RHS. */ @@ -4017,9 +3892,12 @@ namespace lol { } // lol -/* Line 1135 of lalr1.cc */ -#line 4022 "generated/lolfx-parser.cpp" -/* Line 1136 of lalr1.cc */ + +/* Line 1053 of lalr1.cc */ +#line 3898 "generated/lolfx-parser.cpp" + + +/* Line 1055 of lalr1.cc */ #line 1304 "gpu/lolfx-parser.y" @@ -4029,3 +3907,4 @@ 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 ca4c9da2..f4119960 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.7.12-4996. */ +/* A Bison parser, made by GNU Bison 2.4.2. */ /* Skeleton interface for Bison LALR(1) parsers in C++ - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2010 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,30 @@ 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 YY_LOL_GENERATED_LOLFX_PARSER_H_INCLUDED -# define YY_LOL_GENERATED_LOLFX_PARSER_H_INCLUDED +#ifndef PARSER_HEADER_H +# define PARSER_HEADER_H #include #include #include "stack.hh" + + +namespace lol { + +/* Line 34 of lalr1.cc */ +#line 49 "generated/lolfx-parser.h" + class position; + class location; + +} // lol + +/* Line 34 of lalr1.cc */ +#line 56 "generated/lolfx-parser.h" + #include "location.hh" /* Enabling traces. */ @@ -52,10 +61,43 @@ # 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 + +/* 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). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ +do { \ + if (N) \ + { \ + (Current).begin = (Rhs)[1].begin; \ + (Current).end = (Rhs)[N].end; \ + } \ + else \ + { \ + (Current).begin = (Current).end = (Rhs)[0].end; \ + } \ +} while (false) +#endif + namespace lol { -/* Line 33 of lalr1.cc */ -#line 59 "generated/lolfx-parser.h" + +/* Line 34 of lalr1.cc */ +#line 101 "generated/lolfx-parser.h" /// A Bison parser. class LolFxParser @@ -65,7 +107,8 @@ namespace lol { #ifndef YYSTYPE union semantic_type { -/* Line 33 of lalr1.cc */ + +/* Line 34 of lalr1.cc */ #line 34 "gpu/lolfx-parser.y" int ival; @@ -74,8 +117,9 @@ namespace lol { char *sval; -/* Line 33 of lalr1.cc */ -#line 79 "generated/lolfx-parser.h" + +/* Line 34 of lalr1.cc */ +#line 123 "generated/lolfx-parser.h" }; #else typedef YYSTYPE semantic_type; @@ -552,10 +596,6 @@ 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. @@ -600,14 +640,6 @@ namespace lol { /// The location stack. location_stack_type yylocation_stack_; - /// Whether the given \c yypact_ value indicates a defaulted state. - /// \param yyvalue the value to check - static bool yy_pact_value_is_default_ (int yyvalue); - - /// Whether the given \c yytable_ value indicates a syntax error. - /// \param yyvalue the value to check - static bool yy_table_value_is_error_ (int yyvalue); - /// Internal symbol numbers. typedef unsigned short int token_number_type; /* Tables. */ @@ -615,7 +647,7 @@ namespace lol { static const short int yypact_[]; static const short int yypact_ninf_; - /// For a state, default reduction number. + /// For a state, default rule to reduce. /// Unless\a yytable_ specifies something else to do. /// Zero means the default is an error. static const unsigned short int yydefact_[]; @@ -639,14 +671,18 @@ namespace lol { /// For a rule, its LHS. static const unsigned short int yyr1_[]; /// For a rule, its RHS length. - 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); - + static const unsigned char yyr2_[]; +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /// For a symbol, its name in clear. static const char* const yytname_[]; +#endif + +#if YYERROR_VERBOSE + /// Convert the symbol name \a n to a form suitable for a diagnostic. + virtual std::string yytnamerr_ (const char *n); +#endif + #if YYDEBUG /// A type to store symbol numbers and -1. typedef short int rhs_number_type; @@ -673,7 +709,6 @@ 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. @@ -703,9 +738,10 @@ namespace lol { }; } // lol -/* Line 33 of lalr1.cc */ -#line 708 "generated/lolfx-parser.h" + +/* Line 34 of lalr1.cc */ +#line 744 "generated/lolfx-parser.h" -#endif /* !YY_LOL_GENERATED_LOLFX_PARSER_H_INCLUDED */ +#endif /* ! defined PARSER_HEADER_H */ diff --git a/src/generated/position.hh b/src/generated/position.hh index c30401ac..984c21a6 100644 --- a/src/generated/position.hh +++ b/src/generated/position.hh @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.7.12-4996. */ +/* A Bison parser, made by GNU Bison 2.4.2. */ /* Positions for Bison parsers in C++ - Copyright (C) 2002-2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2007, 2009-2010 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,71 +31,60 @@ version 2.2 of Bison. */ /** - ** \file generated/position.hh + ** \file position.hh ** Define the lol::position class. */ -#ifndef YY_LOL_GENERATED_POSITION_HH_INCLUDED -# define YY_LOL_GENERATED_POSITION_HH_INCLUDED +#ifndef BISON_POSITION_HH +# define BISON_POSITION_HH -# include // std::max # include # include - -# ifndef YY_NULL -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULL nullptr -# else -# define YY_NULL 0 -# endif -# endif +# include namespace lol { -/* Line 36 of location.cc */ -#line 57 "generated/position.hh" + +/* Line 37 of location.cc */ +#line 50 "generated/position.hh" /// Abstract a position. class position { public: /// Construct a position. - explicit position (std::string* f = YY_NULL, - unsigned int l = 1u, - unsigned int c = 1u) - : filename (f) - , line (l) - , column (c) + position () + : filename (0), line (1), column (1) { } /// Initialization. - void initialize (std::string* fn = YY_NULL, - unsigned int l = 1u, - unsigned int c = 1u) + inline void initialize (std::string* fn) { filename = fn; - line = l; - column = c; + line = 1; + column = 1; } /** \name Line and Column related manipulators ** \{ */ + public: /// (line related) Advance to the COUNT next lines. - void lines (int count = 1) + inline void lines (int count = 1) { - column = 1u; + column = 1; line += count; } /// (column related) Advance to the COUNT next columns. - void columns (int count = 1) + inline 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. @@ -105,7 +94,7 @@ namespace lol { }; /// Add and assign a position. - inline position& + inline const position& operator+= (position& res, const int width) { res.columns (width); @@ -121,7 +110,7 @@ namespace lol { } /// Add and assign a position. - inline position& + inline const position& operator-= (position& res, const int width) { return res += -width; @@ -156,9 +145,8 @@ namespace lol { ** \param ostr the destination output stream ** \param pos a reference to the position to redirect */ - template - inline std::basic_ostream& - operator<< (std::basic_ostream& ostr, const position& pos) + inline std::ostream& + operator<< (std::ostream& ostr, const position& pos) { if (pos.filename) ostr << *pos.filename << ':'; @@ -167,6 +155,7 @@ namespace lol { } // lol -/* Line 148 of location.cc */ -#line 172 "generated/position.hh" -#endif /* !YY_LOL_GENERATED_POSITION_HH_INCLUDED */ + +/* Line 144 of location.cc */ +#line 161 "generated/position.hh" +#endif // not BISON_POSITION_HH diff --git a/src/generated/stack.hh b/src/generated/stack.hh index df42446e..cf73da80 100644 --- a/src/generated/stack.hh +++ b/src/generated/stack.hh @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.7.12-4996. */ +/* A Bison parser, made by GNU Bison 2.4.2. */ /* Stack handling for Bison parsers in C++ - Copyright (C) 2002-2013 Free Software Foundation, Inc. + Copyright (C) 2002-2010 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,24 +30,21 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ -/** - ** \file generated/stack.hh - ** Define the lol::stack class. - */ +#ifndef BISON_STACK_HH +# define BISON_STACK_HH -#ifndef YY_LOL_GENERATED_STACK_HH_INCLUDED -# define YY_LOL_GENERATED_STACK_HH_INCLUDED - -# include +#include namespace lol { -/* Line 34 of stack.hh */ -#line 47 "generated/stack.hh" + +/* Line 1066 of lalr1.cc */ +#line 43 "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; @@ -86,13 +83,7 @@ namespace lol { pop (unsigned int n = 1) { for (; n; --n) - seq_.pop_front (); - } - - void - clear () - { - seq_.clear (); + seq_.pop_front (); } inline @@ -106,8 +97,7 @@ namespace lol { inline const_iterator end () const { return seq_.rend (); } private: - stack (const stack&); - stack& operator= (const stack&); + S seq_; }; @@ -116,9 +106,10 @@ 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) { } @@ -130,12 +121,15 @@ namespace lol { } private: + const S& stack_; unsigned int range_; }; } // lol -/* Line 124 of stack.hh */ -#line 140 "generated/stack.hh" -#endif /* !YY_LOL_GENERATED_STACK_HH_INCLUDED */ +/* Line 1152 of lalr1.cc */ +#line 133 "generated/stack.hh" + +#endif // not BISON_STACK_HH[]dnl +