⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lalr1.cc

📁 GNU的词法/语法分析器bison源码
💻 CC
📖 第 1 页 / 共 3 页
字号:
  ]b4_table[};/* YYCHECK.  */const ]b4_int_type_for([b4_check])[yy::]b4_parser_class_name[::yycheck_[] ={  ]b4_check[};/* STOS_[STATE-NUM] -- The (internal number of the) accessing   symbol of state STATE-NUM.  */const ]b4_int_type_for([b4_stos])[yy::]b4_parser_class_name[::yystos_[] ={  ]b4_stos[};#if YYDEBUG/* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding   to YYLEX-NUM.  */const ]b4_int_type_for([b4_toknum])[yy::]b4_parser_class_name[::yytoken_number_[] ={  ]b4_toknum[};#endif/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */const ]b4_int_type_for([b4_r1])[yy::]b4_parser_class_name[::yyr1_[] ={  ]b4_r1[};/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */const ]b4_int_type_for([b4_r2])[yy::]b4_parser_class_name[::yyr2_[] ={  ]b4_r2[};#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 yy::]b4_parser_class_name[::yytname_[] ={  ]b4_tname[};#endif#if YYDEBUG/* YYRHS -- A `-1'-separated list of the rules' RHS. */const yy::]b4_parser_class_name[::rhs_number_typeyy::]b4_parser_class_name[::yyrhs_[] ={  ]b4_rhs[};/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in   YYRHS.  */const ]b4_int_type_for([b4_prhs])[yy::]b4_parser_class_name[::yyprhs_[] ={  ]b4_prhs[};/* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */const ]b4_int_type_for([b4_rline])[yy::]b4_parser_class_name[::yyrline_[] ={  ]b4_rline[};// Print the state stack on the debug stream.voidyy::]b4_parser_class_name[::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.voidyy::]b4_parser_class_name[::yyreduce_print_ (int yyrule){  unsigned int yylno = yyrline_[yyrule];  /* Print the symbols being reduced, and their result.  */  *yycdebug_ << "Reducing stack by rule " << yyn_ - 1             << " (line " << yylno << "), ";  for (]b4_int_type_for([b4_prhs])[ i = yyprhs_[yyn_];       0 <= yyrhs_[i]; ++i)    *yycdebug_ << yytname_[yyrhs_[i]] << ' ';  *yycdebug_ << "-> " << yytname_[yyr1_[yyn_]] << std::endl;}#endif // YYDEBUG/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */yy::]b4_parser_class_name[::token_number_typeyy::]b4_parser_class_name[::yytranslate_ (int token){  static  const token_number_type  translate_table[] =  {    ]b4_translate[  };  if ((unsigned int) token <= yyuser_token_number_max_)    return translate_table[token];  else    return yyundef_token_;}const int yy::]b4_parser_class_name[::yyeof_ = 0;const int yy::]b4_parser_class_name[::yylast_ = ]b4_last[;const int yy::]b4_parser_class_name[::yynnts_ = ]b4_nterms_number[;const int yy::]b4_parser_class_name[::yyempty_ = -2;const int yy::]b4_parser_class_name[::yyfinal_ = ]b4_final_state_number[;const int yy::]b4_parser_class_name[::yyterror_ = 1;const int yy::]b4_parser_class_name[::yyerrcode_ = 256;const int yy::]b4_parser_class_name[::yyntokens_ = ]b4_tokens_number[;const unsigned int yy::]b4_parser_class_name[::yyuser_token_number_max_ = ]b4_user_token_number_max[;const yy::]b4_parser_class_name[::token_number_type yy::]b4_parser_class_name[::yyundef_token_ = ]b4_undef_token_number[;]b4_epiloguednl@output stack.hhb4_copyright([stack handling for Bison C++ parsers], [2002, 2003, 2004, 2005])[#ifndef BISON_STACK_HH# define BISON_STACK_HH#include <deque>namespace yy{  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]dnl@output position.hhb4_copyright([Position class for Bison C++ parsers], [2002, 2003, 2004, 2005])[/** ** \file position.hh ** Define the position class. */#ifndef BISON_POSITION_HH# define BISON_POSITION_HH# include <iostream># include <string>namespace yy{  /// Abstract a position.  class position  {  public:    /// Initial column number.    static const unsigned int initial_column = 0;    /// Initial line number.    static const unsigned int initial_line = 1;    /** \name Ctor & dtor.     ** \{ */  public:    /// Construct a position.    position () :      filename (0),      line (initial_line),      column (initial_column)    {    }    /** \} */    /** \name Line and Column related manipulators     ** \{ */  public:    /// (line related) Advance to the COUNT next lines.    inline void lines (int count = 1)    {      column = initial_column;      line += count;    }    /// (column related) Advance to the COUNT next columns.    inline void columns (int count = 1)    {      int leftmost = initial_column;      int current  = column;      if (leftmost <= current + count)	column += count;      else	column = initial_column;    }    /** \} */  public:    /// File name to which this position refers.    ]b4_filename_type[* 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]@output location.hhb4_copyright([Location class for Bison C++ parsers], [2002, 2003, 2004, 2005])[/** ** \file location.hh ** Define the location class. */#ifndef BISON_LOCATION_HH# define BISON_LOCATION_HH# include <iostream># include <string># include "position.hh"namespace yy{  /// Abstract a location.  class location  {    /** \name Ctor & dtor.     ** \{ */  public:    /// Construct a location.    location () :      begin (),      end ()    {    }    /** \} */    /** \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]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -