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

📄 lex.c

📁 gcc库的原代码,对编程有很大帮助.
💻 C
📖 第 1 页 / 共 5 页
字号:
    }  while (c != matching_char);}static int nextyychar = YYEMPTY;static YYSTYPE nextyylval;struct pending_input {  int nextchar, yychar, nextyychar, eof;  YYSTYPE yylval, nextyylval;  struct obstack token_obstack;  int first_token;};struct pending_input *save_pending_input (){  struct pending_input *p;  p = (struct pending_input *) xmalloc (sizeof (struct pending_input));  p->nextchar = nextchar;  p->yychar = yychar;  p->nextyychar = nextyychar;  p->yylval = yylval;  p->nextyylval = nextyylval;  p->eof = end_of_file;  yychar = nextyychar = YYEMPTY;  nextchar = -1;  p->first_token = first_token;  p->token_obstack = token_obstack;  first_token = 0;  gcc_obstack_init (&token_obstack);  end_of_file = 0;  return p;}voidrestore_pending_input (p)     struct pending_input *p;{  my_friendly_assert (nextchar == -1, 229);  nextchar = p->nextchar;  my_friendly_assert (yychar == YYEMPTY || yychar == END_OF_SAVED_INPUT, 230);  yychar = p->yychar;  my_friendly_assert (nextyychar == YYEMPTY, 231);  nextyychar = p->nextyychar;  yylval = p->yylval;  nextyylval = p->nextyylval;  first_token = p->first_token;  obstack_free (&token_obstack, (char *) 0);  token_obstack = p->token_obstack;  end_of_file = p->eof;  free (p);}/* Return next non-whitespace input character, which may come   from `finput', or from `nextchar'.  */static intyynextch (){  int c;  if (nextchar >= 0)    {      c = nextchar;      nextchar = -1;    }  else c = getch ();  return skip_white_space (c);}/* Unget character CH from the input stream.   If RESCAN is non-zero, then we want to `see' this   character as the next input token.  */voidyyungetc (ch, rescan)     int ch;     int rescan;{  /* Unget a character from the input stream.  */  if (yychar == YYEMPTY || rescan == 0)    {      if (nextchar >= 0)	put_back (nextchar);      nextchar = ch;    }  else    {      my_friendly_assert (nextyychar == YYEMPTY, 232);      nextyychar = yychar;      nextyylval = yylval;      yychar = ch;    }}/* This function stores away the text for an inline function that should   be processed later.  It decides how much later, and may need to move   the info between obstacks; therefore, the caller should not refer to   the T parameter after calling this function.   This function also stores the list of template-parameter bindings that   will be needed for expanding the template, if any.  */static voidstore_pending_inline (decl, t)     tree decl;     struct pending_inline *t;{  extern int processing_template_defn;  int delay_to_eof = 0;  struct pending_inline **inlines;  t->fndecl = decl;  /* Default: compile right away, and no extra bindings are needed.  */  t->parm_vec = t->bindings = 0;  if (processing_template_defn)    {      tree type = current_class_type;      /* Assumption: In this (possibly) nested class sequence, only	 one name will have template parms.  */      while (type && TREE_CODE_CLASS (TREE_CODE (type)) == 't')	{	  tree decl = TYPE_NAME (type);	  tree tmpl = IDENTIFIER_TEMPLATE (DECL_NAME (decl));	  if (tmpl)	    {	      t->parm_vec = DECL_TEMPLATE_INFO (TREE_PURPOSE (tmpl))->parm_vec;	      t->bindings = TREE_VALUE (tmpl);	    }	  type = DECL_CONTEXT (decl);	}      if (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE	  || TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)	{	  if (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)	    my_friendly_assert (TYPE_MAX_VALUE (TREE_TYPE (decl)) == current_class_type,				233);	  /* Inline functions can be compiled immediately.  Other functions	     will be output separately, so if we're in interface-only mode,	     punt them now, or output them now if we're doing implementations	     and we know no overrides will exist.  Otherwise, we delay until	     end-of-file, to see if the definition is really required.  */	  if (DECL_THIS_INLINE (decl))	    /* delay_to_eof == 0 */;	  else if (current_class_type && !interface_unknown)	    {	      if (interface_only)		{#if 0		  print_node_brief (stderr, "\ndiscarding text for ", decl, 0);#endif		  if (t->can_free)		    obstack_free (&inline_text_obstack, t->buf);		  DECL_PENDING_INLINE_INFO (decl) = 0;		  return;		}	    }	  /* Don't delay the processing of virtual functions.  */	  else if (DECL_VINDEX (decl) == NULL_TREE)	    delay_to_eof = 1;	}      else	my_friendly_abort (58);    }  if (delay_to_eof)    {      extern struct pending_inline *pending_template_expansions;      if (t->can_free)	{	  char *free_to = t->buf;	  t->buf = (char *) obstack_copy (&permanent_obstack, t->buf,					  t->len + 1);	  t = (struct pending_inline *) obstack_copy (&permanent_obstack, 						      (char *)t, sizeof (*t));	  obstack_free (&inline_text_obstack, free_to);	}      inlines = &pending_template_expansions;      t->can_free = 0;    }  else    {      inlines = &pending_inlines;      DECL_PENDING_INLINE_INFO (decl) = t;    }  /* Because we use obstacks, we must process these in precise order.  */  t->next = *inlines;  *inlines = t;}void reinit_parse_for_block ();voidreinit_parse_for_method (yychar, decl)     int yychar;     tree decl;{  int len;  int starting_lineno = lineno;  char *starting_filename = input_filename;  reinit_parse_for_block (yychar, &inline_text_obstack, 0);  len = obstack_object_size (&inline_text_obstack);  current_base_init_list = NULL_TREE;  current_member_init_list = NULL_TREE;  if (decl == void_type_node      || (current_class_type && TYPE_REDEFINED (current_class_type)))    {      /* Happens when we get two declarations of the same	 function in the same scope.  */      char *buf = obstack_finish (&inline_text_obstack);      obstack_free (&inline_text_obstack, buf);      return;    }  else    {      struct pending_inline *t;      char *buf = obstack_finish (&inline_text_obstack);      t = (struct pending_inline *) obstack_alloc (&inline_text_obstack,						   sizeof (struct pending_inline));      t->lineno = starting_lineno;      t->filename = starting_filename;      t->token = YYEMPTY;      t->token_value = 0;      t->buf = buf;      t->len = len;      t->can_free = 1;      t->deja_vu = 0;      if (interface_unknown && processing_template_defn && flag_external_templates && ! DECL_IN_SYSTEM_HEADER (decl))	warn_if_unknown_interface (decl);      t->interface = (interface_unknown ? 1 : (interface_only ? 0 : 2));      store_pending_inline (decl, t);    }}/* Consume a block -- actually, a method or template definition beginning   with `:' or `{' -- and save it away on the specified obstack.   Argument IS_TEMPLATE indicates which set of error messages should be   output if something goes wrong.  This should really be cleaned up somehow,   without loss of clarity.  */voidreinit_parse_for_block (pyychar, obstackp, is_template)     int pyychar;     struct obstack *obstackp;     int is_template;{  register int c = 0;  int blev = 1;  int starting_lineno = lineno;  char *starting_filename = input_filename;  int len;  int look_for_semicolon = 0;  int look_for_lbrac = 0;  if (pyychar == '{')    obstack_1grow (obstackp, '{');  else if (pyychar == '=')    look_for_semicolon = 1;  else if (pyychar == ':')    {      obstack_1grow (obstackp, pyychar);      look_for_lbrac = 1;      blev = 0;    }  else if (pyychar == RETURN && !is_template)    {      obstack_grow (obstackp, "return", 6);      look_for_lbrac = 1;      blev = 0;    }  else if (pyychar == TRY && !is_template)    {      obstack_grow (obstackp, "try", 3);      look_for_lbrac = 1;      blev = 0;    }  else    {      yyerror (is_template	       ? "parse error in template specification"	       : "parse error in method specification");      obstack_1grow (obstackp, '{');    }  if (nextchar != EOF)    {      c = nextchar;      nextchar = EOF;    }  else    c = getch ();    while (c != EOF)    {      int this_lineno = lineno;      c = skip_white_space (c);      /* Don't lose our cool if there are lots of comments.  */      if (lineno == this_lineno + 1)	obstack_1grow (obstackp, '\n');      else if (lineno == this_lineno)	;      else if (lineno - this_lineno < 10)	{	  int i;	  for (i = lineno - this_lineno; i > 0; i--)	    obstack_1grow (obstackp, '\n');	}      else	{	  char buf[16];	  sprintf (buf, "\n# %d \"", lineno);	  len = strlen (buf);	  obstack_grow (obstackp, buf, len);	  len = strlen (input_filename);	  obstack_grow (obstackp, input_filename, len);	  obstack_1grow (obstackp, '\"');	  obstack_1grow (obstackp, '\n');	}      while (c > ' ')		/* ASCII dependent...  */	{	  obstack_1grow (obstackp, c);	  if (c == '{')	    {	      look_for_lbrac = 0;	      blev++;	    }	  else if (c == '}')	    {	      blev--;	      if (blev == 0 && !look_for_semicolon)		{		  if (pyychar == TRY)		    {		      if (peekyylex () == CATCH)			{			  yylex ();			  obstack_grow (obstackp, " catch ", 7);			  look_for_lbrac = 1;			}		      else			{			  yychar = '{';			  goto done;			}		    }		  else		    {		      goto done;		    }		}	    }	  else if (c == '\\')	    {	      /* Don't act on the next character...e.g, doing an escaped		 double-quote.  */	      c = getch ();	      if (c == EOF)		{		  error_with_file_and_line (starting_filename,					    starting_lineno,					    "end of file read inside definition");		  goto done;		}	      obstack_1grow (obstackp, c);	    }	  else if (c == '\"')	    consume_string (obstackp, c);	  else if (c == '\'')	    consume_string (obstackp, c);	  else if (c == ';')	    {	      if (look_for_lbrac)		{		  error (is_template			 ? "template body missing"			 : "function body for constructor missing");		  obstack_1grow (obstackp, '{');		  obstack_1grow (obstackp, '}');		  len += 2;		  goto done;		}	      else if (look_for_semicolon && blev == 0)		goto done;	    }	  c = getch ();	}      if (c == EOF)	{	  error_with_file_and_line (starting_filename,				    starting_lineno,				    "end of file read inside definition");	  goto done;	}      else if (c != '\n')	{	  obstack_1grow (obstackp, c);	  c = getch ();	}    } done:  obstack_1grow (obstackp, '\0');}/* Build a default function named NAME for type TYPE.   KIND says what to build.   When KIND == 0, build default destructor.   When KIND == 1, build virtual destructor.   When KIND == 2, build default constructor.   When KIND == 3, build default X(const X&) constructor.   When KIND == 4, build default X(X&) constructor.   When KIND == 5, build default operator = (const X&).   When KIND == 6, build default operator = (X&).  */treecons_up_default_function (type, full_name, kind)     tree type, full_name;     int kind;{  extern tree void_list_node;  char *func_buf = NULL;  int func_len = 0;  tree declspecs = NULL_TREE;  tree fn, args;  tree argtype;  int retref = 0;  int complex = 0;

⌨️ 快捷键说明

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