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

📄 oaverilogparser.skl

📁 openaccess与verilog互相转化时所用的源代码
💻 SKL
📖 第 1 页 / 共 3 页
字号:
m4_divert(-1)# C++ skeleton for Bison# Copyright (C) 2002, 2003 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA# 02111-1307  USA## ---------------- #### Default values.  #### ---------------- ### Default Parser class name.m4_define_default([b4_parser_class_name], [Parser])m4_define_default([b4_parser_namespace], [oaVerilog])m4_define_default([b4_root], [ParserBase])## ----------------- #### Semantic Values.  #### ----------------- ### b4_lhs_value([TYPE])# --------------------# Expansion of $<TYPE>$.m4_define([b4_lhs_value],[yyval[]m4_ifval([$1], [.$1])])# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])# --------------------------------------# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH# symbols on RHS.m4_define([b4_rhs_value],[semantic_stack_@{m4_eval([$1 - $2])@}m4_ifval([$3], [.$3])])m4_define_default([b4_location_type], [Location])# b4_lhs_location()# -----------------# Expansion of @$.m4_define([b4_lhs_location],[yyloc])# b4_rhs_location(RULE-LENGTH, NUM)# ---------------------------------# Expansion of @NUM, where the current rule has RULE-LENGTH symbols# on RHS.m4_define([b4_rhs_location],[location_stack_@{m4_eval([$1 - $2])@}])m4_define([b4_inherit],          [m4_ifdef([b4_root],		    [: public b4_root],		    [])])m4_define([b4_param],	  [m4_ifdef([b4_root],	            [,            const ParserParam& param],		    [])])m4_define([b4_constructor],	  [m4_ifdef([b4_root],		    [b4_root (param),      ],		    [])])# b4_parse_param_decl# -------------------#  Constructor's extra arguments.m4_define([b4_parse_param_decl],          [m4_ifset([b4_parse_param], [, b4_c_ansi_formals(b4_parse_param)])])# b4_parse_param_cons# -------------------#  constructor's extra initialisations.m4_define([b4_parse_param_cons],          [m4_ifset([b4_parse_param],		    [,      b4_cc_constructor_calls(b4_parse_param)])])m4_define([b4_cc_constructor_calls],	  [m4_map_sep([b4_cc_constructor_call], [,      ], [$@])])m4_define([b4_cc_constructor_call],	  [$2($2)])# b4_parse_param_vars# -------------------#  Extra instance variables.m4_define([b4_parse_param_vars],          [m4_ifset([b4_parse_param],		    [    /* User arguments.  */b4_cc_var_decls(b4_parse_param)])])m4_define([b4_cc_var_decls],	  [m4_map_sep([b4_cc_var_decl], [], [$@])])m4_define([b4_cc_var_decl],	  [    $1;])# We do want M4 expansion after # for CPP macros.m4_changecom()m4_divert(0)dnlm4_if(b4_defines_flag, 0, [],[@output @output_header_name@b4_copyright([C++ Skeleton parser for LALR(1) parsing with Bison],             [2002, 2003])[/* FIXME: This is wrong, we want computed header guards.   I don't know why the macros are missing now. :( */#ifndef PARSER_HEADER_H# define PARSER_HEADER_H#include "stack.hh"#include "location.hh"#include <string>#include <iostream>/* Using locations.  */// Generalized parsers may need locations but the Verilog parser// does not.  Since a significant portion of the run time is spent// tracking something that is not used, the locations have been // disabled for the Verilog parser.// #define YYLSP_NEEDED ]b4_locations_flag[]b4_token_defines(b4_tokens)[/* Copy the first part of user declarations.  */]b4_pre_prologue[]/* Line __line__ of lalr1.cc.  */b4_syncline([@oline@], [@ofile@])[/* Enabling traces.  */#ifndef YYDEBUG# define YYDEBUG ]b4_debug[#endif/* Enabling verbose error message.  */#ifndef YYERROR_VERBOSE# define YYERROR_VERBOSE ]b4_error_verbose[#endif#ifndef YYSTYPE]m4_ifdef([b4_stype],[b4_syncline([b4_stype_line], [b4_filename])typedef union b4_stype yystype;/* Line __line__ of lalr1.cc.  */b4_syncline([@oline@], [@ofile@])],[typedef int yystype;])[# define YYSTYPE yystype#endif/* Copy the second part of user declarations.  */]b4_post_prologue[]/* Line __line__ of lalr1.cc.  */b4_syncline([@oline@], [@ofile@])[#ifndef YYLLOC_DEFAULT# define YYLLOC_DEFAULT(Current, Rhs, N) \   ((Current).end = Rhs[N].end)#endifnamespace ]b4_parser_namespace[{  class ]b4_parser_class_name[;  template < typename P >  struct Traits  {  };  template < >  struct Traits< ]b4_parser_class_name[ >  {    typedef ]b4_int_type_for([b4_translate])[ TokenNumberType;    typedef ]b4_int_type_for([b4_rhs])[       RhsNumberType;    typedef int      StateType;    typedef YYSTYPE  SemanticType;    // typedef ]b4_location_type[ LocationType;  };}namespace ]b4_parser_namespace[{  class ]b4_parser_class_name b4_inherit[  {  public:    typedef Traits< ]b4_parser_class_name[ >::TokenNumberType TokenNumberType;    typedef Traits< ]b4_parser_class_name[ >::RhsNumberType   RhsNumberType;    typedef Traits< ]b4_parser_class_name[ >::StateType       StateType;    typedef Traits< ]b4_parser_class_name[ >::SemanticType    SemanticType;    // typedef Traits< ]b4_parser_class_name[ >::LocationType    LocationType;    typedef Stack< StateType >    StateStack;    typedef Stack< SemanticType > SemanticStack;    // typedef Stack< LocationType > LocationStack;#if YYLSP_NEEDED    ]b4_parser_class_name[ (bool debug,	    LocationType initlocation][]b4_param[]b4_parse_param_decl[) :      ]b4_constructor[][debug_ (debug),      cdebug_ (std::cerr),      initlocation_ (initlocation)]b4_parse_param_cons[#else    ]b4_parser_class_name[ (bool debug][]b4_param[]b4_parse_param_decl[) :      ]b4_constructor[][debug_ (debug),      cdebug_ (std::cerr)]b4_parse_param_cons[#endif    {    }    virtual ~]b4_parser_class_name[ ()    {    }    virtual int parse ();  private:    virtual void lex_ ();    virtual void deletePos (int position);        virtual void error_ ();    virtual void clearStack_ ();    // virtual void print_ ();    /* Stacks.  */    StateStack    state_stack_;    SemanticStack semantic_stack_;    // LocationStack location_stack_;    /* Tables.  */    static const ]b4_int_type_for([b4_pact])[ pact_[];    static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ pact_ninf_;    static const ]b4_int_type_for([b4_defact])[ defact_[];    static const ]b4_int_type_for([b4_pgoto])[ pgoto_[];    static const ]b4_int_type_for([b4_defgoto])[ defgoto_[];    static const ]b4_int_type_for([b4_table])[ table_[];    static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ table_ninf_;    static const ]b4_int_type_for([b4_check])[ check_[];    static const ]b4_int_type_for([b4_r1])[ r1_[];    static const ]b4_int_type_for([b4_r2])[ r2_[];#if YYDEBUG || YYERROR_VERBOSE    static const char* const name_[];#endif    /* More tables, for debugging.  */#if YYDEBUG    static const RhsNumberType rhs_[];    static const ]b4_int_type_for([b4_prhs])[ prhs_[];    static const ]b4_int_type_for([b4_rline])[ rline_[];    static const ]b4_int_type_for([b4_stos])[ stos_[];    static const ]b4_int_type_for([b4_toknum])[ token_number_[];    virtual void reduce_print_ (int yyrule);    virtual void stack_print_ ();#endif    /* Even more tables.  */    static inline TokenNumberType translate_ (int token);    /* Constants.  */    static const int eof_;    /* LAST_ -- Last index in TABLE_.  */    static const int last_;    static const int nnts_;    static const int empty_;    static const int final_;    static const int terror_;    static const int errcode_;    static const int ntokens_;    static const unsigned user_token_number_max_;    static const TokenNumberType undef_token_;    /* State.  */    int n_;    int len_;    int state_;    /* Debugging.  */    int debug_;    std::ostream &cdebug_;    /* Lookahead and lookahead in internal form.  */    int looka_;    int ilooka_;    /* Message.  */    std::string message;    /* Semantic value and location of lookahead token.  */    SemanticType value;    // LocationType location;    /* @@$ and $$.  */    SemanticType yyval;    // LocationType yyloc;    /* Initial location.  */    // LocationType initlocation_;]b4_parse_param_vars[  };}#endif /* ! defined PARSER_HEADER_H */]])dnl@output @output_parser_name@b4_copyright([C++ Skeleton parser for LALR(1) parsing with Bison],             [2002, 2003])m4_if(b4_defines_flag, 0, [], [#include @output_header_name@])[const unsigned int ]b4_parser_namespace[::Position::initial_column = 0;const unsigned int ]b4_parser_namespace[::Position::initial_line = 1;    /* Enable debugging if requested.  */#if YYDEBUG# define YYCDEBUG    if (debug_) cdebug_# define YY_REDUCE_PRINT(Rule)		\do {					\  if (debug_)				\    reduce_print_ (Rule);		\} while (0)# define YY_STACK_PRINT()		\do {					\  if (debug_)				\    stack_print_ ();			\} while (0)#else /* !YYDEBUG */# define YYCDEBUG    if (0) cdebug_# define YY_REDUCE_PRINT(Rule)# define YY_STACK_PRINT()#endif /* !YYDEBUG */#define YYACCEPT	goto yyacceptlab#define YYABORT		goto yyabortlab#define YYERROR		goto yyerrorlabint]b4_parser_namespace[::]b4_parser_class_name[::parse (){try {  int nerrs = 0;  int errstatus = 0;  /* 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.  */  state_stack_ = StateStack (0);  semantic_stack_ = SemanticStack (1);  // location_stack_ = LocationStack (1);  /* Start.  */  state_ = 0;  looka_ = empty_;#if YYLSP_NEEDED  // location = initlocation_;#endif  YYCDEBUG << "Starting parse" << std::endl;  /* New state.  */ yynewstate:  state_stack_.push (state_);  YYCDEBUG << "Entering state " << state_ << std::endl;  goto yybackup;  /* Backup.  */ yybackup:  /* Try to take a decision without lookahead.  */  n_ = pact_[state_];  if (n_ == pact_ninf_)    goto yydefault;  /* Read a lookahead token.  */  if (looka_ == empty_)    {      YYCDEBUG << "Reading a token: ";      lex_ ();    }  /* Convert token to internal form.  */  if (looka_ <= 0)    {      looka_ = eof_;      ilooka_ = 0;      YYCDEBUG << "Now at end of input." << std::endl;    }  else    {      ilooka_ = translate_ (looka_);#if YYDEBUG      if (debug_)	{	  YYCDEBUG << "Next token is " << looka_		 << " (" << name_[ilooka_];	  // print_ ();	  YYCDEBUG << ')' << std::endl;	}#endif    }  /* If the proper action on seeing token YYTOKEN is to reduce or to

⌨️ 快捷键说明

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