Browse Source

URO : Added URO parser/scanner etc for custom command setup.

EzMesh : parser/scanner regen (with older bison cause windows).
undefined
Benjamin ‘Touky’ Huet Sam Hocevar <sam@hocevar.net> 11 years ago
parent
commit
78c949b2d5
7 changed files with 653 additions and 782 deletions
  1. +294
    -340
      src/generated/easymesh-parser.cpp
  2. +72
    -36
      src/generated/easymesh-parser.h
  3. +23
    -40
      src/generated/location.hh
  4. +144
    -265
      src/generated/lolfx-parser.cpp
  5. +72
    -36
      src/generated/lolfx-parser.h
  6. +27
    -38
      src/generated/position.hh
  7. +21
    -27
      src/generated/stack.hh

+ 294
- 340
src/generated/easymesh-parser.cpp
File diff suppressed because it is too large
View File


+ 72
- 36
src/generated/easymesh-parser.h View File

@@ -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 <string>
#include <iostream>
#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 */

+ 23
- 40
src/generated/location.hh View File

@@ -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 <iostream>
# include <string>
# 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 <typename YYChar>
inline std::basic_ostream<YYChar>&
operator<< (std::basic_ostream<YYChar>& 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

+ 144
- 265
src/generated/lolfx-parser.cpp View File

@@ -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 <string>


/* 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<void>(0)
# define YY_STACK_PRINT() static_cast<void>(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<location_type, location_stack_type> 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);
}



+ 72
- 36
src/generated/lolfx-parser.h View File

@@ -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 <string>
#include <iostream>
#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 */

+ 27
- 38
src/generated/position.hh View File

@@ -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 <algorithm> // std::max
# include <iostream>
# include <string>

# ifndef YY_NULL
# if defined __cplusplus && 201103L <= __cplusplus
# define YY_NULL nullptr
# else
# define YY_NULL 0
# endif
# endif
# include <algorithm>


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 <typename YYChar>
inline std::basic_ostream<YYChar>&
operator<< (std::basic_ostream<YYChar>& 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

+ 21
- 27
src/generated/stack.hh View File

@@ -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 <deque>
#include <deque>


namespace lol {
/* Line 34 of stack.hh */
#line 47 "generated/stack.hh"

/* Line 1066 of lalr1.cc */
#line 43 "generated/stack.hh"
template <class T, class S = std::deque<T> >
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


Loading…
Cancel
Save