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

📄 lex.c

📁 gcc-2.95.3 Linux下最常用的C编译器
💻 C
📖 第 1 页 / 共 5 页
字号:
    return;			/* Don't have a statement pending. */  if (ffelex_token_->type != FFELEX_typeEOS)    ffelex_prepare_eos_ ();  ffelex_permit_include_ = TRUE;  ffelex_send_token_ ();  ffelex_permit_include_ = FALSE;  ffelex_number_of_tokens_ = 0;  ffelex_label_tokens_ = 0;  ffelex_names_ = TRUE;  ffelex_names_pure_ = FALSE;	/* Probably not necessary. */  ffelex_hexnum_ = FALSE;  if (!ffe_is_ffedebug ())    return;  /* For debugging purposes only. */  if (ffelex_total_tokens_ != ffelex_old_total_tokens_)    {      fprintf (dmpout, "; token_track had %ld tokens, now have %ld.\n",	       ffelex_old_total_tokens_, ffelex_total_tokens_);      ffelex_old_total_tokens_ = ffelex_total_tokens_;    }}/* Copied from gcc/c-common.c get_directive_line.  */#if FFECOM_targetCURRENT == FFECOM_targetGCCstatic intffelex_get_directive_line_ (char **text, FILE *finput){  static char *directive_buffer = NULL;  static unsigned buffer_length = 0;  register char *p;  register char *buffer_limit;  register int looking_for = 0;  register int char_escaped = 0;  if (buffer_length == 0)    {      directive_buffer = (char *)xmalloc (128);      buffer_length = 128;    }  buffer_limit = &directive_buffer[buffer_length];  for (p = directive_buffer; ; )    {      int c;      /* Make buffer bigger if it is full.  */      if (p >= buffer_limit)	{	  register unsigned bytes_used = (p - directive_buffer);	  buffer_length *= 2;	  directive_buffer	    = (char *)xrealloc (directive_buffer, buffer_length);	  p = &directive_buffer[bytes_used];	  buffer_limit = &directive_buffer[buffer_length];	}      c = getc (finput);      /* Discard initial whitespace.  */      if ((c == ' ' || c == '\t') && p == directive_buffer)	continue;      /* Detect the end of the directive.  */      if ((c == '\n' && looking_for == 0)	  || c == EOF)	{	  if (looking_for != 0)	    fatal ("Bad directive -- missing close-quote");	  *p++ = '\0';	  *text = directive_buffer;	  return c;	}      *p++ = c;      if (c == '\n')	ffelex_next_line_ ();      /* Handle string and character constant syntax.  */      if (looking_for)	{	  if (looking_for == c && !char_escaped)	    looking_for = 0;	/* Found terminator... stop looking.  */	}      else	if (c == '\'' || c == '"')	  looking_for = c;	/* Don't stop buffering until we see another				   one of these (or an EOF).  */      /* Handle backslash.  */      char_escaped = (c == '\\' && ! char_escaped);    }}#endif/* Handle # directives that make it through (or are generated by) the   preprocessor.  As much as reasonably possible, emulate the behavior   of the gcc compiler phase cc1, though interactions between #include   and INCLUDE might possibly produce bizarre results in terms of   error reporting and the generation of debugging info vis-a-vis the   locations of some things.   Returns the next character unhandled, which is always newline or EOF.  */#if FFECOM_targetCURRENT == FFECOM_targetGCC#if defined HANDLE_PRAGMA/* Local versions of these macros, that can be passed as function pointers.  */static intpragma_getc (){  return getc (finput);}static voidpragma_ungetc (arg)     int arg;{  ungetc (arg, finput);}#endif /* HANDLE_PRAGMA */static intffelex_hash_ (FILE *finput){  register int c;  ffelexToken token = NULL;  /* Read first nonwhite char after the `#'.  */  c = ffelex_getc_ (finput);  while (c == ' ' || c == '\t')    c = ffelex_getc_ (finput);  /* If a letter follows, then if the word here is `line', skip     it and ignore it; otherwise, ignore the line, with an error     if the word isn't `pragma', `ident', `define', or `undef'.  */  if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))    {      if (c == 'p')	{	  if (getc (finput) == 'r'	      && getc (finput) == 'a'	      && getc (finput) == 'g'	      && getc (finput) == 'm'	      && getc (finput) == 'a'	      && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'		  || c == EOF))	    {#if 0	/* g77 doesn't handle pragmas, so ignores them FOR NOW. */	      static char buffer [128];	      char * buff = buffer;	      /* Read the pragma name into a buffer.  */	      while (isspace (c = getc (finput)))		continue;	      	      do		{		  * buff ++ = c;		  c = getc (finput);		}	      while (c != EOF && ! isspace (c) && c != '\n'		     && buff < buffer + 128);	      pragma_ungetc (c);			      * -- buff = 0;#ifdef HANDLE_PRAGMA	      if (HANDLE_PRAGMA (pragma_getc, pragma_ungetc, buffer))		goto skipline;#endif /* HANDLE_PRAGMA */#ifdef HANDLE_GENERIC_PRAGMAS	      if (handle_generic_pragma (buffer))		goto skipline;#endif /* !HANDLE_GENERIC_PRAGMAS */	      /* Issue a warning message if we have been asked to do so.		 Ignoring unknown pragmas in system header file unless		 an explcit -Wunknown-pragmas has been given. */	      if (warn_unknown_pragmas > 1		  || (warn_unknown_pragmas && ! in_system_header))		warning ("ignoring pragma: %s", token_buffer);#endif /* 0 */	      goto skipline;	    }	}      else if (c == 'd')	{	  if (getc (finput) == 'e'	      && getc (finput) == 'f'	      && getc (finput) == 'i'	      && getc (finput) == 'n'	      && getc (finput) == 'e'	      && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'		  || c == EOF))	    {	      char *text;	      c = ffelex_get_directive_line_ (&text, finput);#ifdef DWARF_DEBUGGING_INFO	      if ((debug_info_level == DINFO_LEVEL_VERBOSE)		  && (write_symbols == DWARF_DEBUG))		dwarfout_define (lineno, text);#endif /* DWARF_DEBUGGING_INFO */	      goto skipline;	    }	}      else if (c == 'u')	{	  if (getc (finput) == 'n'	      && getc (finput) == 'd'	      && getc (finput) == 'e'	      && getc (finput) == 'f'	      && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'		  || c == EOF))	    {	      char *text;	      c = ffelex_get_directive_line_ (&text, finput);#ifdef DWARF_DEBUGGING_INFO	      if ((debug_info_level == DINFO_LEVEL_VERBOSE)		  && (write_symbols == DWARF_DEBUG))		dwarfout_undef (lineno, text);#endif /* DWARF_DEBUGGING_INFO */	      goto skipline;	    }	}      else if (c == 'l')	{	  if (getc (finput) == 'i'	      && getc (finput) == 'n'	      && getc (finput) == 'e'	      && ((c = getc (finput)) == ' ' || c == '\t'))	    goto linenum;	}      else if (c == 'i')	{	  if (getc (finput) == 'd'	      && getc (finput) == 'e'	      && getc (finput) == 'n'	      && getc (finput) == 't'	      && ((c = getc (finput)) == ' ' || c == '\t'))	    {	      /* #ident.  The pedantic warning is now in cccp.c.  */	      /* Here we have just seen `#ident '.		 A string constant should follow.  */	      while (c == ' ' || c == '\t')		c = getc (finput);	      /* If no argument, ignore the line.  */	      if (c == '\n' || c == EOF)		return c;	      c = ffelex_cfelex_ (&token, finput, c);	      if ((token == NULL)		  || (ffelex_token_type (token) != FFELEX_typeCHARACTER))		{		  error ("invalid #ident");		  goto skipline;		}	      if (! flag_no_ident)		{#ifdef ASM_OUTPUT_IDENT		  ASM_OUTPUT_IDENT (asm_out_file,				    ffelex_token_text (token));#endif		}	      /* Skip the rest of this line.  */	      goto skipline;	    }	}      error ("undefined or invalid # directive");      goto skipline;    } linenum:  /* Here we have either `#line' or `# <nonletter>'.     In either case, it should be a line number; a digit should follow.  */  while (c == ' ' || c == '\t')    c = ffelex_getc_ (finput);  /* If the # is the only nonwhite char on the line,     just ignore it.  Check the new newline.  */  if (c == '\n' || c == EOF)    return c;  /* Something follows the #; read a token.  */  c = ffelex_cfelex_ (&token, finput, c);  if ((token != NULL)      && (ffelex_token_type (token) == FFELEX_typeNUMBER))    {      int old_lineno = lineno;      char *old_input_filename = input_filename;      ffewhereFile wf;      /* subtract one, because it is the following line that	 gets the specified number */      int l = atoi (ffelex_token_text (token)) - 1;      /* Is this the last nonwhite stuff on the line?  */      while (c == ' ' || c == '\t')	c = ffelex_getc_ (finput);      if (c == '\n' || c == EOF)	{	  /* No more: store the line number and check following line.  */	  lineno = l;	  if (!ffelex_kludge_flag_)	    {	      ffewhere_file_set (NULL, TRUE, (ffewhereLineNumber) l);	      if (token != NULL)		ffelex_token_kill (token);	    }	  return c;	}      /* More follows: it must be a string constant (filename).  */      /* Read the string constant.  */      c = ffelex_cfelex_ (&token, finput, c);      if ((token == NULL)	  || (ffelex_token_type (token) != FFELEX_typeCHARACTER))	{	  error ("invalid #line");	  goto skipline;	}      lineno = l;      if (ffelex_kludge_flag_)	input_filename = ffelex_token_text (token);      else	{	  wf = ffewhere_file_new (ffelex_token_text (token),				  ffelex_token_length (token));	  input_filename = ffewhere_file_name (wf);	  ffewhere_file_set (wf, TRUE, (ffewhereLineNumber) l);	}#if 0	/* Not sure what g77 should do with this yet. */      /* Each change of file name	 reinitializes whether we are now in a system header.  */      in_system_header = 0;#endif      if (main_input_filename == 0)	main_input_filename = input_filename;      /* Is this the last nonwhite stuff on the line?  */      while (c == ' ' || c == '\t')	c = getc (finput);      if (c == '\n' || c == EOF)	{	  if (!ffelex_kludge_flag_)	    {	      /* Update the name in the top element of input_file_stack.  */	      if (input_file_stack)		input_file_stack->name = input_filename;	      if (token != NULL)		ffelex_token_kill (token);	    }	  return c;	}      c = ffelex_cfelex_ (&token, finput, c);      /* `1' after file name means entering new file.	 `2' after file name means just left a file.  */      if ((token != NULL)	  && (ffelex_token_type (token) == FFELEX_typeNUMBER))	{	  int num = atoi (ffelex_token_text (token));	  if (ffelex_kludge_flag_)	    {	      lineno = 1;	      input_filename = old_input_filename;	      fatal ("Use `#line ...' instead of `# ...' in first line");	    }	  if (num == 1)	    {	      /* Pushing to a new file.  */	      ffelex_file_push_ (old_lineno, input_filename);	    }	  else if (num == 2)	    {	      /* Popping out of a file.  */	      ffelex_file_pop_ (input_filename);	    }	  /* Is this the last nonwhite stuff on the line?  */	  while (c == ' ' || c == '\t')	    c = getc (finput);	  if (c == '\n' || c == EOF)	    {	      if (token != NULL)		ffelex_token_kill (token);	      return c;	    }	  c = ffelex_cfelex_ (&token, finput, c);	}      /* `3' after file name means this is a system header file.  */#if 0	/* Not sure what g77 should do with this yet. */      if ((token != NULL)	  && (ffelex_token_type (token) == FFELEX_typeNUMBER)	  && (atoi (ffelex_token_text (token)) == 3))	in_system_header = 1;#endif      while (c == ' ' || c == '\t')	c = getc (finput);      if (((token != NULL)	   || (c != '\n' && c != EOF))	  && ffelex_kludge_flag_)	{	  lineno = 1;	  input_filename = old_input_filename;	  fatal ("Use `#line ...' instead of `# ...' in first line");	}    }  else    error ("invalid #-line");  /* skip the rest of this line.  */ skipline:  if ((token != NULL) && !ffelex_kludge_flag_)    ffelex_token_kill (token);  while ((c = getc (finput)) != EOF && c != '\n')    ;  return c;}#endif	/* FFECOM_targetCURRENT == FFECOM_targetGCC *//* "Image" a character onto the card image, return incremented column number.   Normally invoking this function as in     column = ffelex_image_char_ (c, column);   is the same as doing:     ffelex_card_image_[column++] = c;   However, tabs and carriage returns are handled specially, to preserve   the visual "image" of the input line (in most editors) in the card   image.   Carriage returns are ignored, as they are assumed to be followed   by newlines.   A tab is handled by first doing:     ffelex_card_image_[column++] = ' ';   That is, it translates to at least one space.  Then, as many spaces   are imaged as necessary to bring the column number to the next tab   position, where tab positions start in the ninth column and each

⌨️ 快捷键说明

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