commit - e9de881a9c92ad811717b8238eb1f2a8ddc73994
commit + 6be3eec6c0a53e627e1f2ec05179caaa7918b636
blob - af71f2f0c7017c92f2ae9edf574126b56d8e5a3f
blob + ae0042c91aa5434b5f01d7cedcbbc47b760e0a4b
--- cc/cc1/cc1.c
+++ cc/cc1/cc1.c
// ERROR HANDLING
-int line;
+int line = 1;
error (msg)
char *msg;
peekch (void)
{
- if (peekdch != EOF)
+ if (peekdch == EOF)
peekdch = readch ();
return peekdch;
case ')':
case '{':
case '}':
- return ch;
+ case '=':
+ case ';':
+ case ',':
+ return nextch ();
case EOF:
return TK_EOF;
default:
return 1;
case '[':
return error ("TODO: arrays");
+ case '=':
+ // TODO: init expr
+ next ();
+ break;
case ';':
- if (!first)
- return 1;
- // fallthrough
+ next ();
+ return 1;
+ case ',':
+ break;
default:
return error ("expected declaration");
}
parse (void)
{
while (peek () != TK_EOF) {
- decl (1);
+ if (!decl (1))
+ return error ("expected declaration");
}
return 0;