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

📄 vhdl.c

📁 这个是一个词法和语法分析器的程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************
*                     U N R E G I S T E R E D   C O P Y
* 
* You are on day 6 of your 30 day trial period.
* 
* This file was produced by an UNREGISTERED COPY of Parser Generator. It is
* for evaluation purposes only. If you continue to use Parser Generator 30
* days after installation then you are required to purchase a license. For
* more information see the online help or go to the Bumble-Bee Software
* homepage at:
* 
* http://www.bumblebeesoftware.com
* 
* This notice must remain present in the file. It cannot be removed.
****************************************************************************/

/****************************************************************************
* vhdl.c
* C source file generated from vhdl.lex.
* 
* Date: 03/07/06
* Time: 15:15:22
* 
* ALex Version: 2.07
****************************************************************************/

#include <yylex.h>

/* namespaces */
#if defined(__cplusplus) && defined(YYSTDCPPLIB)
using namespace std;
#endif
#if defined(__cplusplus) && defined(YYNAMESPACE)
using namespace yl;
#endif

#define YYFASTLEXER

#line 1 ".\\vhdl.lex"

/************** VHDL scanner in LEX format **********
 *
 * Version 0.2 Wed Aug 11, 1993
 *
 * This scanner is derived from a scanner of the ALLIANCE CAD toolset,
 * release 1.1. That toolset was written from:
 *   MASI/CAO-VLSI CAD Team
 *   Laboratoire MASI/CAO-VLSI
 *   Tour 55-65, 2eme etage, Porte 13
 *   Universite Pierre et Marie Curie (PARIS VI)
 *   4, place Jussieu 75252 PARIS Cedex 05, FRANCE
 * The ALLIANCE CAD Toolset can be obtained from ftp site : ftp-masi.ibp.fr    
 *
 * This scanner is avail at: ftp.cs.utwente.nl in pub/src/VHDL/Grammar
 * A corresponding Yacc grammar is available at the same site
 *
 * author of this derived scanner version:
 * Thomas Dettmer
 * Dortmund University
 * Dept. of Computer Scienc, LS1
 * PB 500 500
 * D-44221 Dortmund (Germany)
 * Phone: +49-231-755-6464
 * e-mail: dettmer@ls1.informatik.uni-dortmund.de
 *
 * Please report discovered bugs, critics, suggestions
 * and changes you make to dettmer@ls1.informatik.uni-dortmund.de
 * a list of those that reported repaired (hopefully) errors can be found
 * at the end
 *
 ****************************************************************
 * 
 * This file is intended not to be used for commercial purposes
 * without permission of the University of Dortmund
 *
 * NOTE THAT THERE IS NO WARRANTY FOR CORRECTNES, COMPLETENESS, SUPPORT
 * OR ANYTHING ELSE.
 *******************************************************/
 
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <search.h>
#include "vhdl.h"

#ifdef BASE_REPRESENTATION
#ifdef ECHO
#undef ECHO
#endif
#define ECHO echo(yytext)
static void echo(s)
char* s;
{
  char  loc[YYLMAX];
  int   l;
  l=strlen(s);
  loc[l]='\0';
  while(l--) loc[l]=toupper(*(s+l));  
  fprintf(yyout, "%s\n", loc);
}
#endif

int yycolumno=0;
#undef input()
int input(){
  if (yysptr>yysbuf){
    yytchar=U(*--yysptr);
  }else{
    yytchar=getc(yyin);
  }
  if (yytchar=='\t')
    yycolumno+=8;
  else
    ++yycolumno;
  if (yytchar=='\n'){
    yylineno++;
  }
  if (yytchar==EOF)
    return 0;
  return yytchar;
}
#undef unput(c)
void unput(c)
char c;
{
  yytchar=c;
  *yysptr++=yytchar;
  if(yytchar=='\n')
    yylineno--;
  if (c=='\t')
    yycolumno-=8;
  else
    --yycolumno;
}


#define MVL_LG_MC 15
#define MVL_NB_MC 81

int MVL_LINNUM=1;

typedef struct {
        char nom[MVL_LG_MC];
        int kval;
        } el_mc;

static el_mc tab_mc []=
  {
    {"abs"		,t_ABS},
    {"access"		,t_ACCESS},
    {"after"		,t_AFTER},
    {"alias"		,t_ALIAS},
    {"all"		,t_ALL},
    {"and"		,t_AND},
    {"architecture"	,t_ARCHITECTURE},
    {"array"		,t_ARRAY},
    {"assert"		,t_ASSERT},
    {"attribute"	,t_ATTRIBUTE},

    {"begin"		,t_BEGIN},
    {"block"		,t_BLOCK},
    {"body"		,t_BODY},
    {"buffer"		,t_BUFFER},
    {"bus"		,t_BUS},

    {"case"		,t_CASE},
    {"component"	,t_COMPONENT},
    {"configuration"	,t_CONFIGURATION},
    {"constant"		,t_CONSTANT},

    {"disconnect"	,t_DISCONNECT},
    {"downto"		,t_DOWNTO},

    {"else"		,t_ELSE},
    {"elsif"		,t_ELSIF},
    {"end"		,t_END},
    {"entity"		,t_ENTITY},
    {"exit"		,t_EXIT},

    {"file"		,t_FILE},
    {"for"		,t_FOR},
    {"function"		,t_FUNCTION},

    {"generate"		,t_GENERATE},
    {"generic"		,t_GENERIC},
    {"guarded"		,t_GUARDED},

    {"if"		,t_IF},
    {"in"		,t_IN},
    {"inout"		,t_INOUT},
    {"is"		,t_IS},

    {"label"		,t_LABEL},
    {"library"		,t_LIBRARY},
    {"linkage"		,t_LINKAGE},
    {"loop"		,t_LOOP},

    {"map"		,t_MAP},
    {"mod"		,t_MOD},

    {"nand"		,t_NAND},
    {"new"		,t_NEW},
    {"next"		,t_NEXT},
    {"nor"		,t_NOR},
    {"not"		,t_NOT},
    {"null"		,t_NULL},

    {"of"		,t_OF},
    {"on"		,t_ON},
    {"open"		,t_OPEN},
    {"or"		,t_OR},
    {"others"		,t_OTHERS},
    {"out"		,t_OUT},

    {"package"		,t_PACKAGE},
    {"port"		,t_PORT},
    {"procedure"	,t_PROCEDURE},
    {"process"		,t_PROCESS},

    {"range"		,t_RANGE},
    {"record"		,t_RECORD},
    {"register"		,t_REGISTER},
    {"rem"		,t_REM},
    {"report"		,t_REPORT},
    {"return"		,t_RETURN},

    {"select"		,t_SELECT},
    {"severity"		,t_SEVERITY},
    {"signal"		,t_SIGNAL},
    {"subtype"		,t_SUBTYPE},

    {"then"		,t_THEN},
    {"to"		,t_TO},
    {"transport"	,t_TRANSPORT},
    {"type"		,t_TYPE},

    {"units"		,t_UNITS},
    {"until"		,t_UNTIL},
    {"use"		,t_USE},

    {"variable"		,t_VARIABLE},

    {"wait"		,t_WAIT},
    {"when"		,t_WHEN},
    {"while"		,t_WHILE},
    {"with"		,t_WITH},

    {"xor"		,t_XOR}
  };

static int find_mc(s)
char *s;
{
  char  loc[YYLMAX];
  int   l;
  el_mc *pt;

  l=strlen(s);
  strcpy(loc,s);
  while(l--) loc[l]=tolower(loc[l]);	/* conversion en minuscules */
  pt= (el_mc *) bsearch(loc, (char *)tab_mc,MVL_NB_MC,sizeof(el_mc),strcmp);
  if (pt==NULL) return(-1);
  else return(pt->kval);
}

