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

📄 lex.yy.c

📁 用汇编语言编程源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
#ifndef YY_NO_SCAN_BYTES#ifdef YY_USE_PROTOSYY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )#elseYY_BUFFER_STATE yy_scan_bytes( bytes, len )yyconst char *bytes;int len;#endif	{	YY_BUFFER_STATE b;	char *buf;	yy_size_t n;	int i;	/* Get memory for full buffer, including space for trailing EOB's. */	n = len + 2;	buf = (char *) yy_flex_alloc( n );	if ( ! buf )		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );	for ( i = 0; i < len; ++i )		buf[i] = bytes[i];	buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;	b = yy_scan_buffer( buf, n );	if ( ! b )		YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );	/* It's okay to grow etc. this buffer, and we should throw it	 * away when we're done.	 */	b->yy_is_our_buffer = 1;	return b;	}#endif#ifndef YY_NO_PUSH_STATE#ifdef YY_USE_PROTOSstatic void yy_push_state( int new_state )#elsestatic void yy_push_state( new_state )int new_state;#endif	{	if ( yy_start_stack_ptr >= yy_start_stack_depth )		{		yy_size_t new_size;		yy_start_stack_depth += YY_START_STACK_INCR;		new_size = yy_start_stack_depth * sizeof( int );		if ( ! yy_start_stack )			yy_start_stack = (int *) yy_flex_alloc( new_size );		else			yy_start_stack = (int *) yy_flex_realloc(					(void *) yy_start_stack, new_size );		if ( ! yy_start_stack )			YY_FATAL_ERROR(			"out of memory expanding start-condition stack" );		}	yy_start_stack[yy_start_stack_ptr++] = YY_START;	BEGIN(new_state);	}#endif#ifndef YY_NO_POP_STATEstatic void yy_pop_state()	{	if ( --yy_start_stack_ptr < 0 )		YY_FATAL_ERROR( "start-condition stack underflow" );	BEGIN(yy_start_stack[yy_start_stack_ptr]);	}#endif#ifndef YY_NO_TOP_STATEstatic int yy_top_state()	{	return yy_start_stack[yy_start_stack_ptr - 1];	}#endif#ifndef YY_EXIT_FAILURE#define YY_EXIT_FAILURE 2#endif#ifdef YY_USE_PROTOSstatic void yy_fatal_error( yyconst char msg[] )#elsestatic void yy_fatal_error( msg )char msg[];#endif	{	(void) fprintf( stderr, "%s\n", msg );	exit( YY_EXIT_FAILURE );	}/* Redefine yyless() so it works in section 3 code. */#undef yyless#define yyless(n) \	do \		{ \		/* Undo effects of setting up yytext. */ \		yytext[yyleng] = yy_hold_char; \		yy_c_buf_p = yytext + n; \		yy_hold_char = *yy_c_buf_p; \		*yy_c_buf_p = '\0'; \		yyleng = n; \		} \	while ( 0 )/* Internal utility routines. */#ifndef yytext_ptr#ifdef YY_USE_PROTOSstatic void yy_flex_strncpy( char *s1, yyconst char *s2, int n )#elsestatic void yy_flex_strncpy( s1, s2, n )char *s1;yyconst char *s2;int n;#endif	{	register int i;	for ( i = 0; i < n; ++i )		s1[i] = s2[i];	}#endif#ifdef YY_NEED_STRLEN#ifdef YY_USE_PROTOSstatic int yy_flex_strlen( yyconst char *s )#elsestatic int yy_flex_strlen( s )yyconst char *s;#endif	{	register int n;	for ( n = 0; s[n]; ++n )		;	return n;	}#endif#ifdef YY_USE_PROTOSstatic void *yy_flex_alloc( yy_size_t size )#elsestatic void *yy_flex_alloc( size )yy_size_t size;#endif	{	return (void *) malloc( size );	}#ifdef YY_USE_PROTOSstatic void *yy_flex_realloc( void *ptr, yy_size_t size )#elsestatic void *yy_flex_realloc( ptr, size )void *ptr;yy_size_t size;#endif	{	/* The cast to (char *) in the following accommodates both	 * implementations that use char* generic pointers, and those	 * that use void* generic pointers.  It works with the latter	 * because both ANSI C and C++ allow castless assignment from	 * any pointer type to void*, and deal with argument conversions	 * as though doing an assignment.	 */	return (void *) realloc( (char *) ptr, size );	}#ifdef YY_USE_PROTOSstatic void yy_flex_free( void *ptr )#elsestatic void yy_flex_free( ptr )void *ptr;#endif	{	free( ptr );	}#if YY_MAINint main()	{	yylex();	return 0;	}#endif#line 304 "scanner.l"#ifdef __STDC__voidinitialize_scanner (FILE *in_file)#elsevoidinitialize_scanner (in_file)     FILE *in_file;#endif{  yyin = in_file;#ifdef FLEX_SCANNER  yyrestart(in_file);  yy_init = 1;#endif  line_no = 1;  current_line = NULL;  line_returned = 0;  eof_returned = 0;}#ifdef __STDC__voidscanner_start_line (void)#elsevoidscanner_start_line ()#endif{  current_line = NULL;  line_returned = 0;}/* Use yywrap to insert a marker character, which causes the   scanner to return Y_EOF, before return a hard EOF.  This   wouldn't be necessary, except that bison does not allow   the parser to use EOF (= 0) as a non-terminal */int yywrap(){	if (eof_returned)		return (1);	else	{		unput ('\001');		eof_returned = 1;#ifdef FLEX_SCANNER		yy_did_buffer_switch_on_eof = 1;#endif		return (0);	}}/* Return a freshly-allocated copy of STRING with the last CHOP   characters removed. */#ifdef __STDC__static YY_CHAR *copy_str (YY_CHAR *str, int chop)#elsestatic YY_CHAR *copy_str (str, chop)     YY_CHAR *str;     int chop;#endif{  register int new_len = strlen (str) - chop;  register YY_CHAR *new_str = (YY_CHAR *) xmalloc (new_len + 1), *n;  for (n = new_str; *str != '\0' && new_len > 0; new_len -= 1)    if (*str == '\\')      switch (*(str + 1))	{	case 'n':	  {	    *n ++ = '\n';	    str += 2;	    new_len -= 1;	    continue;	  }	case 't':	  {	    *n ++ = '\t';	    str += 2;	    new_len -= 1;	    continue;	  }	case '"':	  {	    *n ++ = '"';	    str += 2;	    new_len -= 1;	    continue;	  }	case 'X':	  {	    YY_CHAR c1 = *(str + 2), c2 = *(str + 3);	    int b = 0;	    if ('0' <= c1 && c1 <= '9') b = c1 - '0';	    else if ('A' <= c1 && c1 <= 'F') b = c1 - 'A' + 10;	    else yyerror ("Bad character in \\X construct in string");	    b <<= 4;	    if ('0' <= c2 && c2 <= '9') b += c2 - '0';	    else if ('A' <= c2 && c2 <= 'F') b += c2 - 'A' + 10;	    else yyerror ("Bad character in \\X construct in string");	    *n ++ = (YY_CHAR) b;	    str += 4;	    new_len -= 3;	    continue;	  }	default:	  {	    *n ++ = *str ++;	    continue;	  }	}    else      *n ++ = *str ++;  *n = '\0';  y_str_length = n - new_str;  return (new_str);}/* On a parse error, write out the current line and print a caret (^)   below the point at which the error occured.	Also, reset the input   stream to the begining of the next line. */#ifdef __STDC__voidprint_erroneous_line (void)#elsevoidprint_erroneous_line ()#endif{  int prefix_length = yytext - current_line;  int i, c;  YY_CHAR buffer[1024], *bp = buffer;  if (current_line == NULL) return;  /* Print part of line that has been consumed. */  if (0 <= prefix_length)    {      /* yytext and current_line point to same line */      error ("	  ");      c = *(current_line + prefix_length);      *(current_line + prefix_length) = '\0';      error ("%s", current_line);      *(current_line + prefix_length) = (char)c;      error ("%s", yytext);    }  else    {      /* yytext and current_line point to different lines */      error ("	  ");      error ("%s", current_line);      prefix_length = strlen(current_line);    }  /* Flush the rest of the line (not consumed) from lex input. */  if (*yytext != '\n')    {      while ((c = input ()) != '\n' && c != EOF && c != 1)	*bp ++ = (char)c;      *bp = '\0';      error ("%s\n", buffer);      if (c == '\n') unput ('\n');      current_line = NULL;    }  /* Print marker to point at which consumption stopped. */  if (1024 <= prefix_length) return;  error ("	  ");  for (i = 0; i < prefix_length; i ++) buffer[i] = ' ';  buffer[i] = '\0';  error ("%s^\n", buffer);}static inst_info keyword_tbl [] = {#undef OP#define OP(NAME, OPCODE, TYPE, R_OPCODE) {NAME, OPCODE, TYPE},#include "op.h"};#ifdef __STDC__static intcheck_keyword (YY_CHAR *id, int allow_pseudo_ops)#elsestatic intcheck_keyword (id, allow_pseudo_ops)     YY_CHAR *id;     int allow_pseudo_ops;#endif{  inst_info *entry =    map_string_to_inst_info (keyword_tbl,			     sizeof(keyword_tbl) / sizeof (inst_info),			     id);  if (entry == NULL)    return (0);  else if (!allow_pseudo_ops && entry->value2 == PSEUDO_OP)    return (0);  else    return (entry->value1);}static inst_info register_tbl [] = {  {"a0", 4, 0},  {"a1", 5, 0},  {"a2", 6, 0},  {"a3", 7, 0},  {"at", 1, 0},  {"fp", 30, 0},  {"gp", 28, 0},  {"k0", 26, 0},  {"k1", 27, 0},  {"kt0", 26, 0},  {"kt1", 27, 0},  {"ra", 31, 0},  {"s0", 16, 0},  {"s1", 17, 0},  {"s2", 18, 0},  {"s3", 19, 0},  {"s4", 20, 0},  {"s5", 21, 0},  {"s6", 22, 0},  {"s7", 23, 0},  {"s8", 30, 0},  {"sp", 29, 0},  {"t0", 8, 0},  {"t1", 9, 0},  {"t2", 10, 0},  {"t3", 11, 0},  {"t4", 12, 0},  {"t5", 13, 0},  {"t6", 14, 0},  {"t7", 15, 0},  {"t8", 24, 0},  {"t9", 25, 0},  {"v0", 2, 0},  {"v1", 3, 0},  {"zero", 0, 0}};#ifdef __STDC__intregister_name_to_number (char *name)#elseintregister_name_to_number (name)     char *name;#endif{  register int c1 = *name, c2 = *(name + 1);  if ('0' <= c1 && c1 <= '9'      && (c2 == '\0' || (('0' <= c2 && c2 <= '9') && *(name + 2) == '\0')))    return (atoi (name));  else if (c1 == 'f' && c2 >= '0' && c2 <= '9')    return atoi (name + 1);  else    {      inst_info *entry =	map_string_to_inst_info (register_tbl,				 sizeof (register_tbl) / sizeof (inst_info),				 name);      if (entry == NULL)	return (-1);      else	return (entry->value1);    }}/* Exactly once, return the current source line, as a printable string   with a line number.  Subsequent calls receive NULL instead of the   line. */#ifdef __STDC__char *source_line ()#elsechar *source_line ()#endif{  if (line_returned)    return (NULL);  else if (current_line == NULL)	/* Error on line */    return (NULL);  else    {      YY_CHAR *eol1, c1;      YY_CHAR *null1 = NULL;      char *r;      /* Find end of line: */      for (eol1 = current_line; *eol1 != '\0' && *eol1 != '\n'; ) eol1 += 1;      /* Ran into null byte, inserted by yylex. In necessary, look further	 for newline */      if (*eol1 == '\0' && yy_hold_char != '\n')	{	  null1 = eol1;	  *eol1 = yy_hold_char;	  for ( ; *eol1 != '\0' && *eol1 != '\n'; )	    eol1 += 1;	}      /* Save end-of-line character and null terminate string so it can	 be printed. */      c1 = *eol1;      *eol1 = '\0';      r = (char *) xmalloc (eol1 - current_line + 10);      sprintf (r, "%d: %s", current_line_no, current_line);      /* Restore end-of-line character and, if necessary, yylex's null byte. */      *eol1 = c1;      if (null1 != NULL)	{	  *null1 = '\0';	}      line_returned = 1;      return ((char *) r);    }}

⌨️ 快捷键说明

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