static EORB_CPP_node *read_expr_10 (void) { char c; char *w; EORB_CPP_node *n; #ifdef DEBUG_EXPR if (debugging) { outputs("~E10:"); } #endif while (1) { c = getnhsexpand(); switch (c) { case '-': case '~': case '!': #ifdef DEBUG_EXPR if (debugging) { outputc(c); } #endif n = read_expr_10(); #ifdef DEBUG_EXPR if (debugging) { outputs("~"); } #endif return (newnode(0, c, n)); break; case 'd': Push(c); input_mark(); w = read_ident(); if (strcmp(w, "defined") == 0) { c = getnonspace(); if (c == '(') { char *id; id = read_ident(); if (id) { c = getnonspace(); if (c == ')') { input_unmark(); #ifdef DEBUG_EXPR if (debugging) { outputs("ifdef"); } #endif return (newname(id)); } } } else if (isbsymchar(c)) { char *id; Push(c); id = read_ident(); if (id) { input_unmark(); #ifdef DEBUG_EXPR if (debugging) { outputs("ifdef"); } #endif return (newname(id)); } } } input_recover(); n = read_expr_11(); #ifdef DEBUG_EXPR if (debugging) { outputs("~"); } #endif return (n); break; default: Push(c); n = read_expr_11(); #ifdef DEBUG_EXPR if (debugging) { outputs("~"); } #endif return (n); break; } } }
int preprocess_getc(void) { int result = 0; int backslash = 0; do { int c; int haddigit; result = read_char(); if (result != 0) { break; } c = Get(); if (c == -1) { break; } if (backslash) { maybe_print(c); backslash = 0; continue; } if (!incldep && (isdigit((int) c) || (c == '.'))) { haddigit = 0; while (isdigit((int) c) || (c == '.')) { haddigit |= isdigit((int) c); maybe_print(c); c = Get(); if (c == -1) { return 0; } } if (haddigit && ((c == 'e') || (c == 'E'))) { maybe_print(c); c = Get(); if (c == -1) { return 0; } while (isdigit((int) c)) { maybe_print(c); c = Get(); if (c == -1) { return 0; } } } Push(c); continue; } if (quote) { if (c == '\\') { maybe_print(c); backslash = 1; continue; } else if ((c == quote) || (c == '\n')) { maybe_print(c); quote = 0; continue; } else { maybe_print(c); continue; } } if (c == '\\') /* this weirdness is Reiser semantics.... */ { backslash = 1; maybe_print(c); continue; } if ((c == '\'') || (c == '"')) { quote = c; maybe_print(c); } else if (linefirst && (c == '#')) { do_sharp(); } else if (do_at_ctrls && (c == '@')) { do_at(); } else if (! incldep) { if (isbsymchar(c) && !in_false_if()) { char *cp; DEF *d; cp = init_accum(); while (issymchar(c)) { accum_char(cp, c); c = Get(); if (c == -1) { return 0; } } Push(c); cp = accum_result(cp); #ifdef DEBUG_MAIN if (debugging) { outputs("<word:"); outputs(cp); outputs(">"); } #endif d = find_def(cp); if (d) { expand_def(d); } else { for (;*cp;cp++) { maybe_print(*cp); } } } else if (c == '/') { int d; d = Get(); if (d == -1) { return 0; } if (d == '*') { d = '\0'; if (keep_comments) { maybe_print('/'); maybe_print('*'); } do { c = d; d = Get(); if (d == -1) { return 0; } if ((d == '\n') || keep_comments) { maybe_print(d); } } while ((c != '*') || (d != '/')); } else if (d == '/') { if (keep_comments) { maybe_print('/'); maybe_print('/'); } do { c = Get(); if (c == -1) { return 0; } if ((c == '\n') || keep_comments) { maybe_print(c); } } while (c != '\n'); } else { Push(d); maybe_print(c); } } else { maybe_print(c); } } } while (result == 0); return result; }
static EORB_CPP_node *read_expr_11 (void) { char c; #ifdef DEBUG_EXPR if (debugging) { outputs("~E11:"); } #endif while (1) { c = getnhsexpand(); if (c == '(') { EORB_CPP_node *n; #ifdef DEBUG_EXPR if (debugging) { outputs("()"); } #endif n = read_expr_(); c = getnhsexpand(); if (c != ')') { err_head(); fprintf(stderr, "expression syntax error -- missing ) supplied\n"); Push(c); } #ifdef DEBUG_EXPR if (debugging) { outputs("~"); } #endif return (n); } else if (isdigit((int) c)) { int base; static char digits[] = "0123456789abcdefABCDEF"; static char values[] = "\0\1\2\3\4\5\6\7\10\11\12\13\14\15\16\17\12\13\14\15\16\17"; char *d; int v; #ifdef DEBUG_EXPR if (debugging) { outputs("N"); } #endif base = 10; if (c == '0') { base = 8; c = Get(); if ((c == 'x') || (c == 'X')) { base = 16; c = Get(); } } v = 0; while (1) { d = strchr(digits, c); if (d == 0) { Push(c); #ifdef DEBUG_EXPR if (debugging) { outputd(v); outputs("~"); } #endif return (newleaf(v)); } else if (values[d -digits] >= base) { err_head(); fprintf(stderr, "warning: illegal %sdigit `%c'\n", (base == 16) ? "hex " : (base == 8) ? "octal " : "", c); } v = (v * base) + values[d - digits]; c = Get(); } } else if (c == '\'') { int i; int j; int n; i = 0; n = 0; while (1) { j = get_quote_char(); if (j < 0) { break; } i = (i << 8) | j; n ++; } if (n > 4) { err_head(); fprintf(stderr, "warning: too many characters in character constant\n"); } return (newleaf(i)); } else if ((c == '\n') && !sharp) {} else { char *id; if (complain) { err_head(); fprintf(stderr, "expression syntax error -- number expected\n"); } if (isbsymchar(c)) { Push(c); id = read_ident(); } else { id = 0; } #ifdef DEBUG_EXPR if (debugging) { outputs("0("); outputc(c); outputs(":"); outputs(id ? id : "(none)"); outputs(")~"); } #endif if (id) { os_free(id); } return (newleaf(0)); } } }