#line 267 "vhdl.c"
/* repeated because of possible precompiled header */
#include <yylex.h>

/* namespaces */
#if defined(__cplusplus) && defined(YYSTDCPPLIB)
using namespace std;
#endif
#if defined(__cplusplus) && defined(YYNAMESPACE)
using namespace yl;
#endif

#define YYFASTLEXER

#include ".\vhdl.h"

#ifndef YYTEXT_SIZE
#define YYTEXT_SIZE 100
#endif
#ifndef YYUNPUT_SIZE
#define YYUNPUT_SIZE YYTEXT_SIZE
#endif
#ifndef YYTEXT_MAX
#define YYTEXT_MAX 0
#endif
#ifndef YYUNPUT_MAX
#define YYUNPUT_MAX YYTEXT_MAX
#endif

/* yytext */
static char YYNEAR yysatext[(YYTEXT_SIZE) + 1];		/* extra char for \0 */
char YYFAR *YYNEAR YYDCDECL yystext = yysatext;
char YYFAR *YYNEAR YYDCDECL yytext = yysatext;
int YYNEAR YYDCDECL yystext_size = (YYTEXT_SIZE);
int YYNEAR YYDCDECL yytext_size = (YYTEXT_SIZE);
int YYNEAR YYDCDECL yytext_max = (YYTEXT_MAX);

/* yystatebuf */
#if (YYTEXT_SIZE) != 0
static int YYNEAR yysastatebuf[(YYTEXT_SIZE)];
int YYFAR *YYNEAR YYDCDECL yysstatebuf = yysastatebuf;
int YYFAR *YYNEAR YYDCDECL yystatebuf = yysastatebuf;
#else
int YYFAR *YYNEAR YYDCDECL yysstatebuf = NULL;
int YYFAR *YYNEAR YYDCDECL yystatebuf = NULL;
#endif

/* yyunputbuf */
#if (YYUNPUT_SIZE) != 0
static int YYNEAR yysaunputbuf[(YYUNPUT_SIZE)];
int YYFAR *YYNEAR YYDCDECL yysunputbufptr = yysaunputbuf;
int YYFAR *YYNEAR YYDCDECL yyunputbufptr = yysaunputbuf;
#else
int YYFAR *YYNEAR YYDCDECL yysunputbufptr = NULL;
int YYFAR *YYNEAR YYDCDECL yyunputbufptr = NULL;
#endif
int YYNEAR YYDCDECL yysunput_size = (YYUNPUT_SIZE);
int YYNEAR YYDCDECL yyunput_size = (YYUNPUT_SIZE);
int YYNEAR YYDCDECL yyunput_max = (YYUNPUT_MAX);

/* backwards compatability with lex */
#ifdef input
#ifdef YYPROTOTYPE
int YYCDECL yyinput(void)
#else
int YYCDECL yyinput()
#endif
{
	return input();
}
#else
#define input yyinput
#endif

#ifdef output
#ifdef YYPROTOTYPE
void YYCDECL yyoutput(int ch)
#else
void YYCDECL yyoutput(ch)
int ch;
#endif
{
	output(ch);
}
#else
#define output yyoutput
#endif

#ifdef unput
#ifdef YYPROTOTYPE
void YYCDECL yyunput(int ch)
#else
void YYCDECL yyunput(ch)
int ch;
#endif
{
	unput(ch);
}
#else
#define unput yyunput
#endif

#ifndef YYNBORLANDWARN
#ifdef __BORLANDC__
#pragma warn -rch		/* <warning: unreachable code> off */
#endif
#endif

