app.c
来自「基于4个mips核的noc设计」· C语言 代码 · 共 1,329 行 · 第 1/3 页
C
1,329 行
if (ch2 == '*') { for (;;) { do { ch2 = GET (); if (ch2 != EOF && IS_NEWLINE (ch2)) add_newlines++; } while (ch2 != EOF && ch2 != '*'); while (ch2 == '*') ch2 = GET (); if (ch2 == EOF || ch2 == '/') break; /* This UNGET will ensure that we count newlines correctly. */ UNGET (ch2); } if (ch2 == EOF) as_warn (_("end of file in multiline comment")); ch = ' '; goto recycle; }#ifdef DOUBLESLASH_LINE_COMMENTS else if (ch2 == '/') { do { ch = GET (); } while (ch != EOF && !IS_NEWLINE (ch)); if (ch == EOF) as_warn ("end of file in comment; newline inserted"); state = 0; PUT ('\n'); break; }#endif else { if (ch2 != EOF) UNGET (ch2); if (state == 9 || state == 10) state = 3; PUT (ch); } break; case LEX_IS_STRINGQUOTE: if (state == 10) { /* Preserve the whitespace in foo "bar" */ UNGET (ch); state = 3; PUT (' '); /* PUT didn't jump out. We could just break, but we know what will happen, so optimize a bit. */ ch = GET (); old_state = 3; } else if (state == 9) old_state = 3; else old_state = state; state = 5; PUT (ch); break;#ifndef IEEE_STYLE case LEX_IS_ONECHAR_QUOTE: if (state == 10) { /* Preserve the whitespace in foo 'b' */ UNGET (ch); state = 3; PUT (' '); break; } ch = GET (); if (ch == EOF) { as_warn (_("end of file after a one-character quote; \\0 inserted")); ch = 0; } if (ch == '\\') { ch = GET (); if (ch == EOF) { as_warn (_("end of file in escape character")); ch = '\\'; } else ch = process_escape (ch); } sprintf (out_buf, "%d", (int) (unsigned char) ch); /* None of these 'x constants for us. We want 'x'. */ if ((ch = GET ()) != '\'') {#ifdef REQUIRE_CHAR_CLOSE_QUOTE as_warn (_("Missing close quote: (assumed)"));#else if (ch != EOF) UNGET (ch);#endif } if (strlen (out_buf) == 1) { PUT (out_buf[0]); break; } if (state == 9) old_state = 3; else old_state = state; state = -1; out_string = out_buf; PUT (*out_string++); break;#endif case LEX_IS_COLON:#ifdef KEEP_WHITE_AROUND_COLON state = 9;#else if (state == 9 || state == 10) state = 3; else if (state != 3) state = 1;#endif PUT (ch); break; case LEX_IS_NEWLINE: /* Roll out a bunch of newlines from inside comments, etc. */ if (add_newlines) { --add_newlines; UNGET (ch); } /* Fall through. */ case LEX_IS_LINE_SEPARATOR: state = 0; PUT (ch); break;#ifdef TC_V850 case LEX_IS_DOUBLEDASH_1ST: ch2 = GET (); if (ch2 != '-') { UNGET (ch2); goto de_fault; } /* Read and skip to end of line. */ do { ch = GET (); } while (ch != EOF && ch != '\n'); if (ch == EOF) { as_warn (_("end of file in comment; newline inserted")); } state = 0; PUT ('\n'); break;#endif#ifdef DOUBLEBAR_PARALLEL case LEX_IS_DOUBLEBAR_1ST: ch2 = GET (); if (ch2 != '|') { UNGET (ch2); goto de_fault; } /* Reset back to state 1 and pretend that we are parsing a line from just after the first white space. */ state = 1; PUT ('|'); PUT ('|'); break;#endif case LEX_IS_LINE_COMMENT_START: /* FIXME-someday: The two character comment stuff was badly thought out. On i386, we want '/' as line comment start AND we want C style comments. hence this hack. The whole lexical process should be reworked. xoxorich. */ if (ch == '/') { ch2 = GET (); if (ch2 == '*') { old_state = 3; state = -2; break; } else { UNGET (ch2); } } /* bad hack */ if (state == 0 || state == 1) /* Only comment at start of line. */ { int startch; startch = ch; do { ch = GET (); } while (ch != EOF && IS_WHITESPACE (ch)); if (ch == EOF) { as_warn (_("end of file in comment; newline inserted")); PUT ('\n'); break; } if (ch < '0' || ch > '9' || state != 0 || startch != '#') { /* Not a cpp line. */ while (ch != EOF && !IS_NEWLINE (ch)) ch = GET (); if (ch == EOF) as_warn (_("EOF in Comment: Newline inserted")); state = 0; PUT ('\n'); break; } /* Looks like `# 123 "filename"' from cpp. */ UNGET (ch); old_state = 4; state = -1; if (scrub_m68k_mri) out_string = "\tappline "; else out_string = "\t.appline "; PUT (*out_string++); break; }#ifdef TC_D10V /* All insns end in a char for which LEX_IS_SYMBOL_COMPONENT is true. Trap is the only short insn that has a first operand that is neither register nor label. We must prevent exef0f ||trap #1 to degenerate to exef0f ||trap#1 . We can't make '#' LEX_IS_SYMBOL_COMPONENT because it is already LEX_IS_LINE_COMMENT_START. However, it is the only character in line_comment_chars for d10v, hence we can recognize it as such. */ /* An alternative approach would be to reset the state to 1 when we see '||', '<'- or '->', but that seems to be overkill. */ if (state == 10) PUT (' ');#endif /* We have a line comment character which is not at the start of a line. If this is also a normal comment character, fall through. Otherwise treat it as a default character. */ if (strchr (tc_comment_chars, ch) == NULL && (! scrub_m68k_mri || (ch != '!' && ch != '*'))) goto de_fault; if (scrub_m68k_mri && (ch == '!' || ch == '*' || ch == '#') && state != 1 && state != 10) goto de_fault; /* Fall through. */ case LEX_IS_COMMENT_START:#if defined TC_ARM && defined OBJ_ELF /* On the ARM, `@' is the comment character. Unfortunately this is also a special character in ELF .symver directives (and .type, though we deal with those another way). So we check if this line is such a directive, and treat the character as default if so. This is a hack. */ if ((symver_state != NULL) && (*symver_state == 0)) goto de_fault;#endif#ifdef WARN_COMMENTS if (!found_comment) as_where (&found_comment_file, &found_comment);#endif do { ch = GET (); } while (ch != EOF && !IS_NEWLINE (ch)); if (ch == EOF) as_warn (_("end of file in comment; newline inserted")); state = 0; PUT ('\n'); break; case LEX_IS_SYMBOL_COMPONENT: if (state == 10) { /* This is a symbol character following another symbol character, with whitespace in between. We skipped the whitespace earlier, so output it now. */ UNGET (ch); state = 3; PUT (' '); break; } if (state == 3) state = 9; /* This is a common case. Quickly copy CH and all the following symbol component or normal characters. */ if (to + 1 < toend && mri_state == NULL#if defined TC_ARM && defined OBJ_ELF && symver_state == NULL#endif ) { char *s; int len; for (s = from; s < fromend; s++) { int type; ch2 = *(unsigned char *) s; type = lex[ch2]; if (type != 0 && type != LEX_IS_SYMBOL_COMPONENT) break; } if (s > from) { /* Handle the last character normally, for simplicity. */ --s; } len = s - from; if (len > (toend - to) - 1) len = (toend - to) - 1; if (len > 0) { PUT (ch); if (len > 8) { memcpy (to, from, len); to += len; from += len; } else { switch (len) { case 8: *to++ = *from++; case 7: *to++ = *from++; case 6: *to++ = *from++; case 5: *to++ = *from++; case 4: *to++ = *from++; case 3: *to++ = *from++; case 2: *to++ = *from++; case 1: *to++ = *from++; } } ch = GET (); } } /* Fall through. */ default: de_fault: /* Some relatively `normal' character. */ if (state == 0) { state = 11; /* Now seeing label definition */ } else if (state == 1) { state = 2; /* Ditto */ } else if (state == 9) { if (lex[ch] != LEX_IS_SYMBOL_COMPONENT) state = 3; } else if (state == 10) { if (ch == '\\') { /* Special handling for backslash: a backslash may be the beginning of a formal parameter (of a macro) following another symbol character, with whitespace in between. If that is the case, we output a space before the parameter. Strictly speaking, correct handling depends upon what the macro parameter expands into; if the parameter expands into something which does not start with an operand character, then we don't want to keep the space. We don't have enough information to make the right choice, so here we are making the choice which is more likely to be correct. */ PUT (' '); } state = 3; } PUT (ch); break; } } /*NOTREACHED*/ fromeof: /* We have reached the end of the input. */ return to - tostart; tofull: /* The output buffer is full. Save any input we have not yet processed. */ if (fromend > from) { saved_input = from; saved_input_len = fromend - from; } else saved_input = NULL; return to - tostart;}/* end of app.c */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?