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

📄 mod_yacc.c

📁 ngspice又一个电子CAD仿真软件代码.功能更全
💻 C
📖 第 1 页 / 共 4 页
字号:
/* A Bison parser, made by GNU Bison 1.875d.  *//* Skeleton parser for Yacc-like parsing with Bison,   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 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, 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.  *//* As a special exception, when this file is copied by Bison into a   Bison output file, you may use that output file without restriction.   This special exception was added by the Free Software Foundation   in version 1.24 of Bison.  *//* Written by Richard Stallman by simplifying the original so called   ``semantic'' parser.  *//* All symbols defined below should begin with yy or YY, to avoid   infringing on user name space.  This should be done even for local   variables, as they might otherwise be expanded by user macros.   There are some unavoidable exceptions within include files to   define necessary library symbols; they are noted "INFRINGES ON   USER NAME SPACE" below.  *//* Identify Bison output.  */#define YYBISON 1/* Skeleton name.  */#define YYSKELETON_NAME "yacc.c"/* Pure parsers.  */#define YYPURE 0/* Using locations.  */#define YYLSP_NEEDED 0/* Tokens.  */#ifndef YYTOKENTYPE# define YYTOKENTYPE   /* Put the tokens into the symbol table, so that GDB and other debuggers      know about them.  */   enum yytokentype {     TOK_ARGS = 258,     TOK_INIT = 259,     TOK_ANALYSIS = 260,     TOK_NEW_TIMEPOINT = 261,     TOK_TIME = 262,     TOK_RAD_FREQ = 263,     TOK_TEMPERATURE = 264,     TOK_T = 265,     TOK_PARAM = 266,     TOK_PARAM_SIZE = 267,     TOK_PARAM_NULL = 268,     TOK_PORT_SIZE = 269,     TOK_PORT_NULL = 270,     TOK_PARTIAL = 271,     TOK_AC_GAIN = 272,     TOK_CHANGED = 273,     TOK_OUTPUT_DELAY = 274,     TOK_STATIC_VAR = 275,     TOK_STATIC_VAR_SIZE = 276,     TOK_INPUT = 277,     TOK_INPUT_STRENGTH = 278,     TOK_INPUT_STATE = 279,     TOK_INPUT_TYPE = 280,     TOK_OUTPUT = 281,     TOK_OUTPUT_CHANGED = 282,     TOK_OUTPUT_STRENGTH = 283,     TOK_OUTPUT_STATE = 284,     TOK_OUTPUT_TYPE = 285,     TOK_COMMA = 286,     TOK_LPAREN = 287,     TOK_RPAREN = 288,     TOK_LBRACKET = 289,     TOK_RBRACKET = 290,     TOK_MISC_C = 291,     TOK_IDENTIFIER = 292,     TOK_LOAD = 293,     TOK_TOTAL_LOAD = 294,     TOK_MESSAGE = 295,     TOK_CALL_TYPE = 296   };#endif#define TOK_ARGS 258#define TOK_INIT 259#define TOK_ANALYSIS 260#define TOK_NEW_TIMEPOINT 261#define TOK_TIME 262#define TOK_RAD_FREQ 263#define TOK_TEMPERATURE 264#define TOK_T 265#define TOK_PARAM 266#define TOK_PARAM_SIZE 267#define TOK_PARAM_NULL 268#define TOK_PORT_SIZE 269#define TOK_PORT_NULL 270#define TOK_PARTIAL 271#define TOK_AC_GAIN 272#define TOK_CHANGED 273#define TOK_OUTPUT_DELAY 274#define TOK_STATIC_VAR 275#define TOK_STATIC_VAR_SIZE 276#define TOK_INPUT 277#define TOK_INPUT_STRENGTH 278#define TOK_INPUT_STATE 279#define TOK_INPUT_TYPE 280#define TOK_OUTPUT 281#define TOK_OUTPUT_CHANGED 282#define TOK_OUTPUT_STRENGTH 283#define TOK_OUTPUT_STATE 284#define TOK_OUTPUT_TYPE 285#define TOK_COMMA 286#define TOK_LPAREN 287#define TOK_RPAREN 288#define TOK_LBRACKET 289#define TOK_RBRACKET 290#define TOK_MISC_C 291#define TOK_IDENTIFIER 292#define TOK_LOAD 293#define TOK_TOTAL_LOAD 294#define TOK_MESSAGE 295#define TOK_CALL_TYPE 296/* Copy the first part of user declarations.  */#line 1 "mod_yacc.y" /* $Id: mod_yacc.y,v 1.7 2005/05/10 21:50:43 sjborley Exp $ *//*============================================================================FILE  mod_yacc.yMEMBER OF process cmppCopyright 1991Georgia Tech Research CorporationAtlanta, Georgia 30332All Rights ReservedPROJECT A-8503AUTHORS    9/12/91  Steve TynorMODIFICATIONS    <date> <person name> <nature of modifications>  20050420 Steven Borley Renamed strcmpi() to local_strcmpi() to avoid                         clash with strcmpi() in a windows header file.SUMMARY    This file contains a BNF specification of the translation of    cfunc.mod files to cfunc.c files, together with various support    functions.INTERFACES    mod_yyparse() -    Function 'yyparse()' is generated automatically                       by UNIX 'yacc' utility and then converted to                       'mod_yyparse()' by UNIX 'sed' utility under                       direction of Makefile.REFERENCED FILES    mod_lex.lNON-STANDARD FEATURES    Names of functions generated by 'yacc' are translated by 'sed'    under direction of the Makefile to prevent collisions with    functions generated from ifs_yacc.y.============================================================================*/#include <assert.h>#include <stdio.h>#include <stdlib.h>#include "mod_yacc_y.h"#define	yymaxdepth mod_yymaxdepth#define	yyparse	mod_yyparse#define	yylex	mod_yylex#define	yyerror	mod_yyerror#define	yylval	mod_yylval#define	yychar	mod_yychar#define	yydebug	mod_yydebug#define	yypact	mod_yypact#define	yyr1	mod_yyr1#define	yyr2	mod_yyr2#define	yydef	mod_yydef#define	yychk	mod_yychk#define	yypgo	mod_yypgo#define	yyact	mod_yyact#define	yyexca	mod_yyexca#define yyerrflag mod_yyerrflag#define yynerrs	mod_yynerrs#define	yyps	mod_yyps#define	yypv	mod_yypv#define	yys	mod_yys#define	yy_yys	mod_yyyys#define	yystate	mod_yystate#define	yytmp	mod_yytmp#define	yyv	mod_yyv#define	yy_yyv	mod_yyyyv#define	yyval	mod_yyval#define	yylloc	mod_yylloc#define yyreds	mod_yyreds#define yytoks	mod_yytoks#define yylhs	mod_yyyylhs#define yylen	mod_yyyylen#define yydefred mod_yyyydefred#define yydgoto	mod_yyyydgoto#define yysindex mod_yyyysindex#define yyrindex mod_yyyyrindex#define yygindex mod_yyyygindex#define yytable	 mod_yyyytable#define yycheck	 mod_yyyycheck#define yyname   mod_yyyyname#define yyrule   mod_yyyyruleIfs_Table_t *mod_ifs_table;extern char *mod_yytext;extern FILE* mod_yyout; extern void mod_yyerror(char*);#include <string.h>#include <ctype.h>int mod_num_errors;#define BUFFER_SIZE 3000static char buffer [BUFFER_SIZE];static int buf_len;   typedef enum {CONN, PARAM, STATIC_VAR} Id_Kind_t;/*--------------------------------------------------------------------------*/static char *subscript (Sub_Id_t sub_id){   if (sub_id.has_subscript) {      return sub_id.subscript;   } else {      return "0";   }}/*--------------------------------------------------------------------------*/int local_strcmpi(s, t)     char *s;     char *t;     /* string compare -  case insensitive */{   for (; *s && t && tolower(*s) == tolower(*t); s++, t++);   if (*s && !*t) {      return 1;   }   if (!*s && *t) {      return -1;   }   if (! (*s || *t)) {      return 0;   }   return (tolower(*s) - tolower(*t));}/*---------------------------------------------------------------------------*/static void put_type (FILE *fp, Data_Type_t type){   char ch = ' ';      switch (type) {   case INTEGER:      ch = 'i';      break;   case REAL:      ch = 'r';      break;   case COMPLEX:      ch = 'c';      break;   case BOOLEAN:      ch = 'b';      break;   case STRING:      ch = 's';      break;   case POINTER:      ch = 'p';      break;   }   fprintf (fp, ".%cvalue", ch);}/*---------------------------------------------------------------------------*/static void put_conn_type (FILE *fp, Port_Type_t type){   char ch;      switch (type) {   case USER_DEFINED:      ch = 'p';      break;   case DIGITAL:      ch = 'p';      break;   default:      ch = 'r';      break;   }   fprintf (fp, ".%cvalue", ch);}/*---------------------------------------------------------------------------*/static void check_dir (int conn_number, Dir_t dir, char *context){   Dir_t conn_dir;      if (conn_number >= 0) {      /*       * If negative, this is an invalid port ID and we've already issued       * an error.       */      conn_dir = mod_ifs_table->conn[conn_number].direction;      if ((conn_dir != dir) && (conn_dir != INOUT)) {	 char error_str[200];	 	 sprintf (error_str,		  "Direction of port `%s' in %s() is not %s or INOUT",		  mod_ifs_table->conn[conn_number].name, context,		  (dir == IN) ? "IN" : "OUT");	 yyerror (error_str);	 mod_num_errors++;      }   }}/*---------------------------------------------------------------------------*/static void check_subscript (Boolean_t formal, Boolean_t actual,			     Boolean_t missing_actual_ok,			     char *context, char *id){   char error_str[200];   if ((formal && !actual) && !missing_actual_ok) {      sprintf (error_str,	       "%s `%s' is an array - subscript required",	       context, id);      yyerror (error_str);      mod_num_errors++;      return;   } else if (!formal && actual) {      sprintf (error_str,	       "%s `%s' is not an array - subscript prohibited",	       context, id);      yyerror (error_str);      mod_num_errors++;      return;   }}/*---------------------------------------------------------------------------*/static int check_id (Sub_Id_t sub_id, Id_Kind_t kind, Boolean_t do_subscript){   int i;   char error_str[200];      switch (kind) {   case CONN:      for (i = 0; i < mod_ifs_table->num_conn; i++) {	 if (0 == local_strcmpi (sub_id.id, mod_ifs_table->conn[i].name)) {	    if (do_subscript) {	       check_subscript (mod_ifs_table->conn[i].is_array,				sub_id.has_subscript, FALSE, "Port",				sub_id.id);	    }	    return i;	 }      }      break;   case PARAM:      for (i = 0; i < mod_ifs_table->num_param; i++) {      	 if (0 == local_strcmpi (sub_id.id, mod_ifs_table->param[i].name)) {	    if (do_subscript) {	       check_subscript (mod_ifs_table->param[i].is_array,				sub_id.has_subscript, FALSE, "Parameter",				sub_id.id);	    }	    return i;	 }      }      break;   case STATIC_VAR:      for (i = 0; i < mod_ifs_table->num_inst_var; i++) {      	 if (0 == local_strcmpi (sub_id.id, mod_ifs_table->inst_var[i].name)) {	    if (do_subscript) {	       check_subscript (mod_ifs_table->inst_var[i].is_array,				sub_id.has_subscript, TRUE,				"Static Variable",				sub_id.id);	    }	    return i;	 }      }      break;   }      sprintf (error_str, "No %s named '%s'",	    ((kind==CONN)	     ? "port"	     : ((kind==PARAM)		? "parameter"		:"static variable")),	    sub_id.id);   yyerror (error_str);   mod_num_errors++;   return -1;}/*---------------------------------------------------------------------------*/static int valid_id (Sub_Id_t sub_id, Id_Kind_t kind){    return check_id (sub_id, kind, FALSE);}/*---------------------------------------------------------------------------*/static int valid_subid (Sub_Id_t sub_id, Id_Kind_t kind){    return check_id (sub_id, kind, TRUE);}/*---------------------------------------------------------------------------*/static void init_buffer (){   buf_len = 0;   buffer[0] = '\0';}/*---------------------------------------------------------------------------*/static void append (char *str){   int len = strlen (str);   if (len + buf_len > BUFFER_SIZE) {      yyerror ("Buffer overflow - try reducing the complexity of CM-macro array subscripts");      exit (1);   }   (void)strcat (buffer,str);}/* Enabling traces.  */#ifndef YYDEBUG# define YYDEBUG 0#endif/* Enabling verbose error messages.  */#ifdef YYERROR_VERBOSE# undef YYERROR_VERBOSE# define YYERROR_VERBOSE 1#else# define YYERROR_VERBOSE 0#endif#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)#line 328 "mod_yacc.y"typedef union YYSTYPE {   char *str;   Sub_Id_t sub_id;} YYSTYPE;/* Line 191 of yacc.c.  */#line 490 "mod_yacc.c"# define yystype YYSTYPE /* obsolescent; will be withdrawn */# define YYSTYPE_IS_DECLARED 1# define YYSTYPE_IS_TRIVIAL 1#endif/* Copy the second part of user declarations.  *//* Line 214 of yacc.c.  */#line 502 "mod_yacc.c"#if ! defined (yyoverflow) || YYERROR_VERBOSE# ifndef YYFREE#  define YYFREE free# endif# ifndef YYMALLOC#  define YYMALLOC malloc# endif/* The parser invokes alloca or malloc; define the necessary symbols.  */# ifdef YYSTACK_USE_ALLOCA#  if YYSTACK_USE_ALLOCA#   define YYSTACK_ALLOC alloca#  endif# else#  if defined (alloca) || defined (_ALLOCA_H)#   define YYSTACK_ALLOC alloca#  else#   ifdef __GNUC__#    define YYSTACK_ALLOC __builtin_alloca#   endif

⌨️ 快捷键说明

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