v4 parser:
* removed files generated by Flex and Bison from SVN * adapted Makefiles accordingly git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1676 ac1d8469-bf42-47a9-8791-bf33cf982152time-shift
parent
e1238b58d6
commit
90cfdee350
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,205 +0,0 @@
|
||||||
|
|
||||||
// -*-C++-*-
|
|
||||||
// FlexLexer.h -- define interfaces for lexical analyzer classes generated
|
|
||||||
// by flex
|
|
||||||
|
|
||||||
// Copyright (c) 1993 The Regents of the University of California.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// This code is derived from software contributed to Berkeley by
|
|
||||||
// Kent Williams and Tom Epperly.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions
|
|
||||||
// are met:
|
|
||||||
|
|
||||||
// 1. Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer in the
|
|
||||||
// documentation and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
// Neither the name of the University nor the names of its contributors
|
|
||||||
// may be used to endorse or promote products derived from this software
|
|
||||||
// without specific prior written permission.
|
|
||||||
|
|
||||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
|
||||||
// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
||||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
// PURPOSE.
|
|
||||||
|
|
||||||
// This file defines FlexLexer, an abstract class which specifies the
|
|
||||||
// external interface provided to flex C++ lexer objects, and yyFlexLexer,
|
|
||||||
// which defines a particular lexer class.
|
|
||||||
//
|
|
||||||
// If you want to create multiple lexer classes, you use the -P flag
|
|
||||||
// to rename each yyFlexLexer to some other xxFlexLexer. You then
|
|
||||||
// include <FlexLexer.h> in your other sources once per lexer class:
|
|
||||||
//
|
|
||||||
// #undef yyFlexLexer
|
|
||||||
// #define yyFlexLexer xxFlexLexer
|
|
||||||
// #include <FlexLexer.h>
|
|
||||||
//
|
|
||||||
// #undef yyFlexLexer
|
|
||||||
// #define yyFlexLexer zzFlexLexer
|
|
||||||
// #include <FlexLexer.h>
|
|
||||||
// ...
|
|
||||||
|
|
||||||
#ifndef __FLEX_LEXER_H
|
|
||||||
// Never included before - need to define base class.
|
|
||||||
#define __FLEX_LEXER_H
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
# ifndef FLEX_STD
|
|
||||||
# define FLEX_STD std::
|
|
||||||
# endif
|
|
||||||
|
|
||||||
extern "C++" {
|
|
||||||
|
|
||||||
struct yy_buffer_state;
|
|
||||||
typedef int yy_state_type;
|
|
||||||
|
|
||||||
class FlexLexer {
|
|
||||||
public:
|
|
||||||
virtual ~FlexLexer() { }
|
|
||||||
|
|
||||||
const char* YYText() const { return yytext; }
|
|
||||||
int YYLeng() const { return yyleng; }
|
|
||||||
|
|
||||||
virtual void
|
|
||||||
yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0;
|
|
||||||
virtual struct yy_buffer_state*
|
|
||||||
yy_create_buffer( FLEX_STD istream* s, int size ) = 0;
|
|
||||||
virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
|
|
||||||
virtual void yyrestart( FLEX_STD istream* s ) = 0;
|
|
||||||
|
|
||||||
virtual int yylex() = 0;
|
|
||||||
|
|
||||||
// Call yylex with new input/output sources.
|
|
||||||
int yylex( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 )
|
|
||||||
{
|
|
||||||
switch_streams( new_in, new_out );
|
|
||||||
return yylex();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Switch to new input/output streams. A nil stream pointer
|
|
||||||
// indicates "keep the current one".
|
|
||||||
virtual void switch_streams( FLEX_STD istream* new_in = 0,
|
|
||||||
FLEX_STD ostream* new_out = 0 ) = 0;
|
|
||||||
|
|
||||||
int lineno() const { return yylineno; }
|
|
||||||
|
|
||||||
int debug() const { return yy_flex_debug; }
|
|
||||||
void set_debug( int flag ) { yy_flex_debug = flag; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
char* yytext;
|
|
||||||
int yyleng;
|
|
||||||
int yylineno; // only maintained if you use %option yylineno
|
|
||||||
int yy_flex_debug; // only has effect with -d or "%option debug"
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)
|
|
||||||
// Either this is the first time through (yyFlexLexerOnce not defined),
|
|
||||||
// or this is a repeated include to define a different flavor of
|
|
||||||
// yyFlexLexer, as discussed in the flex man page.
|
|
||||||
#define yyFlexLexerOnce
|
|
||||||
|
|
||||||
extern "C++" {
|
|
||||||
|
|
||||||
class yyFlexLexer : public FlexLexer {
|
|
||||||
public:
|
|
||||||
// arg_yyin and arg_yyout default to the cin and cout, but we
|
|
||||||
// only make that assignment when initializing in yylex().
|
|
||||||
yyFlexLexer( FLEX_STD istream* arg_yyin = 0, FLEX_STD ostream* arg_yyout = 0 );
|
|
||||||
|
|
||||||
virtual ~yyFlexLexer();
|
|
||||||
|
|
||||||
void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );
|
|
||||||
struct yy_buffer_state* yy_create_buffer( FLEX_STD istream* s, int size );
|
|
||||||
void yy_delete_buffer( struct yy_buffer_state* b );
|
|
||||||
void yyrestart( FLEX_STD istream* s );
|
|
||||||
|
|
||||||
void yypush_buffer_state( struct yy_buffer_state* new_buffer );
|
|
||||||
void yypop_buffer_state(void);
|
|
||||||
|
|
||||||
virtual int yylex();
|
|
||||||
virtual void switch_streams( FLEX_STD istream* new_in, FLEX_STD ostream* new_out );
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual int LexerInput( char* buf, int max_size );
|
|
||||||
virtual void LexerOutput( const char* buf, int size );
|
|
||||||
virtual void LexerError( const char* msg );
|
|
||||||
|
|
||||||
void yyunput( int c, char* buf_ptr );
|
|
||||||
int yyinput();
|
|
||||||
|
|
||||||
void yy_load_buffer_state();
|
|
||||||
void yy_init_buffer( struct yy_buffer_state* b, FLEX_STD istream* s );
|
|
||||||
void yy_flush_buffer( struct yy_buffer_state* b );
|
|
||||||
|
|
||||||
int yy_start_stack_ptr;
|
|
||||||
int yy_start_stack_depth;
|
|
||||||
int* yy_start_stack;
|
|
||||||
|
|
||||||
void yy_push_state( int new_state );
|
|
||||||
void yy_pop_state();
|
|
||||||
int yy_top_state();
|
|
||||||
|
|
||||||
yy_state_type yy_get_previous_state();
|
|
||||||
yy_state_type yy_try_NUL_trans( yy_state_type current_state );
|
|
||||||
int yy_get_next_buffer();
|
|
||||||
|
|
||||||
FLEX_STD istream* yyin; // input source for default LexerInput
|
|
||||||
FLEX_STD ostream* yyout; // output sink for default LexerOutput
|
|
||||||
|
|
||||||
// yy_hold_char holds the character lost when yytext is formed.
|
|
||||||
char yy_hold_char;
|
|
||||||
|
|
||||||
// Number of characters read into yy_ch_buf.
|
|
||||||
int yy_n_chars;
|
|
||||||
|
|
||||||
// Points to current character in buffer.
|
|
||||||
char* yy_c_buf_p;
|
|
||||||
|
|
||||||
int yy_init; // whether we need to initialize
|
|
||||||
int yy_start; // start state number
|
|
||||||
|
|
||||||
// Flag which is used to allow yywrap()'s to do buffer switches
|
|
||||||
// instead of setting up a fresh yyin. A bit of a hack ...
|
|
||||||
int yy_did_buffer_switch_on_eof;
|
|
||||||
|
|
||||||
|
|
||||||
size_t yy_buffer_stack_top; /**< index of top of stack. */
|
|
||||||
size_t yy_buffer_stack_max; /**< capacity of stack. */
|
|
||||||
struct yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */
|
|
||||||
void yyensure_buffer_stack(void);
|
|
||||||
|
|
||||||
// The following are not always needed, but may be depending
|
|
||||||
// on use of certain flex features (like REJECT or yymore()).
|
|
||||||
|
|
||||||
yy_state_type yy_last_accepting_state;
|
|
||||||
char* yy_last_accepting_cpos;
|
|
||||||
|
|
||||||
yy_state_type* yy_state_buf;
|
|
||||||
yy_state_type* yy_state_ptr;
|
|
||||||
|
|
||||||
char* yy_full_match;
|
|
||||||
int* yy_full_state;
|
|
||||||
int yy_full_lp;
|
|
||||||
|
|
||||||
int yy_lp;
|
|
||||||
int yy_looking_for_trail_begin;
|
|
||||||
|
|
||||||
int yy_more_flag;
|
|
||||||
int yy_more_len;
|
|
||||||
int yy_more_offset;
|
|
||||||
int yy_prev_more_offset;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -76,22 +76,17 @@ DynareBison.cc include/DynareBison.hh: DynareBison.yy include/ParsingDriver.hh
|
||||||
clean: clean-recursive
|
clean: clean-recursive
|
||||||
rm -f *.o *.P \
|
rm -f *.o *.P \
|
||||||
*~ include/*~ \
|
*~ include/*~ \
|
||||||
DynareBison.output \
|
|
||||||
DynareFlex.cc \
|
DynareFlex.cc \
|
||||||
|
DynareBison.output \
|
||||||
|
DynareBison.cc \
|
||||||
|
include/position.hh \
|
||||||
|
include/stack.hh \
|
||||||
|
include/location.hh \
|
||||||
|
include/DynareBison.hh \
|
||||||
$(DYNARE_M) \
|
$(DYNARE_M) \
|
||||||
$(DYNARE_S)
|
$(DYNARE_S)
|
||||||
|
|
||||||
clean-recursive:
|
clean-recursive:
|
||||||
make -C macro clean
|
make -C macro clean
|
||||||
|
|
||||||
distclean: clean distclean-recursive
|
.PHONY: all all-recursive clean clean-recursive
|
||||||
rm -f DynareBison.cc \
|
|
||||||
include/position.hh \
|
|
||||||
include/stack.hh \
|
|
||||||
include/location.hh \
|
|
||||||
include/DynareBison.hh
|
|
||||||
|
|
||||||
distclean-recursive:
|
|
||||||
make -C macro distclean
|
|
||||||
|
|
||||||
.PHONY: all all-recursive clean clean-recursive distclean distclean-recursive
|
|
||||||
|
|
|
@ -1,526 +0,0 @@
|
||||||
/* A Bison parser, made by GNU Bison 2.3. */
|
|
||||||
|
|
||||||
/* Skeleton interface for Bison LALR(1) parsers in C++
|
|
||||||
|
|
||||||
Copyright (C) 2002, 2003, 2004, 2005, 2006 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
|
|
||||||
the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA. */
|
|
||||||
|
|
||||||
/* As a special exception, you may create a larger work that contains
|
|
||||||
part or all of the Bison parser skeleton and distribute that work
|
|
||||||
under terms of your choice, so long as that work isn't itself a
|
|
||||||
parser generator using the skeleton or a modified version thereof
|
|
||||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
|
||||||
the parser skeleton itself, you may (at your option) remove this
|
|
||||||
special exception, which will cause the skeleton and the resulting
|
|
||||||
Bison output files to be licensed under the GNU General Public
|
|
||||||
License without this special exception.
|
|
||||||
|
|
||||||
This special exception was added by the Free Software Foundation in
|
|
||||||
version 2.2 of Bison. */
|
|
||||||
|
|
||||||
/* C++ LALR(1) parser skeleton written by Akim Demaille. */
|
|
||||||
|
|
||||||
#ifndef PARSER_HEADER_H
|
|
||||||
# define PARSER_HEADER_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
#include "stack.hh"
|
|
||||||
|
|
||||||
namespace Dynare
|
|
||||||
{
|
|
||||||
class position;
|
|
||||||
class location;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* First part of user declarations. */
|
|
||||||
#line 24 "DynareBison.yy"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class ParsingDriver;
|
|
||||||
|
|
||||||
#include "ExprNode.hh"
|
|
||||||
|
|
||||||
/* Little hack: we redefine the macro which computes the locations, because
|
|
||||||
we need to access the location from within the parsing driver for error
|
|
||||||
and warning messages. */
|
|
||||||
#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; \
|
|
||||||
} \
|
|
||||||
driver.location = (Current); \
|
|
||||||
} while(false)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Line 35 of lalr1.cc. */
|
|
||||||
#line 80 "DynareBison.hh"
|
|
||||||
|
|
||||||
#include "location.hh"
|
|
||||||
|
|
||||||
/* Enabling traces. */
|
|
||||||
#ifndef YYDEBUG
|
|
||||||
# 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 Dynare
|
|
||||||
{
|
|
||||||
|
|
||||||
/// A Bison parser.
|
|
||||||
class parser
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Symbol semantic values.
|
|
||||||
#ifndef YYSTYPE
|
|
||||||
union semantic_type
|
|
||||||
#line 61 "DynareBison.yy"
|
|
||||||
{
|
|
||||||
string *string_val;
|
|
||||||
NodeID node_val;
|
|
||||||
}
|
|
||||||
/* Line 35 of lalr1.cc. */
|
|
||||||
#line 137 "DynareBison.hh"
|
|
||||||
;
|
|
||||||
#else
|
|
||||||
typedef YYSTYPE semantic_type;
|
|
||||||
#endif
|
|
||||||
/// Symbol locations.
|
|
||||||
typedef location location_type;
|
|
||||||
/// Tokens.
|
|
||||||
struct token
|
|
||||||
{
|
|
||||||
/* Tokens. */
|
|
||||||
enum yytokentype {
|
|
||||||
AR = 258,
|
|
||||||
AUTOCORR = 259,
|
|
||||||
BAYESIAN_IRF = 260,
|
|
||||||
BETA_PDF = 261,
|
|
||||||
BICGSTAB = 262,
|
|
||||||
BVAR_DENSITY = 263,
|
|
||||||
BVAR_FORECAST = 264,
|
|
||||||
BVAR_PRIOR_DECAY = 265,
|
|
||||||
BVAR_PRIOR_FLAT = 266,
|
|
||||||
BVAR_PRIOR_LAMBDA = 267,
|
|
||||||
BVAR_PRIOR_MU = 268,
|
|
||||||
BVAR_PRIOR_OMEGA = 269,
|
|
||||||
BVAR_PRIOR_TAU = 270,
|
|
||||||
BVAR_PRIOR_TRAIN = 271,
|
|
||||||
BVAR_REPLIC = 272,
|
|
||||||
CALIB = 273,
|
|
||||||
CALIB_VAR = 274,
|
|
||||||
CHECK = 275,
|
|
||||||
CONF_SIG = 276,
|
|
||||||
CONSTANT = 277,
|
|
||||||
CORR = 278,
|
|
||||||
COVAR = 279,
|
|
||||||
CUTOFF = 280,
|
|
||||||
DATAFILE = 281,
|
|
||||||
DR_ALGO = 282,
|
|
||||||
DROP = 283,
|
|
||||||
DSAMPLE = 284,
|
|
||||||
DYNASAVE = 285,
|
|
||||||
DYNATYPE = 286,
|
|
||||||
END = 287,
|
|
||||||
ENDVAL = 288,
|
|
||||||
EQUAL = 289,
|
|
||||||
ESTIMATION = 290,
|
|
||||||
ESTIMATED_PARAMS = 291,
|
|
||||||
ESTIMATED_PARAMS_BOUNDS = 292,
|
|
||||||
ESTIMATED_PARAMS_INIT = 293,
|
|
||||||
FILENAME = 294,
|
|
||||||
FILTER_STEP_AHEAD = 295,
|
|
||||||
FILTERED_VARS = 296,
|
|
||||||
FIRST_OBS = 297,
|
|
||||||
FLOAT_NUMBER = 298,
|
|
||||||
FORECAST = 299,
|
|
||||||
GAMMA_PDF = 300,
|
|
||||||
GAUSSIAN_ELIMINATION = 301,
|
|
||||||
GCC_COMPILER = 302,
|
|
||||||
GMRES = 303,
|
|
||||||
GRAPH = 304,
|
|
||||||
HISTVAL = 305,
|
|
||||||
HP_FILTER = 306,
|
|
||||||
HP_NGRID = 307,
|
|
||||||
INITVAL = 308,
|
|
||||||
INT_NUMBER = 309,
|
|
||||||
INV_GAMMA_PDF = 310,
|
|
||||||
IRF = 311,
|
|
||||||
KALMAN_ALGO = 312,
|
|
||||||
KALMAN_TOL = 313,
|
|
||||||
LAPLACE = 314,
|
|
||||||
LCC_COMPILER = 315,
|
|
||||||
LIK_ALGO = 316,
|
|
||||||
LIK_INIT = 317,
|
|
||||||
LINEAR = 318,
|
|
||||||
LOAD_MH_FILE = 319,
|
|
||||||
LOGLINEAR = 320,
|
|
||||||
LU = 321,
|
|
||||||
MARKOWITZ = 322,
|
|
||||||
MAX = 323,
|
|
||||||
METHOD = 324,
|
|
||||||
MH_DROP = 325,
|
|
||||||
MH_INIT_SCALE = 326,
|
|
||||||
MH_JSCALE = 327,
|
|
||||||
MH_MODE = 328,
|
|
||||||
MH_NBLOCKS = 329,
|
|
||||||
MH_REPLIC = 330,
|
|
||||||
MH_RECOVER = 331,
|
|
||||||
MIN = 332,
|
|
||||||
MODE_CHECK = 333,
|
|
||||||
MODE_COMPUTE = 334,
|
|
||||||
MODE_FILE = 335,
|
|
||||||
MODEL = 336,
|
|
||||||
MODEL_COMPARISON = 337,
|
|
||||||
MSHOCKS = 338,
|
|
||||||
MODEL_COMPARISON_APPROXIMATION = 339,
|
|
||||||
MODIFIEDHARMONICMEAN = 340,
|
|
||||||
MOMENTS_VARENDO = 341,
|
|
||||||
NAME = 342,
|
|
||||||
NO_COMPILER = 343,
|
|
||||||
NOBS = 344,
|
|
||||||
NOCONSTANT = 345,
|
|
||||||
NOCORR = 346,
|
|
||||||
NODIAGNOSTIC = 347,
|
|
||||||
NOFUNCTIONS = 348,
|
|
||||||
NOGRAPH = 349,
|
|
||||||
NOMOMENTS = 350,
|
|
||||||
NOPRINT = 351,
|
|
||||||
NORMAL_PDF = 352,
|
|
||||||
OBSERVATION_TRENDS = 353,
|
|
||||||
OPTIM = 354,
|
|
||||||
OPTIM_WEIGHTS = 355,
|
|
||||||
ORDER = 356,
|
|
||||||
OSR = 357,
|
|
||||||
OSR_PARAMS = 358,
|
|
||||||
PARAMETERS = 359,
|
|
||||||
PERIODS = 360,
|
|
||||||
PLANNER_OBJECTIVE = 361,
|
|
||||||
PREFILTER = 362,
|
|
||||||
PRESAMPLE = 363,
|
|
||||||
PRINT = 364,
|
|
||||||
PRIOR_TRUNC = 365,
|
|
||||||
PRIOR_ANALYSIS = 366,
|
|
||||||
POSTERIOR_ANALYSIS = 367,
|
|
||||||
QZ_CRITERIUM = 368,
|
|
||||||
RELATIVE_IRF = 369,
|
|
||||||
REPLIC = 370,
|
|
||||||
RPLOT = 371,
|
|
||||||
SHOCKS = 372,
|
|
||||||
SIGMA_E = 373,
|
|
||||||
SIMUL = 374,
|
|
||||||
SIMUL_ALGO = 375,
|
|
||||||
SIMUL_SEED = 376,
|
|
||||||
SMOOTHER = 377,
|
|
||||||
SOLVE_ALGO = 378,
|
|
||||||
SPARSE = 379,
|
|
||||||
SPARSE_DLL = 380,
|
|
||||||
STDERR = 381,
|
|
||||||
STEADY = 382,
|
|
||||||
STOCH_SIMUL = 383,
|
|
||||||
TEX = 384,
|
|
||||||
RAMSEY_POLICY = 385,
|
|
||||||
PLANNER_DISCOUNT = 386,
|
|
||||||
TEX_NAME = 387,
|
|
||||||
UNIFORM_PDF = 388,
|
|
||||||
UNIT_ROOT_VARS = 389,
|
|
||||||
USE_DLL = 390,
|
|
||||||
VALUES = 391,
|
|
||||||
VAR = 392,
|
|
||||||
VAREXO = 393,
|
|
||||||
VAREXO_DET = 394,
|
|
||||||
VAROBS = 395,
|
|
||||||
XLS_SHEET = 396,
|
|
||||||
XLS_RANGE = 397,
|
|
||||||
NORMCDF = 398,
|
|
||||||
HOMOTOPY_SETUP = 399,
|
|
||||||
HOMOTOPY_MODE = 400,
|
|
||||||
HOMOTOPY_STEPS = 401,
|
|
||||||
EXCLAMATION_EQUAL = 402,
|
|
||||||
EXCLAMATION = 403,
|
|
||||||
EQUAL_EQUAL = 404,
|
|
||||||
GREATER_EQUAL = 405,
|
|
||||||
LESS_EQUAL = 406,
|
|
||||||
GREATER = 407,
|
|
||||||
LESS = 408,
|
|
||||||
COMMA = 409,
|
|
||||||
MINUS = 410,
|
|
||||||
PLUS = 411,
|
|
||||||
DIVIDE = 412,
|
|
||||||
TIMES = 413,
|
|
||||||
UMINUS = 414,
|
|
||||||
POWER = 415,
|
|
||||||
EXP = 416,
|
|
||||||
LOG = 417,
|
|
||||||
LN = 418,
|
|
||||||
LOG10 = 419,
|
|
||||||
SIN = 420,
|
|
||||||
COS = 421,
|
|
||||||
TAN = 422,
|
|
||||||
ASIN = 423,
|
|
||||||
ACOS = 424,
|
|
||||||
ATAN = 425,
|
|
||||||
SINH = 426,
|
|
||||||
COSH = 427,
|
|
||||||
TANH = 428,
|
|
||||||
ASINH = 429,
|
|
||||||
ACOSH = 430,
|
|
||||||
ATANH = 431,
|
|
||||||
SQRT = 432,
|
|
||||||
DYNARE_SENSITIVITY = 433,
|
|
||||||
IDENTIFICATION = 434,
|
|
||||||
MORRIS = 435,
|
|
||||||
STAB = 436,
|
|
||||||
REDFORM = 437,
|
|
||||||
PPRIOR = 438,
|
|
||||||
PRIOR_RANGE = 439,
|
|
||||||
PPOST = 440,
|
|
||||||
ILPTAU = 441,
|
|
||||||
GLUE = 442,
|
|
||||||
MORRIS_NLIV = 443,
|
|
||||||
MORRIS_NTRA = 444,
|
|
||||||
NSAM = 445,
|
|
||||||
LOAD_REDFORM = 446,
|
|
||||||
LOAD_RMSE = 447,
|
|
||||||
LOAD_STAB = 448,
|
|
||||||
ALPHA2_STAB = 449,
|
|
||||||
KSSTAT = 450,
|
|
||||||
LOGTRANS_REDFORM = 451,
|
|
||||||
THRESHOLD_REDFORM = 452,
|
|
||||||
KSSTAT_REDFORM = 453,
|
|
||||||
ALPHA2_REDFORM = 454,
|
|
||||||
NAMENDO = 455,
|
|
||||||
NAMLAGENDO = 456,
|
|
||||||
NAMEXO = 457,
|
|
||||||
RMSE = 458,
|
|
||||||
LIK_ONLY = 459,
|
|
||||||
VAR_RMSE = 460,
|
|
||||||
PFILT_RMSE = 461,
|
|
||||||
ISTART_RMSE = 462,
|
|
||||||
ALPHA_RMSE = 463,
|
|
||||||
ALPHA2_RMSE = 464
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
/// Token type.
|
|
||||||
typedef token::yytokentype token_type;
|
|
||||||
|
|
||||||
/// Build a parser object.
|
|
||||||
parser (ParsingDriver &driver_yyarg);
|
|
||||||
virtual ~parser ();
|
|
||||||
|
|
||||||
/// Parse.
|
|
||||||
/// \returns 0 iff parsing succeeded.
|
|
||||||
virtual int parse ();
|
|
||||||
|
|
||||||
/// The current debugging stream.
|
|
||||||
std::ostream& debug_stream () const;
|
|
||||||
/// Set the current debugging stream.
|
|
||||||
void set_debug_stream (std::ostream &);
|
|
||||||
|
|
||||||
/// Type for debugging levels.
|
|
||||||
typedef int debug_level_type;
|
|
||||||
/// The current debugging level.
|
|
||||||
debug_level_type debug_level () const;
|
|
||||||
/// Set the current debugging level.
|
|
||||||
void set_debug_level (debug_level_type l);
|
|
||||||
|
|
||||||
private:
|
|
||||||
/// Report a syntax error.
|
|
||||||
/// \param loc where the syntax error is found.
|
|
||||||
/// \param msg a description of the syntax error.
|
|
||||||
virtual void error (const location_type& loc, const std::string& msg);
|
|
||||||
|
|
||||||
/// Generate an error message.
|
|
||||||
/// \param state the state where the error occurred.
|
|
||||||
/// \param tok the look-ahead token.
|
|
||||||
virtual std::string yysyntax_error_ (int yystate, int tok);
|
|
||||||
|
|
||||||
#if YYDEBUG
|
|
||||||
/// \brief Report a symbol value on the debug stream.
|
|
||||||
/// \param yytype The token type.
|
|
||||||
/// \param yyvaluep Its semantic value.
|
|
||||||
/// \param yylocationp Its location.
|
|
||||||
virtual void yy_symbol_value_print_ (int yytype,
|
|
||||||
const semantic_type* yyvaluep,
|
|
||||||
const location_type* yylocationp);
|
|
||||||
/// \brief Report a symbol on the debug stream.
|
|
||||||
/// \param yytype The token type.
|
|
||||||
/// \param yyvaluep Its semantic value.
|
|
||||||
/// \param yylocationp Its location.
|
|
||||||
virtual void yy_symbol_print_ (int yytype,
|
|
||||||
const semantic_type* yyvaluep,
|
|
||||||
const location_type* yylocationp);
|
|
||||||
#endif /* ! YYDEBUG */
|
|
||||||
|
|
||||||
|
|
||||||
/// State numbers.
|
|
||||||
typedef int state_type;
|
|
||||||
/// State stack type.
|
|
||||||
typedef stack<state_type> state_stack_type;
|
|
||||||
/// Semantic value stack type.
|
|
||||||
typedef stack<semantic_type> semantic_stack_type;
|
|
||||||
/// location stack type.
|
|
||||||
typedef stack<location_type> location_stack_type;
|
|
||||||
|
|
||||||
/// The state stack.
|
|
||||||
state_stack_type yystate_stack_;
|
|
||||||
/// The semantic value stack.
|
|
||||||
semantic_stack_type yysemantic_stack_;
|
|
||||||
/// The location stack.
|
|
||||||
location_stack_type yylocation_stack_;
|
|
||||||
|
|
||||||
/// Internal symbol numbers.
|
|
||||||
typedef unsigned char token_number_type;
|
|
||||||
/* Tables. */
|
|
||||||
/// For a state, the index in \a yytable_ of its portion.
|
|
||||||
static const short int yypact_[];
|
|
||||||
static const short int yypact_ninf_;
|
|
||||||
|
|
||||||
/// 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_[];
|
|
||||||
|
|
||||||
static const short int yypgoto_[];
|
|
||||||
static const short int yydefgoto_[];
|
|
||||||
|
|
||||||
/// What to do in a state.
|
|
||||||
/// \a yytable_[yypact_[s]]: what to do in state \a s.
|
|
||||||
/// - if positive, shift that token.
|
|
||||||
/// - if negative, reduce the rule which number is the opposite.
|
|
||||||
/// - if zero, do what YYDEFACT says.
|
|
||||||
static const short int yytable_[];
|
|
||||||
static const signed char yytable_ninf_;
|
|
||||||
|
|
||||||
static const short int yycheck_[];
|
|
||||||
|
|
||||||
/// For a state, its accessing symbol.
|
|
||||||
static const unsigned short int yystos_[];
|
|
||||||
|
|
||||||
/// For a rule, its LHS.
|
|
||||||
static const unsigned short int yyr1_[];
|
|
||||||
/// For a rule, its RHS length.
|
|
||||||
static const unsigned char yyr2_[];
|
|
||||||
|
|
||||||
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
|
||||||
/// For a symbol, its name in clear.
|
|
||||||
static const char* const yytname_[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#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;
|
|
||||||
/// A `-1'-separated list of the rules' RHS.
|
|
||||||
static const rhs_number_type yyrhs_[];
|
|
||||||
/// For each rule, the index of the first RHS symbol in \a yyrhs_.
|
|
||||||
static const unsigned short int yyprhs_[];
|
|
||||||
/// For each rule, its source line number.
|
|
||||||
static const unsigned short int yyrline_[];
|
|
||||||
/// For each scanner token number, its symbol number.
|
|
||||||
static const unsigned short int yytoken_number_[];
|
|
||||||
/// Report on the debug stream that the rule \a r is going to be reduced.
|
|
||||||
virtual void yy_reduce_print_ (int r);
|
|
||||||
/// Print the state stack on the debug stream.
|
|
||||||
virtual void yystack_print_ ();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// Convert a scanner token number \a t to a symbol number.
|
|
||||||
token_number_type yytranslate_ (int t);
|
|
||||||
|
|
||||||
/// \brief Reclaim the memory associated to a symbol.
|
|
||||||
/// \param yymsg Why this token is reclaimed.
|
|
||||||
/// \param yytype The symbol type.
|
|
||||||
/// \param yyvaluep Its semantic value.
|
|
||||||
/// \param yylocationp Its location.
|
|
||||||
inline void yydestruct_ (const char* yymsg,
|
|
||||||
int yytype,
|
|
||||||
semantic_type* yyvaluep,
|
|
||||||
location_type* yylocationp);
|
|
||||||
|
|
||||||
/// Pop \a n symbols the three stacks.
|
|
||||||
inline void yypop_ (unsigned int n = 1);
|
|
||||||
|
|
||||||
/* Constants. */
|
|
||||||
static const int yyeof_;
|
|
||||||
/* LAST_ -- Last index in TABLE_. */
|
|
||||||
static const int yylast_;
|
|
||||||
static const int yynnts_;
|
|
||||||
static const int yyempty_;
|
|
||||||
static const int yyfinal_;
|
|
||||||
static const int yyterror_;
|
|
||||||
static const int yyerrcode_;
|
|
||||||
static const int yyntokens_;
|
|
||||||
static const unsigned int yyuser_token_number_max_;
|
|
||||||
static const token_number_type yyundef_token_;
|
|
||||||
|
|
||||||
/* Debugging. */
|
|
||||||
int yydebug_;
|
|
||||||
std::ostream* yycdebug_;
|
|
||||||
|
|
||||||
|
|
||||||
/* User arguments. */
|
|
||||||
ParsingDriver &driver;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* ! defined PARSER_HEADER_H */
|
|
|
@ -1,145 +0,0 @@
|
||||||
/* A Bison parser, made by GNU Bison 2.3. */
|
|
||||||
|
|
||||||
/* Locations for Bison parsers in C++
|
|
||||||
|
|
||||||
Copyright (C) 2002, 2003, 2004, 2005, 2006 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
|
|
||||||
the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA. */
|
|
||||||
|
|
||||||
/* As a special exception, you may create a larger work that contains
|
|
||||||
part or all of the Bison parser skeleton and distribute that work
|
|
||||||
under terms of your choice, so long as that work isn't itself a
|
|
||||||
parser generator using the skeleton or a modified version thereof
|
|
||||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
|
||||||
the parser skeleton itself, you may (at your option) remove this
|
|
||||||
special exception, which will cause the skeleton and the resulting
|
|
||||||
Bison output files to be licensed under the GNU General Public
|
|
||||||
License without this special exception.
|
|
||||||
|
|
||||||
This special exception was added by the Free Software Foundation in
|
|
||||||
version 2.2 of Bison. */
|
|
||||||
|
|
||||||
/**
|
|
||||||
** \file location.hh
|
|
||||||
** Define the Dynare::location class.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef BISON_LOCATION_HH
|
|
||||||
# define BISON_LOCATION_HH
|
|
||||||
|
|
||||||
# include <iostream>
|
|
||||||
# include <string>
|
|
||||||
# include "position.hh"
|
|
||||||
|
|
||||||
namespace Dynare
|
|
||||||
{
|
|
||||||
|
|
||||||
/// Abstract a location.
|
|
||||||
class location
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// Construct a location.
|
|
||||||
location ()
|
|
||||||
: begin (), end ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Initialization.
|
|
||||||
inline void initialize (std::string* fn)
|
|
||||||
{
|
|
||||||
begin.initialize (fn);
|
|
||||||
end = begin;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \name Line and Column related manipulators
|
|
||||||
** \{ */
|
|
||||||
public:
|
|
||||||
/// Reset initial location to final location.
|
|
||||||
inline void step ()
|
|
||||||
{
|
|
||||||
begin = end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extend the current location to the COUNT next columns.
|
|
||||||
inline void columns (unsigned int count = 1)
|
|
||||||
{
|
|
||||||
end += count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extend the current location to the COUNT next lines.
|
|
||||||
inline void lines (unsigned int count = 1)
|
|
||||||
{
|
|
||||||
end.lines (count);
|
|
||||||
}
|
|
||||||
/** \} */
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// Beginning of the located region.
|
|
||||||
position begin;
|
|
||||||
/// End of the located region.
|
|
||||||
position end;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Join two location objects to create a location.
|
|
||||||
inline const location operator+ (const location& begin, const location& end)
|
|
||||||
{
|
|
||||||
location res = begin;
|
|
||||||
res.end = end.end;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add two location objects.
|
|
||||||
inline const location operator+ (const location& begin, unsigned int width)
|
|
||||||
{
|
|
||||||
location res = begin;
|
|
||||||
res.columns (width);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add and assign a location.
|
|
||||||
inline location& operator+= (location& res, unsigned int width)
|
|
||||||
{
|
|
||||||
res.columns (width);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief Intercept output stream redirection.
|
|
||||||
** \param ostr the destination output stream
|
|
||||||
** \param loc a reference to the location to redirect
|
|
||||||
**
|
|
||||||
** Avoid duplicate information.
|
|
||||||
*/
|
|
||||||
inline std::ostream& operator<< (std::ostream& ostr, const location& loc)
|
|
||||||
{
|
|
||||||
position last = loc.end - 1;
|
|
||||||
ostr << loc.begin;
|
|
||||||
if (last.filename
|
|
||||||
&& (!loc.begin.filename
|
|
||||||
|| *loc.begin.filename != *last.filename))
|
|
||||||
ostr << '-' << last;
|
|
||||||
else if (loc.begin.line != last.line)
|
|
||||||
ostr << '-' << last.line << '.' << last.column;
|
|
||||||
else if (loc.begin.column != last.column)
|
|
||||||
ostr << '-' << last.column;
|
|
||||||
return ostr;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // not BISON_LOCATION_HH
|
|
|
@ -1,142 +0,0 @@
|
||||||
/* A Bison parser, made by GNU Bison 2.3. */
|
|
||||||
|
|
||||||
/* Positions for Bison parsers in C++
|
|
||||||
|
|
||||||
Copyright (C) 2002, 2003, 2004, 2005, 2006 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
|
|
||||||
the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA. */
|
|
||||||
|
|
||||||
/* As a special exception, you may create a larger work that contains
|
|
||||||
part or all of the Bison parser skeleton and distribute that work
|
|
||||||
under terms of your choice, so long as that work isn't itself a
|
|
||||||
parser generator using the skeleton or a modified version thereof
|
|
||||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
|
||||||
the parser skeleton itself, you may (at your option) remove this
|
|
||||||
special exception, which will cause the skeleton and the resulting
|
|
||||||
Bison output files to be licensed under the GNU General Public
|
|
||||||
License without this special exception.
|
|
||||||
|
|
||||||
This special exception was added by the Free Software Foundation in
|
|
||||||
version 2.2 of Bison. */
|
|
||||||
|
|
||||||
/**
|
|
||||||
** \file position.hh
|
|
||||||
** Define the Dynare::position class.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef BISON_POSITION_HH
|
|
||||||
# define BISON_POSITION_HH
|
|
||||||
|
|
||||||
# include <iostream>
|
|
||||||
# include <string>
|
|
||||||
|
|
||||||
namespace Dynare
|
|
||||||
{
|
|
||||||
/// Abstract a position.
|
|
||||||
class position
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// Construct a position.
|
|
||||||
position ()
|
|
||||||
: filename (0), line (1), column (0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Initialization.
|
|
||||||
inline void initialize (std::string* fn)
|
|
||||||
{
|
|
||||||
filename = fn;
|
|
||||||
line = 1;
|
|
||||||
column = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \name Line and Column related manipulators
|
|
||||||
** \{ */
|
|
||||||
public:
|
|
||||||
/// (line related) Advance to the COUNT next lines.
|
|
||||||
inline void lines (int count = 1)
|
|
||||||
{
|
|
||||||
column = 0;
|
|
||||||
line += count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// (column related) Advance to the COUNT next columns.
|
|
||||||
inline void columns (int count = 1)
|
|
||||||
{
|
|
||||||
int leftmost = 0;
|
|
||||||
int current = column;
|
|
||||||
if (leftmost <= current + count)
|
|
||||||
column += count;
|
|
||||||
else
|
|
||||||
column = 0;
|
|
||||||
}
|
|
||||||
/** \} */
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// File name to which this position refers.
|
|
||||||
std::string* filename;
|
|
||||||
/// Current line number.
|
|
||||||
unsigned int line;
|
|
||||||
/// Current column number.
|
|
||||||
unsigned int column;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Add and assign a position.
|
|
||||||
inline const position&
|
|
||||||
operator+= (position& res, const int width)
|
|
||||||
{
|
|
||||||
res.columns (width);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add two position objects.
|
|
||||||
inline const position
|
|
||||||
operator+ (const position& begin, const int width)
|
|
||||||
{
|
|
||||||
position res = begin;
|
|
||||||
return res += width;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add and assign a position.
|
|
||||||
inline const position&
|
|
||||||
operator-= (position& res, const int width)
|
|
||||||
{
|
|
||||||
return res += -width;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add two position objects.
|
|
||||||
inline const position
|
|
||||||
operator- (const position& begin, const int width)
|
|
||||||
{
|
|
||||||
return begin + -width;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief Intercept output stream redirection.
|
|
||||||
** \param ostr the destination output stream
|
|
||||||
** \param pos a reference to the position to redirect
|
|
||||||
*/
|
|
||||||
inline std::ostream&
|
|
||||||
operator<< (std::ostream& ostr, const position& pos)
|
|
||||||
{
|
|
||||||
if (pos.filename)
|
|
||||||
ostr << *pos.filename << ':';
|
|
||||||
return ostr << pos.line << '.' << pos.column;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif // not BISON_POSITION_HH
|
|
|
@ -1,129 +0,0 @@
|
||||||
/* A Bison parser, made by GNU Bison 2.3. */
|
|
||||||
|
|
||||||
/* Stack handling for Bison parsers in C++
|
|
||||||
|
|
||||||
Copyright (C) 2002, 2003, 2004, 2005, 2006 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
|
|
||||||
the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA. */
|
|
||||||
|
|
||||||
/* As a special exception, you may create a larger work that contains
|
|
||||||
part or all of the Bison parser skeleton and distribute that work
|
|
||||||
under terms of your choice, so long as that work isn't itself a
|
|
||||||
parser generator using the skeleton or a modified version thereof
|
|
||||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
|
||||||
the parser skeleton itself, you may (at your option) remove this
|
|
||||||
special exception, which will cause the skeleton and the resulting
|
|
||||||
Bison output files to be licensed under the GNU General Public
|
|
||||||
License without this special exception.
|
|
||||||
|
|
||||||
This special exception was added by the Free Software Foundation in
|
|
||||||
version 2.2 of Bison. */
|
|
||||||
|
|
||||||
#ifndef BISON_STACK_HH
|
|
||||||
# define BISON_STACK_HH
|
|
||||||
|
|
||||||
#include <deque>
|
|
||||||
|
|
||||||
namespace Dynare
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
|
|
||||||
stack () : seq_ ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
stack (unsigned int n) : seq_ (n)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
T&
|
|
||||||
operator [] (unsigned int i)
|
|
||||||
{
|
|
||||||
return seq_[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
const T&
|
|
||||||
operator [] (unsigned int i) const
|
|
||||||
{
|
|
||||||
return seq_[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
void
|
|
||||||
push (const T& t)
|
|
||||||
{
|
|
||||||
seq_.push_front (t);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
void
|
|
||||||
pop (unsigned int n = 1)
|
|
||||||
{
|
|
||||||
for (; n; --n)
|
|
||||||
seq_.pop_front ();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
unsigned int
|
|
||||||
height () const
|
|
||||||
{
|
|
||||||
return seq_.size ();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const_iterator begin () const { return seq_.rbegin (); }
|
|
||||||
inline const_iterator end () const { return seq_.rend (); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
S seq_;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Present a slice of the top of a stack.
|
|
||||||
template <class T, class S = stack<T> >
|
|
||||||
class slice
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
slice (const S& stack,
|
|
||||||
unsigned int range) : stack_ (stack),
|
|
||||||
range_ (range)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
const T&
|
|
||||||
operator [] (unsigned int i) const
|
|
||||||
{
|
|
||||||
return stack_[range_ - i];
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
const S& stack_;
|
|
||||||
unsigned int range_;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // not BISON_STACK_HH
|
|
|
@ -1,829 +0,0 @@
|
||||||
/* A Bison parser, made by GNU Bison 2.3. */
|
|
||||||
|
|
||||||
/* Skeleton implementation for Bison LALR(1) parsers in C++
|
|
||||||
|
|
||||||
Copyright (C) 2002, 2003, 2004, 2005, 2006 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
|
|
||||||
the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA. */
|
|
||||||
|
|
||||||
/* As a special exception, you may create a larger work that contains
|
|
||||||
part or all of the Bison parser skeleton and distribute that work
|
|
||||||
under terms of your choice, so long as that work isn't itself a
|
|
||||||
parser generator using the skeleton or a modified version thereof
|
|
||||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
|
||||||
the parser skeleton itself, you may (at your option) remove this
|
|
||||||
special exception, which will cause the skeleton and the resulting
|
|
||||||
Bison output files to be licensed under the GNU General Public
|
|
||||||
License without this special exception.
|
|
||||||
|
|
||||||
This special exception was added by the Free Software Foundation in
|
|
||||||
version 2.2 of Bison. */
|
|
||||||
|
|
||||||
// Take the name prefix into account.
|
|
||||||
#define yylex Macrolex
|
|
||||||
|
|
||||||
#include "MacroBison.hh"
|
|
||||||
|
|
||||||
/* User implementation prologue. */
|
|
||||||
#line 54 "MacroBison.yy"
|
|
||||||
|
|
||||||
#include "MacroDriver.hh"
|
|
||||||
|
|
||||||
/* this "connects" the bison parser in the driver to the flex scanner class
|
|
||||||
* object. it defines the yylex() function call to pull the next token from the
|
|
||||||
* current lexer object of the driver context. */
|
|
||||||
#undef yylex
|
|
||||||
#define yylex driver.lexer->lex
|
|
||||||
|
|
||||||
|
|
||||||
/* Line 317 of lalr1.cc. */
|
|
||||||
#line 54 "MacroBison.cc"
|
|
||||||
|
|
||||||
#ifndef YY_
|
|
||||||
# if YYENABLE_NLS
|
|
||||||
# if ENABLE_NLS
|
|
||||||
# include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
|
|
||||||
# define YY_(msgid) dgettext ("bison-runtime", msgid)
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# ifndef YY_
|
|
||||||
# define YY_(msgid) msgid
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Suppress unused-variable warnings by "using" E. */
|
|
||||||
#define YYUSE(e) ((void) (e))
|
|
||||||
|
|
||||||
/* A pseudo ostream that takes yydebug_ into account. */
|
|
||||||
# define YYCDEBUG \
|
|
||||||
for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false) \
|
|
||||||
(*yycdebug_)
|
|
||||||
|
|
||||||
/* Enable debugging if requested. */
|
|
||||||
#if YYDEBUG
|
|
||||||
|
|
||||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
|
||||||
do { \
|
|
||||||
if (yydebug_) \
|
|
||||||
{ \
|
|
||||||
*yycdebug_ << Title << ' '; \
|
|
||||||
yy_symbol_print_ ((Type), (Value), (Location)); \
|
|
||||||
*yycdebug_ << std::endl; \
|
|
||||||
} \
|
|
||||||
} while (false)
|
|
||||||
|
|
||||||
# define YY_REDUCE_PRINT(Rule) \
|
|
||||||
do { \
|
|
||||||
if (yydebug_) \
|
|
||||||
yy_reduce_print_ (Rule); \
|
|
||||||
} while (false)
|
|
||||||
|
|
||||||
# define YY_STACK_PRINT() \
|
|
||||||
do { \
|
|
||||||
if (yydebug_) \
|
|
||||||
yystack_print_ (); \
|
|
||||||
} while (false)
|
|
||||||
|
|
||||||
#else /* !YYDEBUG */
|
|
||||||
|
|
||||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
|
|
||||||
# define YY_REDUCE_PRINT(Rule)
|
|
||||||
# define YY_STACK_PRINT()
|
|
||||||
|
|
||||||
#endif /* !YYDEBUG */
|
|
||||||
|
|
||||||
#define YYACCEPT goto yyacceptlab
|
|
||||||
#define YYABORT goto yyabortlab
|
|
||||||
#define YYERROR goto yyerrorlab
|
|
||||||
|
|
||||||
namespace Macro
|
|
||||||
{
|
|
||||||
#if YYERROR_VERBOSE
|
|
||||||
|
|
||||||
/* Return YYSTR after stripping away unnecessary quotes and
|
|
||||||
backslashes, so that it's suitable for yyerror. The heuristic is
|
|
||||||
that double-quoting is unnecessary unless the string contains an
|
|
||||||
apostrophe, a comma, or backslash (other than backslash-backslash).
|
|
||||||
YYSTR is taken from yytname. */
|
|
||||||
std::string
|
|
||||||
parser::yytnamerr_ (const char *yystr)
|
|
||||||
{
|
|
||||||
if (*yystr == '"')
|
|
||||||
{
|
|
||||||
std::string yyr = "";
|
|
||||||
char const *yyp = yystr;
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
switch (*++yyp)
|
|
||||||
{
|
|
||||||
case '\'':
|
|
||||||
case ',':
|
|
||||||
goto do_not_strip_quotes;
|
|
||||||
|
|
||||||
case '\\':
|
|
||||||
if (*++yyp != '\\')
|
|
||||||
goto do_not_strip_quotes;
|
|
||||||
/* Fall through. */
|
|
||||||
default:
|
|
||||||
yyr += *yyp;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '"':
|
|
||||||
return yyr;
|
|
||||||
}
|
|
||||||
do_not_strip_quotes: ;
|
|
||||||
}
|
|
||||||
|
|
||||||
return yystr;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// Build a parser object.
|
|
||||||
parser::parser (MacroDriver &driver_yyarg, ostream &out_yyarg)
|
|
||||||
: yydebug_ (false),
|
|
||||||
yycdebug_ (&std::cerr),
|
|
||||||
driver (driver_yyarg),
|
|
||||||
out (out_yyarg)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
parser::~parser ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#if YYDEBUG
|
|
||||||
/*--------------------------------.
|
|
||||||
| Print this symbol on YYOUTPUT. |
|
|
||||||
`--------------------------------*/
|
|
||||||
|
|
||||||
inline void
|
|
||||||
parser::yy_symbol_value_print_ (int yytype,
|
|
||||||
const semantic_type* yyvaluep, const location_type* yylocationp)
|
|
||||||
{
|
|
||||||
YYUSE (yylocationp);
|
|
||||||
YYUSE (yyvaluep);
|
|
||||||
switch (yytype)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
parser::yy_symbol_print_ (int yytype,
|
|
||||||
const semantic_type* yyvaluep, const location_type* yylocationp)
|
|
||||||
{
|
|
||||||
*yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm")
|
|
||||||
<< ' ' << yytname_[yytype] << " ("
|
|
||||||
<< *yylocationp << ": ";
|
|
||||||
yy_symbol_value_print_ (yytype, yyvaluep, yylocationp);
|
|
||||||
*yycdebug_ << ')';
|
|
||||||
}
|
|
||||||
#endif /* ! YYDEBUG */
|
|
||||||
|
|
||||||
void
|
|
||||||
parser::yydestruct_ (const char* yymsg,
|
|
||||||
int yytype, semantic_type* yyvaluep, location_type* yylocationp)
|
|
||||||
{
|
|
||||||
YYUSE (yylocationp);
|
|
||||||
YYUSE (yymsg);
|
|
||||||
YYUSE (yyvaluep);
|
|
||||||
|
|
||||||
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
|
|
||||||
|
|
||||||
switch (yytype)
|
|
||||||
{
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
parser::yypop_ (unsigned int n)
|
|
||||||
{
|
|
||||||
yystate_stack_.pop (n);
|
|
||||||
yysemantic_stack_.pop (n);
|
|
||||||
yylocation_stack_.pop (n);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream&
|
|
||||||
parser::debug_stream () const
|
|
||||||
{
|
|
||||||
return *yycdebug_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
parser::set_debug_stream (std::ostream& o)
|
|
||||||
{
|
|
||||||
yycdebug_ = &o;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
parser::debug_level_type
|
|
||||||
parser::debug_level () const
|
|
||||||
{
|
|
||||||
return yydebug_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
parser::set_debug_level (debug_level_type l)
|
|
||||||
{
|
|
||||||
yydebug_ = l;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
parser::parse ()
|
|
||||||
{
|
|
||||||
/// Look-ahead and look-ahead in internal form.
|
|
||||||
int yychar = yyempty_;
|
|
||||||
int yytoken = 0;
|
|
||||||
|
|
||||||
/* State. */
|
|
||||||
int yyn;
|
|
||||||
int yylen = 0;
|
|
||||||
int yystate = 0;
|
|
||||||
|
|
||||||
/* Error handling. */
|
|
||||||
int yynerrs_ = 0;
|
|
||||||
int yyerrstatus_ = 0;
|
|
||||||
|
|
||||||
/// Semantic value of the look-ahead.
|
|
||||||
semantic_type yylval;
|
|
||||||
/// Location of the look-ahead.
|
|
||||||
location_type yylloc;
|
|
||||||
/// The locations where the error started and ended.
|
|
||||||
location yyerror_range[2];
|
|
||||||
|
|
||||||
/// $$.
|
|
||||||
semantic_type yyval;
|
|
||||||
/// @$.
|
|
||||||
location_type yyloc;
|
|
||||||
|
|
||||||
int yyresult;
|
|
||||||
|
|
||||||
YYCDEBUG << "Starting parse" << std::endl;
|
|
||||||
|
|
||||||
|
|
||||||
/* User initialization code. */
|
|
||||||
#line 38 "MacroBison.yy"
|
|
||||||
{
|
|
||||||
// Initialize the location filenames
|
|
||||||
yylloc.begin.filename = yylloc.end.filename = &driver.file;
|
|
||||||
// Output first @line statement
|
|
||||||
out << "@line \"" << driver.file << "\" 1" << endl;
|
|
||||||
}
|
|
||||||
/* Line 547 of yacc.c. */
|
|
||||||
#line 294 "MacroBison.cc"
|
|
||||||
/* Initialize the stacks. The initial state will be pushed in
|
|
||||||
yynewstate, since the latter expects the semantical and the
|
|
||||||
location values to have been already stored, initialize these
|
|
||||||
stacks with a primary value. */
|
|
||||||
yystate_stack_ = state_stack_type (0);
|
|
||||||
yysemantic_stack_ = semantic_stack_type (0);
|
|
||||||
yylocation_stack_ = location_stack_type (0);
|
|
||||||
yysemantic_stack_.push (yylval);
|
|
||||||
yylocation_stack_.push (yylloc);
|
|
||||||
|
|
||||||
/* New state. */
|
|
||||||
yynewstate:
|
|
||||||
yystate_stack_.push (yystate);
|
|
||||||
YYCDEBUG << "Entering state " << yystate << std::endl;
|
|
||||||
goto yybackup;
|
|
||||||
|
|
||||||
/* Backup. */
|
|
||||||
yybackup:
|
|
||||||
|
|
||||||
/* Try to take a decision without look-ahead. */
|
|
||||||
yyn = yypact_[yystate];
|
|
||||||
if (yyn == yypact_ninf_)
|
|
||||||
goto yydefault;
|
|
||||||
|
|
||||||
/* Read a look-ahead token. */
|
|
||||||
if (yychar == yyempty_)
|
|
||||||
{
|
|
||||||
YYCDEBUG << "Reading a token: ";
|
|
||||||
yychar = yylex (&yylval, &yylloc, driver);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Convert token to internal form. */
|
|
||||||
if (yychar <= yyeof_)
|
|
||||||
{
|
|
||||||
yychar = yytoken = yyeof_;
|
|
||||||
YYCDEBUG << "Now at end of input." << std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
yytoken = yytranslate_ (yychar);
|
|
||||||
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If the proper action on seeing token YYTOKEN is to reduce or to
|
|
||||||
detect an error, take that action. */
|
|
||||||
yyn += yytoken;
|
|
||||||
if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken)
|
|
||||||
goto yydefault;
|
|
||||||
|
|
||||||
/* Reduce or error. */
|
|
||||||
yyn = yytable_[yyn];
|
|
||||||
if (yyn <= 0)
|
|
||||||
{
|
|
||||||
if (yyn == 0 || yyn == yytable_ninf_)
|
|
||||||
goto yyerrlab;
|
|
||||||
yyn = -yyn;
|
|
||||||
goto yyreduce;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Accept? */
|
|
||||||
if (yyn == yyfinal_)
|
|
||||||
goto yyacceptlab;
|
|
||||||
|
|
||||||
/* Shift the look-ahead token. */
|
|
||||||
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
|
|
||||||
|
|
||||||
/* Discard the token being shifted unless it is eof. */
|
|
||||||
if (yychar != yyeof_)
|
|
||||||
yychar = yyempty_;
|
|
||||||
|
|
||||||
yysemantic_stack_.push (yylval);
|
|
||||||
yylocation_stack_.push (yylloc);
|
|
||||||
|
|
||||||
/* Count tokens shifted since error; after three, turn off error
|
|
||||||
status. */
|
|
||||||
if (yyerrstatus_)
|
|
||||||
--yyerrstatus_;
|
|
||||||
|
|
||||||
yystate = yyn;
|
|
||||||
goto yynewstate;
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------.
|
|
||||||
| yydefault -- do the default action for the current state. |
|
|
||||||
`-----------------------------------------------------------*/
|
|
||||||
yydefault:
|
|
||||||
yyn = yydefact_[yystate];
|
|
||||||
if (yyn == 0)
|
|
||||||
goto yyerrlab;
|
|
||||||
goto yyreduce;
|
|
||||||
|
|
||||||
/*-----------------------------.
|
|
||||||
| yyreduce -- Do a reduction. |
|
|
||||||
`-----------------------------*/
|
|
||||||
yyreduce:
|
|
||||||
yylen = yyr2_[yyn];
|
|
||||||
/* If YYLEN is nonzero, implement the default value of the action:
|
|
||||||
`$$ = $1'. Otherwise, use the top of the stack.
|
|
||||||
|
|
||||||
Otherwise, the following line sets YYVAL to garbage.
|
|
||||||
This behavior is undocumented and Bison
|
|
||||||
users should not rely upon it. */
|
|
||||||
if (yylen)
|
|
||||||
yyval = yysemantic_stack_[yylen - 1];
|
|
||||||
else
|
|
||||||
yyval = yysemantic_stack_[0];
|
|
||||||
|
|
||||||
{
|
|
||||||
slice<location_type, location_stack_type> slice (yylocation_stack_, yylen);
|
|
||||||
YYLLOC_DEFAULT (yyloc, slice, yylen);
|
|
||||||
}
|
|
||||||
YY_REDUCE_PRINT (yyn);
|
|
||||||
switch (yyn)
|
|
||||||
{
|
|
||||||
|
|
||||||
/* Line 675 of lalr1.cc. */
|
|
||||||
#line 411 "MacroBison.cc"
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc);
|
|
||||||
|
|
||||||
yypop_ (yylen);
|
|
||||||
yylen = 0;
|
|
||||||
YY_STACK_PRINT ();
|
|
||||||
|
|
||||||
yysemantic_stack_.push (yyval);
|
|
||||||
yylocation_stack_.push (yyloc);
|
|
||||||
|
|
||||||
/* Shift the result of the reduction. */
|
|
||||||
yyn = yyr1_[yyn];
|
|
||||||
yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0];
|
|
||||||
if (0 <= yystate && yystate <= yylast_
|
|
||||||
&& yycheck_[yystate] == yystate_stack_[0])
|
|
||||||
yystate = yytable_[yystate];
|
|
||||||
else
|
|
||||||
yystate = yydefgoto_[yyn - yyntokens_];
|
|
||||||
goto yynewstate;
|
|
||||||
|
|
||||||
/*------------------------------------.
|
|
||||||
| yyerrlab -- here on detecting error |
|
|
||||||
`------------------------------------*/
|
|
||||||
yyerrlab:
|
|
||||||
/* If not already recovering from an error, report this error. */
|
|
||||||
if (!yyerrstatus_)
|
|
||||||
{
|
|
||||||
++yynerrs_;
|
|
||||||
error (yylloc, yysyntax_error_ (yystate, yytoken));
|
|
||||||
}
|
|
||||||
|
|
||||||
yyerror_range[0] = yylloc;
|
|
||||||
if (yyerrstatus_ == 3)
|
|
||||||
{
|
|
||||||
/* If just tried and failed to reuse look-ahead 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 look-ahead token after shifting the error
|
|
||||||
token. */
|
|
||||||
goto yyerrlab1;
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------.
|
|
||||||
| yyerrorlab -- error raised explicitly by YYERROR. |
|
|
||||||
`---------------------------------------------------*/
|
|
||||||
yyerrorlab:
|
|
||||||
|
|
||||||
/* Pacify compilers like GCC when the user code never invokes
|
|
||||||
YYERROR and the label yyerrorlab therefore never appears in user
|
|
||||||
code. */
|
|
||||||
if (false)
|
|
||||||
goto yyerrorlab;
|
|
||||||
|
|
||||||
yyerror_range[0] = yylocation_stack_[yylen - 1];
|
|
||||||
/* Do not reclaim the symbols of the rule which action triggered
|
|
||||||
this YYERROR. */
|
|
||||||
yypop_ (yylen);
|
|
||||||
yylen = 0;
|
|
||||||
yystate = yystate_stack_[0];
|
|
||||||
goto yyerrlab1;
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------.
|
|
||||||
| yyerrlab1 -- common code for both syntax error and YYERROR. |
|
|
||||||
`-------------------------------------------------------------*/
|
|
||||||
yyerrlab1:
|
|
||||||
yyerrstatus_ = 3; /* Each real token shifted decrements this. */
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
yyn = yypact_[yystate];
|
|
||||||
if (yyn != yypact_ninf_)
|
|
||||||
{
|
|
||||||
yyn += yyterror_;
|
|
||||||
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
|
|
||||||
{
|
|
||||||
yyn = yytable_[yyn];
|
|
||||||
if (0 < yyn)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Pop the current state because it cannot handle the error token. */
|
|
||||||
if (yystate_stack_.height () == 1)
|
|
||||||
YYABORT;
|
|
||||||
|
|
||||||
yyerror_range[0] = yylocation_stack_[0];
|
|
||||||
yydestruct_ ("Error: popping",
|
|
||||||
yystos_[yystate],
|
|
||||||
&yysemantic_stack_[0], &yylocation_stack_[0]);
|
|
||||||
yypop_ ();
|
|
||||||
yystate = yystate_stack_[0];
|
|
||||||
YY_STACK_PRINT ();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (yyn == yyfinal_)
|
|
||||||
goto yyacceptlab;
|
|
||||||
|
|
||||||
yyerror_range[1] = yylloc;
|
|
||||||
// Using YYLLOC is tempting, but would change the location of
|
|
||||||
// the look-ahead. YYLOC is available though.
|
|
||||||
YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
|
|
||||||
yysemantic_stack_.push (yylval);
|
|
||||||
yylocation_stack_.push (yyloc);
|
|
||||||
|
|
||||||
/* Shift the error token. */
|
|
||||||
YY_SYMBOL_PRINT ("Shifting", yystos_[yyn],
|
|
||||||
&yysemantic_stack_[0], &yylocation_stack_[0]);
|
|
||||||
|
|
||||||
yystate = yyn;
|
|
||||||
goto yynewstate;
|
|
||||||
|
|
||||||
/* Accept. */
|
|
||||||
yyacceptlab:
|
|
||||||
yyresult = 0;
|
|
||||||
goto yyreturn;
|
|
||||||
|
|
||||||
/* Abort. */
|
|
||||||
yyabortlab:
|
|
||||||
yyresult = 1;
|
|
||||||
goto yyreturn;
|
|
||||||
|
|
||||||
yyreturn:
|
|
||||||
if (yychar != yyeof_ && yychar != yyempty_)
|
|
||||||
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 (yystate_stack_.height () != 1)
|
|
||||||
{
|
|
||||||
yydestruct_ ("Cleanup: popping",
|
|
||||||
yystos_[yystate_stack_[0]],
|
|
||||||
&yysemantic_stack_[0],
|
|
||||||
&yylocation_stack_[0]);
|
|
||||||
yypop_ ();
|
|
||||||
}
|
|
||||||
|
|
||||||
return yyresult;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate an error message.
|
|
||||||
std::string
|
|
||||||
parser::yysyntax_error_ (int yystate, int tok)
|
|
||||||
{
|
|
||||||
std::string res;
|
|
||||||
YYUSE (yystate);
|
|
||||||
#if YYERROR_VERBOSE
|
|
||||||
int yyn = yypact_[yystate];
|
|
||||||
if (yypact_ninf_ < yyn && yyn <= yylast_)
|
|
||||||
{
|
|
||||||
/* 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]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
res = YY_("syntax error");
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
|
|
||||||
STATE-NUM. */
|
|
||||||
const signed char parser::yypact_ninf_ = -1;
|
|
||||||
const signed char
|
|
||||||
parser::yypact_[] =
|
|
||||||
{
|
|
||||||
-1, 0, -1
|
|
||||||
};
|
|
||||||
|
|
||||||
/* 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
|
|
||||||
parser::yydefact_[] =
|
|
||||||
{
|
|
||||||
2, 0, 1
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYPGOTO[NTERM-NUM]. */
|
|
||||||
const signed char
|
|
||||||
parser::yypgoto_[] =
|
|
||||||
{
|
|
||||||
-1, -1
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYDEFGOTO[NTERM-NUM]. */
|
|
||||||
const signed char
|
|
||||||
parser::yydefgoto_[] =
|
|
||||||
{
|
|
||||||
-1, 1
|
|
||||||
};
|
|
||||||
|
|
||||||
/* 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 zero, do what YYDEFACT says. */
|
|
||||||
const signed char parser::yytable_ninf_ = -1;
|
|
||||||
const unsigned char
|
|
||||||
parser::yytable_[] =
|
|
||||||
{
|
|
||||||
2
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYCHECK. */
|
|
||||||
const unsigned char
|
|
||||||
parser::yycheck_[] =
|
|
||||||
{
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
/* STOS_[STATE-NUM] -- The (internal number of the) accessing
|
|
||||||
symbol of state STATE-NUM. */
|
|
||||||
const unsigned char
|
|
||||||
parser::yystos_[] =
|
|
||||||
{
|
|
||||||
0, 6, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
#if YYDEBUG
|
|
||||||
/* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
|
|
||||||
to YYLEX-NUM. */
|
|
||||||
const unsigned short int
|
|
||||||
parser::yytoken_number_[] =
|
|
||||||
{
|
|
||||||
0, 256, 257, 258, 259
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
|
|
||||||
const unsigned char
|
|
||||||
parser::yyr1_[] =
|
|
||||||
{
|
|
||||||
0, 5, 6
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
|
|
||||||
const unsigned char
|
|
||||||
parser::yyr2_[] =
|
|
||||||
{
|
|
||||||
0, 2, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
#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*
|
|
||||||
const parser::yytname_[] =
|
|
||||||
{
|
|
||||||
"$end", "error", "$undefined", "INT_NUMBER", "NAME", "$accept",
|
|
||||||
"statement_list_or_nothing", 0
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if YYDEBUG
|
|
||||||
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
|
||||||
const parser::rhs_number_type
|
|
||||||
parser::yyrhs_[] =
|
|
||||||
{
|
|
||||||
6, 0, -1, -1
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
|
|
||||||
YYRHS. */
|
|
||||||
const unsigned char
|
|
||||||
parser::yyprhs_[] =
|
|
||||||
{
|
|
||||||
0, 0, 3
|
|
||||||
};
|
|
||||||
|
|
||||||
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
|
|
||||||
const unsigned char
|
|
||||||
parser::yyrline_[] =
|
|
||||||
{
|
|
||||||
0, 70, 70
|
|
||||||
};
|
|
||||||
|
|
||||||
// Print the state stack on the debug stream.
|
|
||||||
void
|
|
||||||
parser::yystack_print_ ()
|
|
||||||
{
|
|
||||||
*yycdebug_ << "Stack now";
|
|
||||||
for (state_stack_type::const_iterator i = yystate_stack_.begin ();
|
|
||||||
i != yystate_stack_.end (); ++i)
|
|
||||||
*yycdebug_ << ' ' << *i;
|
|
||||||
*yycdebug_ << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Report on the debug stream that the rule \a yyrule is going to be reduced.
|
|
||||||
void
|
|
||||||
parser::yy_reduce_print_ (int yyrule)
|
|
||||||
{
|
|
||||||
unsigned int yylno = yyrline_[yyrule];
|
|
||||||
int yynrhs = yyr2_[yyrule];
|
|
||||||
/* Print the symbols being reduced, and their result. */
|
|
||||||
*yycdebug_ << "Reducing stack by rule " << yyrule - 1
|
|
||||||
<< " (line " << yylno << "), ";
|
|
||||||
/* The symbols being reduced. */
|
|
||||||
for (int yyi = 0; yyi < yynrhs; yyi++)
|
|
||||||
YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
|
|
||||||
yyrhs_[yyprhs_[yyrule] + yyi],
|
|
||||||
&(yysemantic_stack_[(yynrhs) - (yyi + 1)]),
|
|
||||||
&(yylocation_stack_[(yynrhs) - (yyi + 1)]));
|
|
||||||
}
|
|
||||||
#endif // YYDEBUG
|
|
||||||
|
|
||||||
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
|
||||||
parser::token_number_type
|
|
||||||
parser::yytranslate_ (int t)
|
|
||||||
{
|
|
||||||
static
|
|
||||||
const token_number_type
|
|
||||||
translate_table[] =
|
|
||||||
{
|
|
||||||
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 2, 2, 2, 2, 2, 1, 2, 3, 4
|
|
||||||
};
|
|
||||||
if ((unsigned int) t <= yyuser_token_number_max_)
|
|
||||||
return translate_table[t];
|
|
||||||
else
|
|
||||||
return yyundef_token_;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int parser::yyeof_ = 0;
|
|
||||||
const int parser::yylast_ = 0;
|
|
||||||
const int parser::yynnts_ = 2;
|
|
||||||
const int parser::yyempty_ = -2;
|
|
||||||
const int parser::yyfinal_ = 2;
|
|
||||||
const int parser::yyterror_ = 1;
|
|
||||||
const int parser::yyerrcode_ = 256;
|
|
||||||
const int parser::yyntokens_ = 5;
|
|
||||||
|
|
||||||
const unsigned int parser::yyuser_token_number_max_ = 259;
|
|
||||||
const parser::token_number_type parser::yyundef_token_ = 2;
|
|
||||||
|
|
||||||
} // namespace Macro
|
|
||||||
|
|
||||||
#line 72 "MacroBison.yy"
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
Macro::parser::error(const Macro::parser::location_type &l,
|
|
||||||
const string &m)
|
|
||||||
{
|
|
||||||
driver.error(l, m);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Local variables:
|
|
||||||
mode: C++
|
|
||||||
End:
|
|
||||||
*/
|
|
||||||
|
|
|
@ -1,302 +0,0 @@
|
||||||
/* A Bison parser, made by GNU Bison 2.3. */
|
|
||||||
|
|
||||||
/* Skeleton interface for Bison LALR(1) parsers in C++
|
|
||||||
|
|
||||||
Copyright (C) 2002, 2003, 2004, 2005, 2006 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
|
|
||||||
the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA. */
|
|
||||||
|
|
||||||
/* As a special exception, you may create a larger work that contains
|
|
||||||
part or all of the Bison parser skeleton and distribute that work
|
|
||||||
under terms of your choice, so long as that work isn't itself a
|
|
||||||
parser generator using the skeleton or a modified version thereof
|
|
||||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
|
||||||
the parser skeleton itself, you may (at your option) remove this
|
|
||||||
special exception, which will cause the skeleton and the resulting
|
|
||||||
Bison output files to be licensed under the GNU General Public
|
|
||||||
License without this special exception.
|
|
||||||
|
|
||||||
This special exception was added by the Free Software Foundation in
|
|
||||||
version 2.2 of Bison. */
|
|
||||||
|
|
||||||
/* C++ LALR(1) parser skeleton written by Akim Demaille. */
|
|
||||||
|
|
||||||
#ifndef PARSER_HEADER_H
|
|
||||||
# define PARSER_HEADER_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
#include "stack.hh"
|
|
||||||
|
|
||||||
namespace Macro
|
|
||||||
{
|
|
||||||
class position;
|
|
||||||
class location;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* First part of user declarations. */
|
|
||||||
#line 24 "MacroBison.yy"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class MacroDriver;
|
|
||||||
|
|
||||||
|
|
||||||
/* Line 35 of lalr1.cc. */
|
|
||||||
#line 60 "MacroBison.hh"
|
|
||||||
|
|
||||||
#include "location.hh"
|
|
||||||
|
|
||||||
/* Enabling traces. */
|
|
||||||
#ifndef YYDEBUG
|
|
||||||
# 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 Macro
|
|
||||||
{
|
|
||||||
|
|
||||||
/// A Bison parser.
|
|
||||||
class parser
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Symbol semantic values.
|
|
||||||
#ifndef YYSTYPE
|
|
||||||
union semantic_type
|
|
||||||
#line 49 "MacroBison.yy"
|
|
||||||
{
|
|
||||||
string *string_val;
|
|
||||||
int int_val;
|
|
||||||
}
|
|
||||||
/* Line 35 of lalr1.cc. */
|
|
||||||
#line 117 "MacroBison.hh"
|
|
||||||
;
|
|
||||||
#else
|
|
||||||
typedef YYSTYPE semantic_type;
|
|
||||||
#endif
|
|
||||||
/// Symbol locations.
|
|
||||||
typedef location location_type;
|
|
||||||
/// Tokens.
|
|
||||||
struct token
|
|
||||||
{
|
|
||||||
/* Tokens. */
|
|
||||||
enum yytokentype {
|
|
||||||
INT_NUMBER = 258,
|
|
||||||
NAME = 259
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
/// Token type.
|
|
||||||
typedef token::yytokentype token_type;
|
|
||||||
|
|
||||||
/// Build a parser object.
|
|
||||||
parser (MacroDriver &driver_yyarg, ostream &out_yyarg);
|
|
||||||
virtual ~parser ();
|
|
||||||
|
|
||||||
/// Parse.
|
|
||||||
/// \returns 0 iff parsing succeeded.
|
|
||||||
virtual int parse ();
|
|
||||||
|
|
||||||
/// The current debugging stream.
|
|
||||||
std::ostream& debug_stream () const;
|
|
||||||
/// Set the current debugging stream.
|
|
||||||
void set_debug_stream (std::ostream &);
|
|
||||||
|
|
||||||
/// Type for debugging levels.
|
|
||||||
typedef int debug_level_type;
|
|
||||||
/// The current debugging level.
|
|
||||||
debug_level_type debug_level () const;
|
|
||||||
/// Set the current debugging level.
|
|
||||||
void set_debug_level (debug_level_type l);
|
|
||||||
|
|
||||||
private:
|
|
||||||
/// Report a syntax error.
|
|
||||||
/// \param loc where the syntax error is found.
|
|
||||||
/// \param msg a description of the syntax error.
|
|
||||||
virtual void error (const location_type& loc, const std::string& msg);
|
|
||||||
|
|
||||||
/// Generate an error message.
|
|
||||||
/// \param state the state where the error occurred.
|
|
||||||
/// \param tok the look-ahead token.
|
|
||||||
virtual std::string yysyntax_error_ (int yystate, int tok);
|
|
||||||
|
|
||||||
#if YYDEBUG
|
|
||||||
/// \brief Report a symbol value on the debug stream.
|
|
||||||
/// \param yytype The token type.
|
|
||||||
/// \param yyvaluep Its semantic value.
|
|
||||||
/// \param yylocationp Its location.
|
|
||||||
virtual void yy_symbol_value_print_ (int yytype,
|
|
||||||
const semantic_type* yyvaluep,
|
|
||||||
const location_type* yylocationp);
|
|
||||||
/// \brief Report a symbol on the debug stream.
|
|
||||||
/// \param yytype The token type.
|
|
||||||
/// \param yyvaluep Its semantic value.
|
|
||||||
/// \param yylocationp Its location.
|
|
||||||
virtual void yy_symbol_print_ (int yytype,
|
|
||||||
const semantic_type* yyvaluep,
|
|
||||||
const location_type* yylocationp);
|
|
||||||
#endif /* ! YYDEBUG */
|
|
||||||
|
|
||||||
|
|
||||||
/// State numbers.
|
|
||||||
typedef int state_type;
|
|
||||||
/// State stack type.
|
|
||||||
typedef stack<state_type> state_stack_type;
|
|
||||||
/// Semantic value stack type.
|
|
||||||
typedef stack<semantic_type> semantic_stack_type;
|
|
||||||
/// location stack type.
|
|
||||||
typedef stack<location_type> location_stack_type;
|
|
||||||
|
|
||||||
/// The state stack.
|
|
||||||
state_stack_type yystate_stack_;
|
|
||||||
/// The semantic value stack.
|
|
||||||
semantic_stack_type yysemantic_stack_;
|
|
||||||
/// The location stack.
|
|
||||||
location_stack_type yylocation_stack_;
|
|
||||||
|
|
||||||
/// Internal symbol numbers.
|
|
||||||
typedef unsigned char token_number_type;
|
|
||||||
/* Tables. */
|
|
||||||
/// For a state, the index in \a yytable_ of its portion.
|
|
||||||
static const signed char yypact_[];
|
|
||||||
static const signed char yypact_ninf_;
|
|
||||||
|
|
||||||
/// 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_[];
|
|
||||||
|
|
||||||
static const signed char yypgoto_[];
|
|
||||||
static const signed char yydefgoto_[];
|
|
||||||
|
|
||||||
/// What to do in a state.
|
|
||||||
/// \a yytable_[yypact_[s]]: what to do in state \a s.
|
|
||||||
/// - if positive, shift that token.
|
|
||||||
/// - if negative, reduce the rule which number is the opposite.
|
|
||||||
/// - if zero, do what YYDEFACT says.
|
|
||||||
static const unsigned char yytable_[];
|
|
||||||
static const signed char yytable_ninf_;
|
|
||||||
|
|
||||||
static const unsigned char yycheck_[];
|
|
||||||
|
|
||||||
/// For a state, its accessing symbol.
|
|
||||||
static const unsigned char yystos_[];
|
|
||||||
|
|
||||||
/// For a rule, its LHS.
|
|
||||||
static const unsigned char yyr1_[];
|
|
||||||
/// For a rule, its RHS length.
|
|
||||||
static const unsigned char yyr2_[];
|
|
||||||
|
|
||||||
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
|
||||||
/// For a symbol, its name in clear.
|
|
||||||
static const char* const yytname_[];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#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;
|
|
||||||
/// A `-1'-separated list of the rules' RHS.
|
|
||||||
static const rhs_number_type yyrhs_[];
|
|
||||||
/// For each rule, the index of the first RHS symbol in \a yyrhs_.
|
|
||||||
static const unsigned char yyprhs_[];
|
|
||||||
/// For each rule, its source line number.
|
|
||||||
static const unsigned char yyrline_[];
|
|
||||||
/// For each scanner token number, its symbol number.
|
|
||||||
static const unsigned short int yytoken_number_[];
|
|
||||||
/// Report on the debug stream that the rule \a r is going to be reduced.
|
|
||||||
virtual void yy_reduce_print_ (int r);
|
|
||||||
/// Print the state stack on the debug stream.
|
|
||||||
virtual void yystack_print_ ();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// Convert a scanner token number \a t to a symbol number.
|
|
||||||
token_number_type yytranslate_ (int t);
|
|
||||||
|
|
||||||
/// \brief Reclaim the memory associated to a symbol.
|
|
||||||
/// \param yymsg Why this token is reclaimed.
|
|
||||||
/// \param yytype The symbol type.
|
|
||||||
/// \param yyvaluep Its semantic value.
|
|
||||||
/// \param yylocationp Its location.
|
|
||||||
inline void yydestruct_ (const char* yymsg,
|
|
||||||
int yytype,
|
|
||||||
semantic_type* yyvaluep,
|
|
||||||
location_type* yylocationp);
|
|
||||||
|
|
||||||
/// Pop \a n symbols the three stacks.
|
|
||||||
inline void yypop_ (unsigned int n = 1);
|
|
||||||
|
|
||||||
/* Constants. */
|
|
||||||
static const int yyeof_;
|
|
||||||
/* LAST_ -- Last index in TABLE_. */
|
|
||||||
static const int yylast_;
|
|
||||||
static const int yynnts_;
|
|
||||||
static const int yyempty_;
|
|
||||||
static const int yyfinal_;
|
|
||||||
static const int yyterror_;
|
|
||||||
static const int yyerrcode_;
|
|
||||||
static const int yyntokens_;
|
|
||||||
static const unsigned int yyuser_token_number_max_;
|
|
||||||
static const token_number_type yyundef_token_;
|
|
||||||
|
|
||||||
/* Debugging. */
|
|
||||||
int yydebug_;
|
|
||||||
std::ostream* yycdebug_;
|
|
||||||
|
|
||||||
|
|
||||||
/* User arguments. */
|
|
||||||
MacroDriver &driver;
|
|
||||||
ostream &out;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* ! defined PARSER_HEADER_H */
|
|
File diff suppressed because it is too large
Load Diff
|
@ -14,9 +14,14 @@ MacroBison.cc MacroBison.hh: MacroBison.yy MacroDriver.hh
|
||||||
bison --verbose -o MacroBison.cc MacroBison.yy
|
bison --verbose -o MacroBison.cc MacroBison.yy
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o *.P *~ MacroBison.output MacroFlex.cc libmacro.a
|
rm -f *.o *.P *~ \
|
||||||
|
MacroFlex.cc \
|
||||||
|
MacroBison.output \
|
||||||
|
MacroBison.cc \
|
||||||
|
MacroBison.hh \
|
||||||
|
location.hh \
|
||||||
|
stack.hh \
|
||||||
|
position.hh \
|
||||||
|
libmacro.a
|
||||||
|
|
||||||
distclean: clean
|
.PHONY: clean
|
||||||
rm -f MacroBison.cc MacroBison.hh location.hh stack.hh position.hh
|
|
||||||
|
|
||||||
.PHONY: clean distclean
|
|
||||||
|
|
|
@ -1,145 +0,0 @@
|
||||||
/* A Bison parser, made by GNU Bison 2.3. */
|
|
||||||
|
|
||||||
/* Locations for Bison parsers in C++
|
|
||||||
|
|
||||||
Copyright (C) 2002, 2003, 2004, 2005, 2006 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
|
|
||||||
the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA. */
|
|
||||||
|
|
||||||
/* As a special exception, you may create a larger work that contains
|
|
||||||
part or all of the Bison parser skeleton and distribute that work
|
|
||||||
under terms of your choice, so long as that work isn't itself a
|
|
||||||
parser generator using the skeleton or a modified version thereof
|
|
||||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
|
||||||
the parser skeleton itself, you may (at your option) remove this
|
|
||||||
special exception, which will cause the skeleton and the resulting
|
|
||||||
Bison output files to be licensed under the GNU General Public
|
|
||||||
License without this special exception.
|
|
||||||
|
|
||||||
This special exception was added by the Free Software Foundation in
|
|
||||||
version 2.2 of Bison. */
|
|
||||||
|
|
||||||
/**
|
|
||||||
** \file location.hh
|
|
||||||
** Define the Macro::location class.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef BISON_LOCATION_HH
|
|
||||||
# define BISON_LOCATION_HH
|
|
||||||
|
|
||||||
# include <iostream>
|
|
||||||
# include <string>
|
|
||||||
# include "position.hh"
|
|
||||||
|
|
||||||
namespace Macro
|
|
||||||
{
|
|
||||||
|
|
||||||
/// Abstract a location.
|
|
||||||
class location
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// Construct a location.
|
|
||||||
location ()
|
|
||||||
: begin (), end ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Initialization.
|
|
||||||
inline void initialize (std::string* fn)
|
|
||||||
{
|
|
||||||
begin.initialize (fn);
|
|
||||||
end = begin;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \name Line and Column related manipulators
|
|
||||||
** \{ */
|
|
||||||
public:
|
|
||||||
/// Reset initial location to final location.
|
|
||||||
inline void step ()
|
|
||||||
{
|
|
||||||
begin = end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extend the current location to the COUNT next columns.
|
|
||||||
inline void columns (unsigned int count = 1)
|
|
||||||
{
|
|
||||||
end += count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extend the current location to the COUNT next lines.
|
|
||||||
inline void lines (unsigned int count = 1)
|
|
||||||
{
|
|
||||||
end.lines (count);
|
|
||||||
}
|
|
||||||
/** \} */
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// Beginning of the located region.
|
|
||||||
position begin;
|
|
||||||
/// End of the located region.
|
|
||||||
position end;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Join two location objects to create a location.
|
|
||||||
inline const location operator+ (const location& begin, const location& end)
|
|
||||||
{
|
|
||||||
location res = begin;
|
|
||||||
res.end = end.end;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add two location objects.
|
|
||||||
inline const location operator+ (const location& begin, unsigned int width)
|
|
||||||
{
|
|
||||||
location res = begin;
|
|
||||||
res.columns (width);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add and assign a location.
|
|
||||||
inline location& operator+= (location& res, unsigned int width)
|
|
||||||
{
|
|
||||||
res.columns (width);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief Intercept output stream redirection.
|
|
||||||
** \param ostr the destination output stream
|
|
||||||
** \param loc a reference to the location to redirect
|
|
||||||
**
|
|
||||||
** Avoid duplicate information.
|
|
||||||
*/
|
|
||||||
inline std::ostream& operator<< (std::ostream& ostr, const location& loc)
|
|
||||||
{
|
|
||||||
position last = loc.end - 1;
|
|
||||||
ostr << loc.begin;
|
|
||||||
if (last.filename
|
|
||||||
&& (!loc.begin.filename
|
|
||||||
|| *loc.begin.filename != *last.filename))
|
|
||||||
ostr << '-' << last;
|
|
||||||
else if (loc.begin.line != last.line)
|
|
||||||
ostr << '-' << last.line << '.' << last.column;
|
|
||||||
else if (loc.begin.column != last.column)
|
|
||||||
ostr << '-' << last.column;
|
|
||||||
return ostr;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // not BISON_LOCATION_HH
|
|
|
@ -1,142 +0,0 @@
|
||||||
/* A Bison parser, made by GNU Bison 2.3. */
|
|
||||||
|
|
||||||
/* Positions for Bison parsers in C++
|
|
||||||
|
|
||||||
Copyright (C) 2002, 2003, 2004, 2005, 2006 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
|
|
||||||
the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA. */
|
|
||||||
|
|
||||||
/* As a special exception, you may create a larger work that contains
|
|
||||||
part or all of the Bison parser skeleton and distribute that work
|
|
||||||
under terms of your choice, so long as that work isn't itself a
|
|
||||||
parser generator using the skeleton or a modified version thereof
|
|
||||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
|
||||||
the parser skeleton itself, you may (at your option) remove this
|
|
||||||
special exception, which will cause the skeleton and the resulting
|
|
||||||
Bison output files to be licensed under the GNU General Public
|
|
||||||
License without this special exception.
|
|
||||||
|
|
||||||
This special exception was added by the Free Software Foundation in
|
|
||||||
version 2.2 of Bison. */
|
|
||||||
|
|
||||||
/**
|
|
||||||
** \file position.hh
|
|
||||||
** Define the Macro::position class.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef BISON_POSITION_HH
|
|
||||||
# define BISON_POSITION_HH
|
|
||||||
|
|
||||||
# include <iostream>
|
|
||||||
# include <string>
|
|
||||||
|
|
||||||
namespace Macro
|
|
||||||
{
|
|
||||||
/// Abstract a position.
|
|
||||||
class position
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
/// Construct a position.
|
|
||||||
position ()
|
|
||||||
: filename (0), line (1), column (0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Initialization.
|
|
||||||
inline void initialize (std::string* fn)
|
|
||||||
{
|
|
||||||
filename = fn;
|
|
||||||
line = 1;
|
|
||||||
column = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \name Line and Column related manipulators
|
|
||||||
** \{ */
|
|
||||||
public:
|
|
||||||
/// (line related) Advance to the COUNT next lines.
|
|
||||||
inline void lines (int count = 1)
|
|
||||||
{
|
|
||||||
column = 0;
|
|
||||||
line += count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// (column related) Advance to the COUNT next columns.
|
|
||||||
inline void columns (int count = 1)
|
|
||||||
{
|
|
||||||
int leftmost = 0;
|
|
||||||
int current = column;
|
|
||||||
if (leftmost <= current + count)
|
|
||||||
column += count;
|
|
||||||
else
|
|
||||||
column = 0;
|
|
||||||
}
|
|
||||||
/** \} */
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// File name to which this position refers.
|
|
||||||
std::string* filename;
|
|
||||||
/// Current line number.
|
|
||||||
unsigned int line;
|
|
||||||
/// Current column number.
|
|
||||||
unsigned int column;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Add and assign a position.
|
|
||||||
inline const position&
|
|
||||||
operator+= (position& res, const int width)
|
|
||||||
{
|
|
||||||
res.columns (width);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add two position objects.
|
|
||||||
inline const position
|
|
||||||
operator+ (const position& begin, const int width)
|
|
||||||
{
|
|
||||||
position res = begin;
|
|
||||||
return res += width;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add and assign a position.
|
|
||||||
inline const position&
|
|
||||||
operator-= (position& res, const int width)
|
|
||||||
{
|
|
||||||
return res += -width;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add two position objects.
|
|
||||||
inline const position
|
|
||||||
operator- (const position& begin, const int width)
|
|
||||||
{
|
|
||||||
return begin + -width;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief Intercept output stream redirection.
|
|
||||||
** \param ostr the destination output stream
|
|
||||||
** \param pos a reference to the position to redirect
|
|
||||||
*/
|
|
||||||
inline std::ostream&
|
|
||||||
operator<< (std::ostream& ostr, const position& pos)
|
|
||||||
{
|
|
||||||
if (pos.filename)
|
|
||||||
ostr << *pos.filename << ':';
|
|
||||||
return ostr << pos.line << '.' << pos.column;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif // not BISON_POSITION_HH
|
|
|
@ -1,129 +0,0 @@
|
||||||
/* A Bison parser, made by GNU Bison 2.3. */
|
|
||||||
|
|
||||||
/* Stack handling for Bison parsers in C++
|
|
||||||
|
|
||||||
Copyright (C) 2002, 2003, 2004, 2005, 2006 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
|
|
||||||
the Free Software Foundation; either version 2, or (at your option)
|
|
||||||
any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA. */
|
|
||||||
|
|
||||||
/* As a special exception, you may create a larger work that contains
|
|
||||||
part or all of the Bison parser skeleton and distribute that work
|
|
||||||
under terms of your choice, so long as that work isn't itself a
|
|
||||||
parser generator using the skeleton or a modified version thereof
|
|
||||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
|
||||||
the parser skeleton itself, you may (at your option) remove this
|
|
||||||
special exception, which will cause the skeleton and the resulting
|
|
||||||
Bison output files to be licensed under the GNU General Public
|
|
||||||
License without this special exception.
|
|
||||||
|
|
||||||
This special exception was added by the Free Software Foundation in
|
|
||||||
version 2.2 of Bison. */
|
|
||||||
|
|
||||||
#ifndef BISON_STACK_HH
|
|
||||||
# define BISON_STACK_HH
|
|
||||||
|
|
||||||
#include <deque>
|
|
||||||
|
|
||||||
namespace Macro
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
|
|
||||||
stack () : seq_ ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
stack (unsigned int n) : seq_ (n)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
T&
|
|
||||||
operator [] (unsigned int i)
|
|
||||||
{
|
|
||||||
return seq_[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
const T&
|
|
||||||
operator [] (unsigned int i) const
|
|
||||||
{
|
|
||||||
return seq_[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
void
|
|
||||||
push (const T& t)
|
|
||||||
{
|
|
||||||
seq_.push_front (t);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
void
|
|
||||||
pop (unsigned int n = 1)
|
|
||||||
{
|
|
||||||
for (; n; --n)
|
|
||||||
seq_.pop_front ();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
unsigned int
|
|
||||||
height () const
|
|
||||||
{
|
|
||||||
return seq_.size ();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const_iterator begin () const { return seq_.rbegin (); }
|
|
||||||
inline const_iterator end () const { return seq_.rend (); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
S seq_;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Present a slice of the top of a stack.
|
|
||||||
template <class T, class S = stack<T> >
|
|
||||||
class slice
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
slice (const S& stack,
|
|
||||||
unsigned int range) : stack_ (stack),
|
|
||||||
range_ (range)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
const T&
|
|
||||||
operator [] (unsigned int i) const
|
|
||||||
{
|
|
||||||
return stack_[range_ - i];
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
const S& stack_;
|
|
||||||
unsigned int range_;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // not BISON_STACK_HH
|
|
Loading…
Reference in New Issue