summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--uscript/parser.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/uscript/parser.c b/uscript/parser.c
index 295f496..9fd4e27 100644
--- a/uscript/parser.c
+++ b/uscript/parser.c
@@ -82,7 +82,7 @@ void show_error(struct parser *p, struct token tok, const char *msg, ...)
fprintf(stderr, "on line %d at EOF:\n\t", tok.line);
else
fprintf(stderr, "on line %d at '%.*s':\n\t", tok.line, tok.len, tok.start);
-
+
va_list args;
va_start(args, msg);
vfprintf(stderr, msg, args);
@@ -704,15 +704,16 @@ void fun_stat(struct parser *p, bool is_global)
begin_function(p, proto);
- expect(p, '(', "expected '(' after function name");
- if (p->cur.kind != ')') {
- do {
- expect(p, TOKEN_IDENT, "expected arguement name");
- declare_variable(p, p->prev);
- proto->argc++;
- } while (consume(p, ','));
+ if (consume(p, '(')) {
+ if (p->cur.kind != ')') {
+ do {
+ expect(p, TOKEN_IDENT, "expected arguement name");
+ declare_variable(p, p->prev);
+ proto->argc++;
+ } while (consume(p, ','));
+ }
+ expect(p, ')', "expected ')' after arguments");
}
- expect(p, ')', "expected ')' after arguments");
while (p->cur.kind != TOKEN_END && p->cur.kind != TOKEN_EOF)
stat(p);