src/parser.h

Go to the documentation of this file.
00001 /* A Bison parser, made by GNU Bison 2.3.  */
00002 
00003 /* Skeleton interface for Bison LALR(1) parsers in C++
00004 
00005    Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2, or (at your option)
00010    any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program; if not, write to the Free Software
00019    Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020    Boston, MA 02110-1301, USA.  */
00021 
00022 /* As a special exception, you may create a larger work that contains
00023    part or all of the Bison parser skeleton and distribute that work
00024    under terms of your choice, so long as that work isn't itself a
00025    parser generator using the skeleton or a modified version thereof
00026    as a parser skeleton.  Alternatively, if you modify or redistribute
00027    the parser skeleton itself, you may (at your option) remove this
00028    special exception, which will cause the skeleton and the resulting
00029    Bison output files to be licensed under the GNU General Public
00030    License without this special exception.
00031 
00032    This special exception was added by the Free Software Foundation in
00033    version 2.2 of Bison.  */
00034 
00035 /* C++ LALR(1) parser skeleton written by Akim Demaille.  */
00036 
00037 #ifndef PARSER_HEADER_H
00038 # define PARSER_HEADER_H
00039 
00040 #include <string>
00041 #include <iostream>
00042 #include "stack.hh"
00043 
00044 namespace example
00045 {
00046   class position;
00047   class location;
00048 }
00049 
00050 /* First part of user declarations.  */
00051 #line 4 "parser.yy"
00052  /*** C/C++ Declarations ***/
00053 
00054 #include <stdio.h>
00055 #include <string>
00056 #include <vector>
00057 
00058 #include "expression.h"
00059 
00060 
00061 
00062 /* Line 35 of lalr1.cc.  */
00063 #line 64 "parser.h"
00064 
00065 #include "location.hh"
00066 
00067 /* Enabling traces.  */
00068 #ifndef YYDEBUG
00069 # define YYDEBUG 1
00070 #endif
00071 
00072 /* Enabling verbose error messages.  */
00073 #ifdef YYERROR_VERBOSE
00074 # undef YYERROR_VERBOSE
00075 # define YYERROR_VERBOSE 1
00076 #else
00077 # define YYERROR_VERBOSE 1
00078 #endif
00079 
00080 /* Enabling the token table.  */
00081 #ifndef YYTOKEN_TABLE
00082 # define YYTOKEN_TABLE 0
00083 #endif
00084 
00085 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
00086    If N is 0, then set CURRENT to the empty location which ends
00087    the previous symbol: RHS[0] (always defined).  */
00088 
00089 #ifndef YYLLOC_DEFAULT
00090 # define YYLLOC_DEFAULT(Current, Rhs, N)                \
00091 do {                                                    \
00092   if (N)                                                \
00093     {                                                   \
00094       (Current).begin = (Rhs)[1].begin;                 \
00095       (Current).end   = (Rhs)[N].end;                   \
00096     }                                                   \
00097   else                                                  \
00098     {                                                   \
00099       (Current).begin = (Current).end = (Rhs)[0].end;   \
00100     }                                                   \
00101 } while (false)
00102 #endif
00103 
00104 namespace example
00105 {
00106 
00108   class Parser
00109   {
00110   public:
00112 #ifndef YYSTYPE
00113     union semantic_type
00114 #line 56 "parser.yy"
00115 {
00116     int                         integerVal;
00117     double                      doubleVal;
00118     std::string*                stringVal;
00119     CalcNode*                   calcnode;
00120 }
00121 /* Line 35 of lalr1.cc.  */
00122 #line 123 "parser.h"
00123         ;
00124 #else
00125     typedef YYSTYPE semantic_type;
00126 #endif
00128     typedef location location_type;
00130     struct token
00131     {
00132       /* Tokens.  */
00133    enum yytokentype {
00134      END = 0,
00135      EOL = 258,
00136      INTEGER = 259,
00137      DOUBLE = 260,
00138      STRING = 261
00139    };
00140 
00141     };
00143     typedef token::yytokentype token_type;
00144 
00146     Parser (class Driver& driver_yyarg);
00147     virtual ~Parser ();
00148 
00151     virtual int parse ();
00152 
00154     std::ostream& debug_stream () const;
00156     void set_debug_stream (std::ostream &);
00157 
00159     typedef int debug_level_type;
00161     debug_level_type debug_level () const;
00163     void set_debug_level (debug_level_type l);
00164 
00165   private:
00169     virtual void error (const location_type& loc, const std::string& msg);
00170 
00174     virtual std::string yysyntax_error_ (int yystate, int tok);
00175 
00176 #if YYDEBUG
00181     virtual void yy_symbol_value_print_ (int yytype,
00182                                          const semantic_type* yyvaluep,
00183                                          const location_type* yylocationp);
00188     virtual void yy_symbol_print_ (int yytype,
00189                                    const semantic_type* yyvaluep,
00190                                    const location_type* yylocationp);
00191 #endif /* ! YYDEBUG */
00192 
00193 
00195     typedef int state_type;
00197     typedef stack<state_type>    state_stack_type;
00199     typedef stack<semantic_type> semantic_stack_type;
00201     typedef stack<location_type> location_stack_type;
00202 
00204     state_stack_type yystate_stack_;
00206     semantic_stack_type yysemantic_stack_;
00208     location_stack_type yylocation_stack_;
00209 
00211     typedef unsigned char token_number_type;
00212     /* Tables.  */
00214     static const signed char yypact_[];
00215     static const signed char yypact_ninf_;
00216 
00220     static const unsigned char yydefact_[];
00221 
00222     static const signed char yypgoto_[];
00223     static const signed char yydefgoto_[];
00224 
00230     static const unsigned char yytable_[];
00231     static const signed char yytable_ninf_;
00232 
00233     static const signed char yycheck_[];
00234 
00236     static const unsigned char yystos_[];
00237 
00239     static const unsigned char yyr1_[];
00241     static const unsigned char yyr2_[];
00242 
00243 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
00245     static const char* const yytname_[];
00246 #endif
00247 
00248 #if YYERROR_VERBOSE
00250     virtual std::string yytnamerr_ (const char *n);
00251 #endif
00252 
00253 #if YYDEBUG
00255     typedef signed char rhs_number_type;
00257     static const rhs_number_type yyrhs_[];
00259     static const unsigned char yyprhs_[];
00261     static const unsigned char yyrline_[];
00263     static const unsigned short int yytoken_number_[];
00265     virtual void yy_reduce_print_ (int r);
00267     virtual void yystack_print_ ();
00268 #endif
00269 
00271     token_number_type yytranslate_ (int t);
00272 
00278     inline void yydestruct_ (const char* yymsg,
00279                              int yytype,
00280                              semantic_type* yyvaluep,
00281                              location_type* yylocationp);
00282 
00284     inline void yypop_ (unsigned int n = 1);
00285 
00286     /* Constants.  */
00287     static const int yyeof_;
00288     /* LAST_ -- Last index in TABLE_.  */
00289     static const int yylast_;
00290     static const int yynnts_;
00291     static const int yyempty_;
00292     static const int yyfinal_;
00293     static const int yyterror_;
00294     static const int yyerrcode_;
00295     static const int yyntokens_;
00296     static const unsigned int yyuser_token_number_max_;
00297     static const token_number_type yyundef_token_;
00298 
00299     /* Debugging.  */
00300     int yydebug_;
00301     std::ostream* yycdebug_;
00302 
00303 
00304     /* User arguments.  */
00305     class Driver& driver;
00306   };
00307 }
00308 
00309 
00310 #endif /* ! defined PARSER_HEADER_H */

Generated on Mon Aug 20 13:34:21 2007 for Flex Bison C++ Example by  doxygen 1.5.2