Home | History | Annotate | Download | only in calc++
      1 /* A Bison parser, made by GNU Bison 2.6.90.8-d4fe.  */
      2 
      3 /* Skeleton interface for Bison LALR(1) parsers in C++
      4 
      5       Copyright (C) 2002-2012 Free Software Foundation, Inc.
      6 
      7    This program is free software: you can redistribute it and/or modify
      8    it under the terms of the GNU General Public License as published by
      9    the Free Software Foundation, either version 3 of the License, or
     10    (at your option) any later version.
     11 
     12    This program is distributed in the hope that it will be useful,
     13    but WITHOUT ANY WARRANTY; without even the implied warranty of
     14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15    GNU General Public License for more details.
     16 
     17    You should have received a copy of the GNU General Public License
     18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     19 
     20 /* As a special exception, you may create a larger work that contains
     21    part or all of the Bison parser skeleton and distribute that work
     22    under terms of your choice, so long as that work isn't itself a
     23    parser generator using the skeleton or a modified version thereof
     24    as a parser skeleton.  Alternatively, if you modify or redistribute
     25    the parser skeleton itself, you may (at your option) remove this
     26    special exception, which will cause the skeleton and the resulting
     27    Bison output files to be licensed under the GNU General Public
     28    License without this special exception.
     29 
     30    This special exception was added by the Free Software Foundation in
     31    version 2.2 of Bison.  */
     32 
     33 /**
     34  ** \file ../../../../examples/calc++/calc++-parser.hh
     35  ** Define the yy::parser class.
     36  */
     37 
     38 /* C++ LALR(1) parser skeleton written by Akim Demaille.  */
     39 
     40 #ifndef YY_YY_EXAMPLES_CALC_CALC_PARSER_HH_INCLUDED
     41 # define YY_YY_EXAMPLES_CALC_CALC_PARSER_HH_INCLUDED
     42 
     43 /* "%code requires" blocks.  */
     44 /* Line 33 of lalr1.cc  */
     45 #line 10214 "../../doc/bison.texi"
     46 
     47 # include <string>
     48 class calcxx_driver;
     49 
     50 
     51 /* Line 33 of lalr1.cc  */
     52 #line 53 "../../../../examples/calc++/calc++-parser.hh"
     53 
     54 
     55 #include <string>
     56 #include <iostream>
     57 #include "stack.hh"
     58 #include "location.hh"
     59 
     60 /* Enabling traces.  */
     61 #ifndef YYDEBUG
     62 # define YYDEBUG 1
     63 #endif
     64 
     65 
     66 namespace yy {
     67 /* Line 33 of lalr1.cc  */
     68 #line 69 "../../../../examples/calc++/calc++-parser.hh"
     69 
     70   /// A Bison parser.
     71   class calcxx_parser
     72   {
     73   public:
     74     /// Symbol semantic values.
     75 #ifndef YYSTYPE
     76     union semantic_type
     77     {
     78 /* Line 33 of lalr1.cc  */
     79 #line 10267 "../../doc/bison.texi"
     80 
     81   int          ival;
     82   std::string *sval;
     83 
     84 
     85 /* Line 33 of lalr1.cc  */
     86 #line 87 "../../../../examples/calc++/calc++-parser.hh"
     87     };
     88 #else
     89     typedef YYSTYPE semantic_type;
     90 #endif
     91     /// Symbol locations.
     92     typedef location location_type;
     93     /// Tokens.
     94     struct token
     95     {
     96       /* Tokens.  */
     97    enum yytokentype {
     98      END = 0,
     99      ASSIGN = 258,
    100      IDENTIFIER = 259,
    101      NUMBER = 260
    102    };
    103 
    104     };
    105     /// Token type.
    106     typedef token::yytokentype token_type;
    107 
    108     /// Build a parser object.
    109     calcxx_parser (calcxx_driver& driver_yyarg);
    110     virtual ~calcxx_parser ();
    111 
    112     /// Parse.
    113     /// \returns  0 iff parsing succeeded.
    114     virtual int parse ();
    115 
    116 #if YYDEBUG
    117     /// The current debugging stream.
    118     std::ostream& debug_stream () const;
    119     /// Set the current debugging stream.
    120     void set_debug_stream (std::ostream &);
    121 
    122     /// Type for debugging levels.
    123     typedef int debug_level_type;
    124     /// The current debugging level.
    125     debug_level_type debug_level () const;
    126     /// Set the current debugging level.
    127     void set_debug_level (debug_level_type l);
    128 #endif
    129 
    130   private:
    131     /// Report a syntax error.
    132     /// \param loc    where the syntax error is found.
    133     /// \param msg    a description of the syntax error.
    134     virtual void error (const location_type& loc, const std::string& msg);
    135 
    136     /// Generate an error message.
    137     /// \param state   the state where the error occurred.
    138     /// \param tok     the lookahead token.
    139     virtual std::string yysyntax_error_ (int yystate, int tok);
    140 
    141 #if YYDEBUG
    142     /// \brief Report a symbol value on the debug stream.
    143     /// \param yytype       The token type.
    144     /// \param yyvaluep     Its semantic value.
    145     /// \param yylocationp  Its location.
    146     virtual void yy_symbol_value_print_ (int yytype,
    147 					 const semantic_type* yyvaluep,
    148 					 const location_type* yylocationp);
    149     /// \brief Report a symbol on the debug stream.
    150     /// \param yytype       The token type.
    151     /// \param yyvaluep     Its semantic value.
    152     /// \param yylocationp  Its location.
    153     virtual void yy_symbol_print_ (int yytype,
    154 				   const semantic_type* yyvaluep,
    155 				   const location_type* yylocationp);
    156 #endif
    157 
    158 
    159     /// State numbers.
    160     typedef int state_type;
    161     /// State stack type.
    162     typedef stack<state_type>    state_stack_type;
    163     /// Semantic value stack type.
    164     typedef stack<semantic_type> semantic_stack_type;
    165     /// location stack type.
    166     typedef stack<location_type> location_stack_type;
    167 
    168     /// The state stack.
    169     state_stack_type yystate_stack_;
    170     /// The semantic value stack.
    171     semantic_stack_type yysemantic_stack_;
    172     /// The location stack.
    173     location_stack_type yylocation_stack_;
    174 
    175     /// Whether the given \c yypact_ value indicates a defaulted state.
    176     /// \param yyvalue   the value to check
    177     static bool yy_pact_value_is_default_ (int yyvalue);
    178 
    179     /// Whether the given \c yytable_ value indicates a syntax error.
    180     /// \param yyvalue   the value to check
    181     static bool yy_table_value_is_error_ (int yyvalue);
    182 
    183     /// Internal symbol numbers.
    184     typedef unsigned char token_number_type;
    185     /* Tables.  */
    186     /// For a state, the index in \a yytable_ of its portion.
    187     static const signed char yypact_[];
    188     static const signed char yypact_ninf_;
    189 
    190     /// For a state, default reduction number.
    191     /// Unless\a  yytable_ specifies something else to do.
    192     /// Zero means the default is an error.
    193     static const unsigned char yydefact_[];
    194 
    195     static const signed char yypgoto_[];
    196     static const signed char yydefgoto_[];
    197 
    198     /// What to do in a state.
    199     /// \a yytable_[yypact_[s]]: what to do in state \a s.
    200     /// - if positive, shift that token.
    201     /// - if negative, reduce the rule which number is the opposite.
    202     /// - if zero, do what YYDEFACT says.
    203     static const unsigned char yytable_[];
    204     static const signed char yytable_ninf_;
    205 
    206     static const signed char yycheck_[];
    207 
    208     /// For a state, its accessing symbol.
    209     static const unsigned char yystos_[];
    210 
    211     /// For a rule, its LHS.
    212     static const unsigned char yyr1_[];
    213     /// For a rule, its RHS length.
    214     static const unsigned char yyr2_[];
    215 
    216     /// Convert the symbol name \a n to a form suitable for a diagnostic.
    217     static std::string yytnamerr_ (const char *n);
    218 
    219 
    220     /// For a symbol, its name in clear.
    221     static const char* const yytname_[];
    222 #if YYDEBUG
    223     /// A type to store symbol numbers and -1.
    224     typedef signed char rhs_number_type;
    225     /// A `-1'-separated list of the rules' RHS.
    226     static const rhs_number_type yyrhs_[];
    227     /// For each rule, the index of the first RHS symbol in \a yyrhs_.
    228     static const unsigned char yyprhs_[];
    229     /// For each rule, its source line number.
    230     static const unsigned short int yyrline_[];
    231     /// For each scanner token number, its symbol number.
    232     static const unsigned short int yytoken_number_[];
    233     /// Report on the debug stream that the rule \a r is going to be reduced.
    234     virtual void yy_reduce_print_ (int r);
    235     /// Print the state stack on the debug stream.
    236     virtual void yystack_print_ ();
    237 
    238     /* Debugging.  */
    239     int yydebug_;
    240     std::ostream* yycdebug_;
    241 #endif
    242 
    243     /// Convert a scanner token number \a t to a symbol number.
    244     token_number_type yytranslate_ (int t);
    245 
    246     /// \brief Reclaim the memory associated to a symbol.
    247     /// \param yymsg        Why this token is reclaimed.
    248     ///                     If null, do not display the symbol, just free it.
    249     /// \param yytype       The symbol type.
    250     /// \param yyvaluep     Its semantic value.
    251     /// \param yylocationp  Its location.
    252     inline void yydestruct_ (const char* yymsg,
    253 			     int yytype,
    254 			     semantic_type* yyvaluep,
    255 			     location_type* yylocationp);
    256 
    257     /// Pop \a n symbols the three stacks.
    258     inline void yypop_ (unsigned int n = 1);
    259 
    260     /* Constants.  */
    261     static const int yyeof_;
    262     /* LAST_ -- Last index in TABLE_.  */
    263     static const int yylast_;
    264     static const int yynnts_;
    265     static const int yyempty_;
    266     static const int yyfinal_;
    267     static const int yyterror_;
    268     static const int yyerrcode_;
    269     static const int yyntokens_;
    270     static const unsigned int yyuser_token_number_max_;
    271     static const token_number_type yyundef_token_;
    272 
    273     /* User arguments.  */
    274     calcxx_driver& driver;
    275   };
    276 
    277 } // yy
    278 /* Line 33 of lalr1.cc  */
    279 #line 280 "../../../../examples/calc++/calc++-parser.hh"
    280 
    281 
    282 
    283 #endif /* !YY_YY_EXAMPLES_CALC_CALC_PARSER_HH_INCLUDED  */
    284