/[bison]/bison/data/bison.c++
ViewVC logotype

Diff of /bison/data/bison.c++

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.25 by akim, Thu May 2 14:33:48 2002 UTC revision 1.26 by ra, Thu May 2 16:43:00 2002 UTC
# Line 32  m4_define([b4_lhs_value], Line 32  m4_define([b4_lhs_value],
32  # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH  # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
33  # symbols on RHS.  # symbols on RHS.
34  m4_define([b4_rhs_value],  m4_define([b4_rhs_value],
35  [yyvsp@<:@m4_eval([$2 - $1])@:>@m4_ifval([$3], [.$3])])  [semantic_stack_@<:@m4_eval([$1 - $2])@:>@m4_ifval([$3], [.$3])])
36    
37    
38  # b4_lhs_location()  # b4_lhs_location()
# Line 47  m4_define([b4_lhs_location], Line 47  m4_define([b4_lhs_location],
47  # Expansion of @NUM, where the current rule has RULE-LENGTH symbols  # Expansion of @NUM, where the current rule has RULE-LENGTH symbols
48  # on RHS.  # on RHS.
49  m4_define([b4_rhs_location],  m4_define([b4_rhs_location],
50  [yylsp@<:@m4_eval([$2 - $1])@:>@])  [location_stack_@<:@m4_eval([$1 - $2])@:>@])
51    
52    
53  # b4_token_defines(TOKEN-NAME, TOKEN-NUMBER)  # b4_token_defines(TOKEN-NAME, TOKEN-NUMBER)
# Line 351  yy::b4_name::parse () Line 351  yy::b4_name::parse ()
351    semantic_stack_ = SemanticStack (1);    semantic_stack_ = SemanticStack (1);
352    location_stack_ = LocationStack (1);    location_stack_ = LocationStack (1);
353    
   /* Reserve initial space.  The C parser needed that, but is it really  
      useful here?  */  
   state_stack_.reserve (initdepth_);  
   semantic_stack_.reserve (initdepth_);  
   location_stack_.reserve (initdepth_);  
   
354    /* Start.  */    /* Start.  */
355    state_ = 0;    state_ = 0;
356    looka_ = empty_;    looka_ = empty_;
# Line 459  yy::b4_name::parse () Line 453  yy::b4_name::parse ()
453    len_ = r2_[[n_]];    len_ = r2_[[n_]];
454    if (len_)    if (len_)
455      {      {
456        yyval = semantic_stack_[[1 - len_]];        yyval = semantic_stack_[[len_ - 1]];
457        yyloc = location_stack_[[1 - len_]];        yyloc = location_stack_[[len_ - 1]];
458      }      }
459    else    else
460      {      {
# Line 485  yy::b4_name::parse () Line 479  yy::b4_name::parse ()
479        YYLLOC_DEFAULT (yyloc, slice, len_);        YYLLOC_DEFAULT (yyloc, slice, len_);
480      }      }
481    
482    {    switch (n_)
483      SemanticStack& yyvsp (semantic_stack_);      {
484      LocationStack& yylsp (location_stack_);        b4_actions
485        }
     switch (n_)  
       {  
         b4_actions  
       }  
   }  
486    
487  /* Line __line__ of __file__.  */  /* Line __line__ of __file__.  */
488  #line __oline__ "__ofile__"  #line __oline__ "__ofile__"
# Line 786  b4_copyright Line 775  b4_copyright
775  #ifndef BISON_STACK_HH  #ifndef BISON_STACK_HH
776  # define BISON_STACK_HH  # define BISON_STACK_HH
777    
778  #include <vector>  #include <deque>
779    
780  namespace yy  namespace yy
781  {  {
782    template < class T, class S = std::vector< T > >    template < class T, class S = std::deque< T > >
783    class Stack    class Stack
784    {    {
785    public:    public:
# Line 808  namespace yy Line 797  namespace yy
797    
798      inline      inline
799      T&      T&
800      operator [[]] (int index)      operator [[]] (unsigned index)
801      {      {
802        return seq_[[height () - 1 + index]];        return seq_[[index]];
803      }      }
804    
805      inline      inline
806      const T&      const T&
807      operator [[]] (int index) const      operator [[]] (unsigned index) const
808      {      {
809        return seq_[[height () - 1 + index]];        return seq_[[index]];
810      }      }
811    
812      inline      inline
813      void      void
814      push (const T& t)      push (const T& t)
815      {      {
816        seq_.push_back (t);        seq_.push_front (t);
817      }      }
818    
819      inline      inline
# Line 832  namespace yy Line 821  namespace yy
821      pop (unsigned n = 1)      pop (unsigned n = 1)
822      {      {
823        for (; n; --n)        for (; n; --n)
824          seq_.pop_back ();          seq_.pop_front ();
     }  
   
     inline  
     void  
     reserve (unsigned n)  
     {  
       seq_.reserve (n);  
825      }      }
826    
827      inline      inline
# Line 872  namespace yy Line 854  namespace yy
854      const T&      const T&
855      operator [[]] (unsigned index) const      operator [[]] (unsigned index) const
856      {      {
857        return stack_[[index - range_]];        return stack_[[range_ - index]];
858      }      }
859    
860    private:    private:

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26