static Obj *read_expr(void *root) { for (;;) { int c = getchar(); if (c == ' ' || c == '\n' || c == '\r' || c == '\t') continue; if (c == EOF) return NULL; if (c == ';') { skip_line(); continue; } if (c == '(') return read_list(root); if (c == ')') return Cparen; if (c == '.') return Dot; if (c == '\'') return read_quote(root); if (isdigit(c)) return make_int(root, read_number(c - '0')); if (c == '-' && isdigit(peek())) return make_int(root, -read_number(0)); if (isalpha(c) || strchr(symbol_chars, c)) return read_symbol(root, c); error("Don't know how to handle %c", c); } }
alloc_t *read(FILE *f) { alloc_t *x; char c; c = next_token_char(f); if (c == '\'') { x = read_quote(f); } else if (c == '(') { x = read_list(f); } else if (c == ')') { longjmp(fatal, ERROR_RIGHT_PAREN); } else if (c != EOF) { c = ungetc(c, f); if (c == EOF) { longjmp(fatal, ERROR_PUSHBACK); } x = read_symbol(f); } return x; }
static Obj *read(Env *env, Obj *root, char **p) { for (;;) { char c = **p; (*p)++; if (c == '\0') return NULL; if (c == ' ' || c == '\n' || c == '\r' || c == '\t') continue; if (c == '(') return read_sexp(env, root, p); if (c == ')') error("unclosed open parenthesis"); if (c == '\'') return read_quote(env, root, p); if (isdigit(c)) return read_number(env, root, p, c - '0'); if (isalpha(c) || strchr("+=!@#$%^&*", c)) return read_symbol(env, root, p, c); error("don't know how to handle %c", c); } }