app.c

来自「基于4个mips核的noc设计」· C语言 代码 · 共 1,329 行 · 第 1/3 页

C
1,329
字号
      switch (state)	{	case -1:	  ch = *out_string++;	  if (*out_string == '\0')	    {	      state = old_state;	      old_state = 3;	    }	  PUT (ch);	  continue;	case -2:	  for (;;)	    {	      do		{		  ch = GET ();		  if (ch == EOF)		    {		      as_warn (_("end of file in comment"));		      goto fromeof;		    }		  if (ch == '\n')		    PUT ('\n');		}	      while (ch != '*');	      while ((ch = GET ()) == '*')		;	      if (ch == EOF)		{		  as_warn (_("end of file in comment"));		  goto fromeof;		}	      if (ch == '/')		break;	      UNGET (ch);	    }	  state = old_state;	  UNGET (' ');	  continue;	case 4:	  ch = GET ();	  if (ch == EOF)	    goto fromeof;	  else if (ch >= '0' && ch <= '9')	    PUT (ch);	  else	    {	      while (ch != EOF && IS_WHITESPACE (ch))		ch = GET ();	      if (ch == '"')		{		  UNGET (ch);		  if (scrub_m68k_mri)		    out_string = "\n\tappfile ";		  else		    out_string = "\n\t.appfile ";		  old_state = 7;		  state = -1;		  PUT (*out_string++);		}	      else		{		  while (ch != EOF && ch != '\n')		    ch = GET ();		  state = 0;		  PUT (ch);		}	    }	  continue;	case 5:	  /* We are going to copy everything up to a quote character,             with special handling for a backslash.  We try to             optimize the copying in the simple case without using the             GET and PUT macros.  */	  {	    char *s;	    int len;	    for (s = from; s < fromend; s++)	      {		ch = *s;		/* This condition must be changed if the type of any                   other character can be LEX_IS_STRINGQUOTE.  */		if (ch == '\\'		    || ch == '"'		    || ch == '\''		    || ch == '\n')		  break;	      }	    len = s - from;	    if (len > toend - to)	      len = toend - to;	    if (len > 0)	      {		memcpy (to, from, len);		to += len;		from += len;	      }	  }	  ch = GET ();	  if (ch == EOF)	    {	      as_warn (_("end of file in string: inserted '\"'"));	      state = old_state;	      UNGET ('\n');	      PUT ('"');	    }	  else if (lex[ch] == LEX_IS_STRINGQUOTE)	    {	      state = old_state;	      PUT (ch);	    }#ifndef NO_STRING_ESCAPES	  else if (ch == '\\')	    {	      state = 6;	      PUT (ch);	    }#endif	  else if (scrub_m68k_mri && ch == '\n')	    {	      /* Just quietly terminate the string.  This permits lines like		   bne	label	loop if we haven't reach end yet		 */	      state = old_state;	      UNGET (ch);	      PUT ('\'');	    }	  else	    {	      PUT (ch);	    }	  continue;	case 6:	  state = 5;	  ch = GET ();	  switch (ch)	    {	      /* Handle strings broken across lines, by turning '\n' into		 '\\' and 'n'.  */	    case '\n':	      UNGET ('n');	      add_newlines++;	      PUT ('\\');	      continue;	    case '"':	    case '\\':	    case 'b':	    case 'f':	    case 'n':	    case 'r':	    case 't':	    case 'v':	    case 'x':	    case 'X':	    case '0':	    case '1':	    case '2':	    case '3':	    case '4':	    case '5':	    case '6':	    case '7':	      break;#if defined(IGNORE_NONSTANDARD_ESCAPES) | defined(ONLY_STANDARD_ESCAPES)	    default:	      as_warn (_("Unknown escape '\\%c' in string: Ignored"), ch);	      break;#else  /* ONLY_STANDARD_ESCAPES */	    default:	      /* Accept \x as x for any x */	      break;#endif /* ONLY_STANDARD_ESCAPES */	    case EOF:	      as_warn (_("End of file in string: '\"' inserted"));	      PUT ('"');	      continue;	    }	  PUT (ch);	  continue;	case 7:	  ch = GET ();	  state = 5;	  old_state = 8;	  if (ch == EOF)	    goto fromeof;	  PUT (ch);	  continue;	case 8:	  do	    ch = GET ();	  while (ch != '\n' && ch != EOF);	  if (ch == EOF)	    goto fromeof;	  state = 0;	  PUT (ch);	  continue;	}      /* OK, we are somewhere in states 0 through 4 or 9 through 11 */      /* flushchar: */      ch = GET ();    recycle:#if defined TC_ARM && defined OBJ_ELF      /* We need to watch out for .symver directives.  See the comment later	 in this function.  */      if (symver_state == NULL)	{	  if ((state == 0 || state == 1) && ch == symver_pseudo[0])	    symver_state = symver_pseudo + 1;	}      else	{	  /* We advance to the next state if we find the right	     character.  */	  if (ch != '\0' && (*symver_state == ch))	    ++symver_state;	  else if (*symver_state != '\0')	    /* We did not get the expected character, or we didn't	       get a valid terminating character after seeing the	       entire pseudo-op, so we must go back to the beginning.  */	    symver_state = NULL;	  else	    {	      /* We've read the entire pseudo-op.  If this is the end		 of the line, go back to the beginning.  */	      if (IS_NEWLINE (ch))		symver_state = NULL;	    }	}#endif /* TC_ARM && OBJ_ELF */#ifdef TC_M68K      /* We want to have pseudo-ops which control whether we are in         MRI mode or not.  Unfortunately, since m68k MRI mode affects         the scrubber, that means that we need a special purpose         recognizer here.  */      if (mri_state == NULL)	{	  if ((state == 0 || state == 1)	      && ch == mri_pseudo[0])	    mri_state = mri_pseudo + 1;	}      else	{	  /* We advance to the next state if we find the right	     character, or if we need a space character and we get any	     whitespace character, or if we need a '0' and we get a	     '1' (this is so that we only need one state to handle	     ``.mri 0'' and ``.mri 1'').  */	  if (ch != '\0'	      && (*mri_state == ch		  || (*mri_state == ' '		      && lex[ch] == LEX_IS_WHITESPACE)		  || (*mri_state == '0'		      && ch == '1')))	    {	      mri_last_ch = ch;	      ++mri_state;	    }	  else if (*mri_state != '\0'		   || (lex[ch] != LEX_IS_WHITESPACE		       && lex[ch] != LEX_IS_NEWLINE))	    {	      /* We did not get the expected character, or we didn't		 get a valid terminating character after seeing the		 entire pseudo-op, so we must go back to the		 beginning.  */	      mri_state = NULL;	    }	  else	    {	      /* We've read the entire pseudo-op.  mips_last_ch is                 either '0' or '1' indicating whether to enter or                 leave MRI mode.  */	      do_scrub_begin (mri_last_ch == '1');	      mri_state = NULL;	      /* We continue handling the character as usual.  The                 main gas reader must also handle the .mri pseudo-op                 to control expression parsing and the like.  */	    }	}#endif      if (ch == EOF)	{	  if (state != 0)	    {	      as_warn (_("end of file not at end of a line; newline inserted"));	      state = 0;	      PUT ('\n');	    }	  goto fromeof;	}      switch (lex[ch])	{	case LEX_IS_WHITESPACE:	  do	    {	      ch = GET ();	    }	  while (ch != EOF && IS_WHITESPACE (ch));	  if (ch == EOF)	    goto fromeof;	  if (state == 0)	    {	      /* Preserve a single whitespace character at the		 beginning of a line.  */	      state = 1;	      UNGET (ch);	      PUT (' ');	      break;	    }#ifdef KEEP_WHITE_AROUND_COLON	  if (lex[ch] == LEX_IS_COLON)	    {	      /* Only keep this white if there's no white *after* the                 colon.  */	      ch2 = GET ();	      UNGET (ch2);	      if (!IS_WHITESPACE (ch2))		{		  state = 9;		  UNGET (ch);		  PUT (' ');		  break;		}	    }#endif	  if (IS_COMMENT (ch)	      || ch == '/'	      || IS_LINE_SEPARATOR (ch))	    {	      if (scrub_m68k_mri)		{		  /* In MRI mode, we keep these spaces.  */		  UNGET (ch);		  PUT (' ');		  break;		}	      goto recycle;	    }	  /* If we're in state 2 or 11, we've seen a non-white	     character followed by whitespace.  If the next character	     is ':', this is whitespace after a label name which we	     normally must ignore.  In MRI mode, though, spaces are	     not permitted between the label and the colon.  */	  if ((state == 2 || state == 11)	      && lex[ch] == LEX_IS_COLON	      && ! scrub_m68k_mri)	    {	      state = 1;	      PUT (ch);	      break;	    }	  switch (state)	    {	    case 0:	      state++;	      goto recycle;	/* Punted leading sp */	    case 1:	      /* We can arrive here if we leave a leading whitespace		 character at the beginning of a line.  */	      goto recycle;	    case 2:	      state = 3;	      if (to + 1 < toend)		{		  /* Optimize common case by skipping UNGET/GET.  */		  PUT (' ');	/* Sp after opco */		  goto recycle;		}	      UNGET (ch);	      PUT (' ');	      break;	    case 3:	      if (scrub_m68k_mri)		{		  /* In MRI mode, we keep these spaces.  */		  UNGET (ch);		  PUT (' ');		  break;		}	      goto recycle;	/* Sp in operands */	    case 9:	    case 10:	      if (scrub_m68k_mri)		{		  /* In MRI mode, we keep these spaces.  */		  state = 3;		  UNGET (ch);		  PUT (' ');		  break;		}	      state = 10;	/* Sp after symbol char */	      goto recycle;	    case 11:	      if (LABELS_WITHOUT_COLONS || flag_m68k_mri)		state = 1;	      else		{		  /* We know that ch is not ':', since we tested that                     case above.  Therefore this is not a label, so it                     must be the opcode, and we've just seen the                     whitespace after it.  */		  state = 3;		}	      UNGET (ch);	      PUT (' ');	/* Sp after label definition.  */	      break;	    default:	      BAD_CASE (state);	    }	  break;	case LEX_IS_TWOCHAR_COMMENT_1ST:	  ch2 = GET ();

⌨️ 快捷键说明

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