📄 lex.c
字号:
};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; }}voidclear_inline_text_obstack (){ obstack_free (&inline_text_obstack, inline_text_firstobj);}/* 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. */static voidstore_pending_inline (decl, t) tree decl; struct pending_inline *t;{ t->fndecl = decl; DECL_PENDING_INLINE_INFO (decl) = t; /* Because we use obstacks, we must process these in precise order. */ t->next = pending_inlines; pending_inlines = t;}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); 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->deja_vu = 0;#if 0 if (interface_unknown && processing_template_defn && flag_external_templates && ! DECL_IN_SYSTEM_HEADER (decl)) warn_if_unknown_interface (decl);#endif t->interface = (interface_unknown ? 1 : (interface_only ? 0 : 2)); store_pending_inline (decl, t); }}/* Consume a block -- actually, a method beginning with `:' or `{' -- and save it away on the specified obstack. */voidreinit_parse_for_block (pyychar, obstackp) int pyychar; struct obstack *obstackp;{ 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) { obstack_grow (obstackp, "return", 6); look_for_lbrac = 1; blev = 0; } else if (pyychar == TRY) { obstack_grow (obstackp, "try", 3); look_for_lbrac = 1; blev = 0; } else { yyerror ("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 ("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');}/* Consume a no-commas expression -- actually, a default argument -- and save it away on the specified obstack. */static voidreinit_parse_for_expr (obstackp) struct obstack *obstackp;{ register int c = 0; int starting_lineno = lineno; char *starting_filename = input_filename; int len; int look_for_semicolon = 0; int look_for_lbrac = 0; int plev = 0; 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... */ { if (plev <= 0 && (c == ')' || c == ',')) { put_back (c); goto done; } obstack_1grow (obstackp, c); if (c == '(' || c == '[') ++plev; else if (c == ']' || c == ')') --plev; 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); 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');}int do_snarf_defarg;/* Decide whether the default argument we are about to see should be gobbled up as text for later parsing. */voidmaybe_snarf_defarg (){ if (current_class_type && TYPE_BEING_DEFINED (current_class_type)) do_snarf_defarg = 1;}/* When we see a default argument in a method declaration, we snarf it as text using snarf_defarg. When we get up to namespace scope, we then go through and parse all of them using do_pending_defargs. Since yacc parsers are not reentrant, we retain defargs state in these two variables so that subsequent calls to do_pending_defargs can resume where the previous call left off. */tree defarg_fns;tree defarg_parm;treesnarf_defarg (){ int len;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -