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

📄 lex.c

📁 gcc库的原代码,对编程有很大帮助.
💻 C
📖 第 1 页 / 共 5 页
字号:
  tree name = constructor_name (full_name);  switch (kind)    {      /* Destructors.  */    case 1:      declspecs = build_decl_list (NULL_TREE, ridpointers [(int) RID_VIRTUAL]);      /* Fall through...  */    case 0:      name = build_parse_node (BIT_NOT_EXPR, name);      args = void_list_node;      break;    case 2:      /* Default constructor.  */      args = void_list_node;      complex = TYPE_NEEDS_CONSTRUCTING (type);      break;    case 3:      type = build_type_variant (type, 1, 0);      /* Fall through...  */    case 4:      /* According to ARM $12.8, the default copy ctor will be declared, but	 not defined, unless it's needed.  */      argtype = build_reference_type (type);      args = tree_cons (NULL_TREE,			build_tree_list (hash_tree_chain (argtype, NULL_TREE),					 get_identifier ("_ctor_arg")),			void_list_node);      complex = TYPE_HAS_COMPLEX_INIT_REF (type);      break;    case 5:      type = build_type_variant (type, 1, 0);      /* Fall through...  */    case 6:      retref = 1;      declspecs = build_decl_list (NULL_TREE, full_name);      name = ansi_opname [(int) MODIFY_EXPR];      argtype = build_reference_type (type);      args = tree_cons (NULL_TREE,			build_tree_list (hash_tree_chain (argtype, NULL_TREE),					 get_identifier ("_ctor_arg")),			void_list_node);      complex = TYPE_HAS_COMPLEX_ASSIGN_REF (type);      break;    default:      my_friendly_abort (59);    }  declspecs = decl_tree_cons (NULL_TREE, ridpointers [(int) RID_INLINE],			      declspecs);  TREE_PARMLIST (args) = 1;  {    tree declarator = build_parse_node (CALL_EXPR, name, args, NULL_TREE);    if (retref)      declarator = build_parse_node (ADDR_EXPR, declarator);        fn = grokfield (declarator, declspecs, NULL_TREE, NULL_TREE,		    NULL_TREE, NULL_TREE);  }    if (fn == void_type_node)    return fn;  if (processing_template_defn)    {      SET_DECL_IMPLICIT_INSTANTIATION (fn);      repo_template_used (fn);    }  if (CLASSTYPE_INTERFACE_KNOWN (type))    {      DECL_INTERFACE_KNOWN (fn) = 1;      DECL_NOT_REALLY_EXTERN (fn) = (!CLASSTYPE_INTERFACE_ONLY (type)				     && flag_implement_inlines);    }  else    DECL_NOT_REALLY_EXTERN (fn) = 1;#if 0  /* When on-the-fly synthesis works properly, remove the second and third     conditions here.  */  if (flag_keep_inline_functions#if 0      || ! flag_no_inline      || complex#endif      || ! DECL_EXTERNAL (fn))    {      struct pending_inline *t;      t = (struct pending_inline *)	obstack_alloc (&synth_obstack, sizeof (struct pending_inline));      t->lineno = -kind;      t->can_free = 0;      t->interface = (interface_unknown ? 1 : (interface_only ? 0 : 2));      store_pending_inline (fn, t);    }  else#endif    mark_inline_for_output (fn);#ifdef DEBUG_DEFAULT_FUNCTIONS  { char *fn_type = NULL;    tree t = name;    switch (kind)      {      case 0: fn_type = "default destructor"; break;      case 1: fn_type = "virtual destructor"; break;      case 2: fn_type = "default constructor"; break;      case 3: fn_type = "default X(const X&)"; break;      case 4: fn_type = "default X(X&)"; break;      }    if (fn_type)      {	if (TREE_CODE (name) == BIT_NOT_EXPR)	  t = TREE_OPERAND (name, 0);	fprintf (stderr, "[[[[ %s for %s:\n%s]]]]\n", fn_type,		 IDENTIFIER_POINTER (t), func_buf);      }  }#endif /* DEBUG_DEFAULT_FUNCTIONS */  /* Show that this function was generated by the compiler.  */  SET_DECL_ARTIFICIAL (fn);    return fn;}/* Heuristic to tell whether the user is missing a semicolon   after a struct or enum declaration.  Emit an error message   if we know the user has blown it.  */voidcheck_for_missing_semicolon (type)     tree type;{  if (yychar < 0)    yychar = yylex ();  if ((yychar > 255       && yychar != SCSPEC       && yychar != IDENTIFIER       && yychar != TYPENAME)      || end_of_file)    {      if (ANON_AGGRNAME_P (TYPE_IDENTIFIER (type)))	error ("semicolon missing after %s declaration",	       TREE_CODE (type) == ENUMERAL_TYPE ? "enum" : "struct");      else	cp_error ("semicolon missing after declaration of `%T'", type);      shadow_tag (build_tree_list (0, type));    }  /* Could probably also hack cases where class { ... } f (); appears.  */  clear_anon_tags ();}voidnote_got_semicolon (type)     tree type;{  if (TREE_CODE_CLASS (TREE_CODE (type)) != 't')    my_friendly_abort (60);  if (IS_AGGR_TYPE (type))    CLASSTYPE_GOT_SEMICOLON (type) = 1;}voidnote_list_got_semicolon (declspecs)     tree declspecs;{  tree link;  for (link = declspecs; link; link = TREE_CHAIN (link))    {      tree type = TREE_VALUE (link);      if (TREE_CODE_CLASS (TREE_CODE (type)) == 't')	note_got_semicolon (type);    }  clear_anon_tags ();}/* If C is not whitespace, return C.   Otherwise skip whitespace and return first nonwhite char read.  */static intskip_white_space (c)     register int c;{  for (;;)    {      switch (c)	{	case '\n':	  c = check_newline ();	  break;	case ' ':	case '\t':	case '\f':	case '\r':	case '\v':	case '\b':	  do	    c = getch ();	  while (c == ' ' || c == '\t');	  break;	case '\\':	  c = getch ();	  if (c == '\n')	    lineno++;	  else	    error ("stray '\\' in program");	  c = getch ();	  break;	default:	  return (c);	}    }}/* Make the token buffer longer, preserving the data in it.   P should point to just beyond the last valid character in the old buffer.   The value we return is a pointer to the new buffer   at a place corresponding to P.  */static char *extend_token_buffer (p)     char *p;{  int offset = p - token_buffer;  maxtoken = maxtoken * 2 + 10;  token_buffer = (char *) xrealloc (token_buffer, maxtoken + 2);  return token_buffer + offset;}static intget_last_nonwhite_on_line (){  register int c;  /* Is this the last nonwhite stuff on the line?  */  if (nextchar >= 0)    c = nextchar, nextchar = -1;  else    c = getch ();  while (c == ' ' || c == '\t')    c = getch ();  return c;}/* At the beginning of a line, increment the line number   and process any #-directive on this line.   If the line is a #-directive, read the entire line and return a newline.   Otherwise, return the line's first non-whitespace character.  */int linemode;intcheck_newline (){  register int c;  register int token;  /* Read first nonwhite char on the line.  Do this before incrementing the     line number, in case we're at the end of saved text.  */  do    c = getch ();  while (c == ' ' || c == '\t');  lineno++;  if (c != '#')    {      /* If not #, return it so caller will use it.  */      return c;    }  /* Don't read beyond this line.  */  linemode = 1;    /* Read first nonwhite char after the `#'.  */  do    c = getch ();  while (c == ' ' || c == '\t');  /* 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'.  */  if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))    {      if (c == 'p')	{	  if (getch () == 'r'	      && getch () == 'a'	      && getch () == 'g'	      && getch () == 'm'	      && getch () == 'a')	    {	      /* Read first nonwhite char after the `#pragma'.  */	      do		c = getch ();	      while (c == ' ' || c == '\t');	      if (c == 'v'		  && getch () == 't'		  && getch () == 'a'		  && getch () == 'b'		  && getch () == 'l'		  && getch () == 'e'		  && ((c = getch ()) == ' ' || c == '\t'))		{		  extern tree pending_vtables;		  /* More follows: it must be a string constant (class name).  */		  token = real_yylex ();		  if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)		    {		      error ("invalid #pragma vtable");		      goto skipline;		    }		  if (write_virtuals != 2)		    {		      warning ("use `+e2' option to enable #pragma vtable");		      goto skipline;		    }		  pending_vtables = perm_tree_cons (NULL_TREE, get_identifier (TREE_STRING_POINTER (yylval.ttype)), pending_vtables);		  if (nextchar < 0)		    nextchar = getch ();		  c = nextchar;		  if (c != EOF)		    warning ("trailing characters ignored");		}	      else if (c == 'u'		       && getch () == 'n'		       && getch () == 'i'		       && getch () == 't'		       && ((c = getch ()) == ' ' || c == '\t'))		{		  /* More follows: it must be a string constant (unit name).  */		  token = real_yylex ();		  if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)		    {		      error ("invalid #pragma unit");		      goto skipline;		    }		  current_unit_name = get_identifier (TREE_STRING_POINTER (yylval.ttype));		  current_unit_language = current_lang_name;		  if (nextchar < 0)		    nextchar = getch ();		  c = nextchar;		  if (c != EOF)		    warning ("trailing characters ignored");		}	      else if (c == 'i')		{		  tree fileinfo = IDENTIFIER_CLASS_VALUE (get_time_identifier (input_filename));		  c = getch ();		  if (c == 'n'		      && getch () == 't'		      && getch () == 'e'		      && getch () == 'r'		      && getch () == 'f'		      && getch () == 'a'		      && getch () == 'c'		      && getch () == 'e'		      && ((c = getch ()) == ' ' || c == '\t' || c == EOF))		    {		      int warned_already = 0;		      char *main_filename = input_filename;		      main_filename = FILE_NAME_NONDIRECTORY (main_filename);		      while (c == ' ' || c == '\t')			c = getch ();		      if (c != EOF)			{			  put_back (c);			  token = real_yylex ();			  if (token != STRING			      || TREE_CODE (yylval.ttype) != STRING_CST)			    {			      error ("invalid `#pragma interface'");			      goto skipline;			    }			  main_filename = TREE_STRING_POINTER (yylval.ttype);			  c = getch();			  put_back (c);			}		      while (c == ' ' || c == '\t')			c = getch ();		      while (c != EOF)			{			  if (!warned_already && extra_warnings			      && c != ' ' && c != '\t')			    {			      warning ("garbage after `#pragma interface' ignored");			      warned_already = 1;			    }			  c = getch ();			}		      write_virtuals = 3;		      if (impl_file_chain == 0)			{			  /* If this is zero at this point, then we are			     auto-implementing.  */			  if (main_input_filename == 0)			    main_input_filename = input_filename;#ifdef AUTO_IMPLEMENT			  filename = FILE_NAME_NONDIRECTORY (main_input_filename);			  fi = get_time_identifier (filename);			  fi = IDENTIFIER_CLASS_VALUE (fi);			  TREE_INT_CST_LOW (fi) = 0;			  TREE_INT_CST_HIGH (fi) = 1;			  /* Get default.  */			  impl_fil

⌨️ 快捷键说明

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