#ifdef YYPROTOTYPE
int YYCDECL yylexeraction(int action)
#else
int YYCDECL yylexeraction(action)
int action;
#endif
{
	yyreturnflg = YYTRUE;
	switch (action) {
	case 1:
		{
#line 249 ".\\vhdl.lex"

			/* nothing */
#ifndef BASE_REPRESENTATION			
			ECHO; /*return(t_Space);*/
#endif
			
#line 393 "vhdl.c"
		}
		break;
	case 2:
		{
#line 255 ".\\vhdl.lex"

			ECHO; return(t_Ampersand);
									
#line 402 "vhdl.c"
		}
		break;
	case 3:
		{
#line 258 ".\\vhdl.lex"

			ECHO; return(t_Apostrophe);
									
#line 411 "vhdl.c"
		}
		break;
	case 4:
		{
#line 261 ".\\vhdl.lex"

			ECHO; return(t_LeftParen);
									
#line 420 "vhdl.c"
		}
		break;
	case 5:
		{
#line 264 ".\\vhdl.lex"

			ECHO; return(t_RightParen);
									
#line 429 "vhdl.c"
		}
		break;
	case 6:
		{
#line 267 ".\\vhdl.lex"

			ECHO; return(t_DoubleStar);
									
#line 438 "vhdl.c"
		}
		break;
	case 7:
		{
#line 270 ".\\vhdl.lex"

			ECHO; return(t_Star);
									
#line 447 "vhdl.c"
		}
		break;
	case 8:
		{
#line 273 ".\\vhdl.lex"

			ECHO; return(t_Plus);
									
#line 456 "vhdl.c"
		}
		break;
	case 9:
		{
#line 276 ".\\vhdl.lex"

			ECHO; return(t_Comma);
									
#line 465 "vhdl.c"
		}
		break;
	case 10:
		{
#line 279 ".\\vhdl.lex"

			ECHO; return(t_Minus);
									
#line 474 "vhdl.c"
		}
		break;
	case 11:
		{
#line 282 ".\\vhdl.lex"

			ECHO; return(t_VarAsgn);
									
#line 483 "vhdl.c"
		}
		break;
	case 12:
		{
#line 285 ".\\vhdl.lex"

			ECHO; return(t_Colon);
									
#line 492 "vhdl.c"
		}
		break;
	case 13:
		{
#line 288 ".\\vhdl.lex"

			ECHO; return(t_Semicolon);
									
#line 501 "vhdl.c"
		}
		break;
	case 14:
		{
#line 291 ".\\vhdl.lex"

	    ECHO;
	    return(t_LESym);
	
#line 511 "vhdl.c"
		}
		break;
	case 15:
		{
#line 295 ".\\vhdl.lex"

            ECHO;
	    return(t_GESym);
	
#line 521 "vhdl.c"
		}
		break;
	case 16:
		{
#line 299 ".\\vhdl.lex"

            ECHO;
	    return(t_LTSym);
	
#line 531 "vhdl.c"
		}
		break;
	case 17:
		{
#line 303 ".\\vhdl.lex"

            ECHO;
	    return(t_GTSym);
	
#line 541 "vhdl.c"
		}
		break;
	case 18:
		{
#line 307 ".\\vhdl.lex"

			ECHO; return(t_EQSym);
									
#line 550 "vhdl.c"
		}
		break;
	case 19:
		{
#line 310 ".\\vhdl.lex"

			ECHO; return(t_NESym);
									
#line 559 "vhdl.c"
		}
		break;
	case 20:
		{
#line 313 ".\\vhdl.lex"

            ECHO;
	    return(t_Arrow);
	
#line 569 "vhdl.c"
		}
		break;
	case 21:
		{
#line 317 ".\\vhdl.lex"

            ECHO;
	    return(t_Box);
	
#line 579 "vhdl.c"
		}
		break;
	case 22:
		{
#line 321 ".\\vhdl.lex"

			ECHO; return(t_Bar);
									
#line 588 "vhdl.c"
		}
		break;
	case 23:
		{
#line 324 ".\\vhdl.lex"

			ECHO; return(t_Bar);
									
#line 597 "vhdl.c"
		}
		break;
	case 24:
		{
#line 327 ".\\vhdl.lex"

			ECHO; return(t_Dot);
									
#line 606 "vhdl.c"
		}
		break;
	case 25:
		{
#line 330 ".\\vhdl.lex"

			ECHO; return(t_Slash);
									
#line 615 "vhdl.c"
		}
		break;
	case 26:
		{
#line 333 ".\\vhdl.lex"

	int itoken;
	itoken=find_mc(yytext);
	if (itoken== -1) 
	{
	  ECHO;
	  yylval.ds_Id.pos=yycolumno;
	  yylval.ds_Id.len=strlen(yytext);
	  yylval.ds_Id.line=yylineno;
	  /* yylval.ds_Id.name= insertName(yytext); */
	  return ( t_Identifier );
			  }
			else
			  {
			  ECHO; return ( itoken );
			  }
									
#line 638 "vhdl.c"
		}
		break;
	case 27:
		{
#line 350 ".\\vhdl.lex"

			ECHO; return ( t_AbstractLit );
			
#line 647 "vhdl.c"
		}
		break;
	case 28:
		{
#line 354 ".\\vhdl.lex"

			ECHO; return ( t_CharacterLit );
				
#line 656 "vhdl.c"
		}
		break;
	case 29:
		{
#line 358 ".\\vhdl.lex"

			ECHO; return ( t_StringLit );
			
#line 665 "vhdl.c"
		}
		break;
	case 30:
		{
#line 362 ".\\vhdl.lex"

			ECHO; return ( t_BitStringLit );
			
#line 674 "vhdl.c"
		}
		break;
	case 31:
		{
#line 366 ".\\vhdl.lex"

			/* end of line */
			MVL_LINNUM++;
			/* tobuf( "\n%4d\t", MVL_LINNUM);*/
#ifndef BASE_REPRESENTATION
			ECHO;
#endif
			yycolumno=0;
			/*return(t_NEWLINE);*/
									
#line 690 "vhdl.c"
		}
		break;
	case 32:
		{
#line 376 ".\\vhdl.lex"

			/* comment */
#ifndef BASE_REPRESENTATION
			ECHO;
#endif
			/*return(t_COMMENT);*/
									
#line 703 "vhdl.c"
		}
		break;
	case 33:
		{
#line 383 ".\\vhdl.lex"

			ECHO; /*return (t_UNKNOWN);*/
									
#line 712 "vhdl.c"
		}
		break;
	default:
		yyassert(0);
		break;
	}
	yyreturnflg = YYFALSE;
	return 0;
}

#ifndef YYNBORLANDWARN
#ifdef __BORLANDC__
#pragma warn .rch		/* <warning: unreachable code> to the old state */
#endif
#endif
YYCONST yymatch_t YYNEARFAR YYBASED_CODE YYDCDECL yymatch[] = {
	0,
	-32,
	0
};

int YYNEAR YYDCDECL yytransitionmax = 854;
YYCONST yytransition_t YYNEARFAR YYBASED_CODE YYDCDECL yytransition[] = {
	{ 0, 0 },
	{ 32, 10 },
	{ 19, 40 },
	{ 19, 40 },
	{ 19, 40 },
	{ 19, 40 },
	{ 19, 40 },
	{ 19, 40 },
	{ 19, 40 },
	{ 19, 40 },
	{ 19, 40 },
	{ 19, 40 },
	{ 47, 26 },
	{ 30, 31 },
	{ 54, 39 },
	{ 48, 26 },
	{ 54, 39 },
	{ 42, 22 },
	{ 43, 22 },
	{ 49, 32 },
	{ 50, 34 },
	{ 0, 54 },
	{ 34, 16 },
	{ 44, 23 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },
	{ 32, 10 },

⌨️ 快捷键说明

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