aboutsummaryrefslogtreecommitdiff
path: root/src/parse.cff
diff options
context:
space:
mode:
Diffstat (limited to 'src/parse.cff')
-rw-r--r--src/parse.cff19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/parse.cff b/src/parse.cff
index bd5262e..7249390 100644
--- a/src/parse.cff
+++ b/src/parse.cff
@@ -561,7 +561,8 @@ fn lex(P *Parser) Tok {
fn lexpeek(P *Parser) Tok {
switch P.peektok {
- case Some t; return t;
+ case Some t;
+ return t;
}
let tok = lex(P);
P.peektok = :Some(tok);
@@ -2763,6 +2764,8 @@ fn parsevardecl(P *Parser, toplevel bool, externp bool, letp bool, yield DeclYie
} while !lexmatch(P, &tok, ';');
}
+ extern fn BREAK() void {}
+
fn parsefn(P *Parser, loc Loc, toplevel bool, externp bool, name *const u8) *Decl {
let decl Decl = {
name,
@@ -2784,6 +2787,11 @@ fn parsefn(P *Parser, loc Loc, toplevel bool, externp bool, name *const u8) *Dec
static id int = 0;
Fn.id = ++id;
// TODO tlalloc necessary for templates. but it leaks some memory
+ let d Decl #?;
+ extern fn memset(*void, int, usize) *void;
+ memset(&d, 0, sizeof(d));
+ d = decl;
+
let decl = putdecl_alloc(P, P.tlalloc, loc, decl);
let Fn = &decl.u.Fn;
decl.toplevel = toplevel;
@@ -3040,6 +3048,12 @@ fn parsedecls(P *Parser, loc Loc, yield DeclYielder, yarg *void, toplevel bool)
externp = #f,
name *const u8 = #null;
+
+ if lexmatch(P, &tok, ';') or lexmatch(P, &tok, :eof) {
+ // no-op
+ return;
+ }
+
let attr u32 = 0;
if lexmatch(P, &tok, '#') {
lexexpect(P, '[');
@@ -3062,9 +3076,6 @@ fn parsedecls(P *Parser, loc Loc, yield DeclYielder, yarg *void, toplevel bool)
switch {
- case lexmatch(P, &tok, ';') or lexmatch(P, &tok, :eof);
- // no-op
-
case lexmatch(P, &tok, :kw_fn);
let name = lexmatch(P, &tok, :ident) ? tok.u.ident : #null;
decl = parsefn(P, tok.loc, toplevel, externp, name);