rui314/chibicc

Why isn't `tok->next` in `is_function()`

sunshaoce opened this issue · 3 comments

static bool is_function(Token *tok) {
  if (equal(tok, ";"))
    return false;

  Type dummy = {};
  Type *ty = declarator(&tok, tok, &dummy);
  return ty->kind == TY_FUNC;
}

I think if (equal(tok, ";")) could be if (equal(tok->next, ";"))

Hey @sunshaoce I am also studying these code too.
I think the if check whether this is a type declaration. like

int;  // this is type declaration
int main() { ... }

I see, thank you!