aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bootstrap/all.h2
-rw-r--r--bootstrap/parse.c44
-rw-r--r--bootstrap/test.cff25
3 files changed, 10 insertions, 61 deletions
diff --git a/bootstrap/all.h b/bootstrap/all.h
index 7631872..15f932c 100644
--- a/bootstrap/all.h
+++ b/bootstrap/all.h
@@ -201,7 +201,7 @@ struct fn {
};
struct macrocase {
- bool variadic, bodyarg;
+ bool variadic;
slice_t(const char *) params;
struct toktree body;
};
diff --git a/bootstrap/parse.c b/bootstrap/parse.c
index 2b0f08e..4372cdc 100644
--- a/bootstrap/parse.c
+++ b/bootstrap/parse.c
@@ -1642,7 +1642,6 @@ parseexpandmacro(struct parser *P, const struct macro *macro) {
struct expan expan = {0};
struct expanarg *expanargs;
struct macrocase c;
- bool bodyarg = 0;
expan.span = lexpeek(P).span;
lexexpect(P, '(');
@@ -1686,42 +1685,11 @@ parseexpandmacro(struct parser *P, const struct macro *macro) {
}
}
- if (lexmatch(P, &tok, '{')) {
- int pabal = 0,
- bkbal = 0,
- bcbal = 1;
- struct span espan = tok.span;
- vec_t(struct tok) toks = {0};
- struct toktree ttoks;
- vec_push(&toks, (struct tok){'{'});
- bodyarg = 1;
-
- while (bcbal > 0) {
- tok = lex(P);
- switch (tok.t) {
- case '[': ++bkbal; break;
- case ']': --bkbal; break;
- case '{': ++bcbal; break;
- case '}': --bcbal; break;
- case '(': ++pabal; break;
- case ')': --pabal; break;
- case TKeof:
- fatal(P, espan, "unterminated macro `%s' invokation", macro->name);
- }
- vec_push(&toks, tok);
- }
-
- vec_slice_cpy(&ttoks, &toks);
- vec_push(&args, ttoks);
- }
-
for (int i = 0; i < macro->cs.n; ++i) {
c = macro->cs.d[i];
- if (c.bodyarg && bodyarg && args.length == c.params.n) {
- goto ok;
- } else if (!c.variadic && args.length == c.params.n && !bodyarg) {
+ if (!c.variadic && args.length == c.params.n) {
goto ok;
- } else if (c.variadic && args.length >= c.params.n - 1 && !bodyarg) {
+ } else if (c.variadic && args.length >= c.params.n - 1) {
int n = args.length - (c.params.n - 1);
if (n == 0) {
vec_push(&args, (struct toktree){0});
@@ -1971,14 +1939,8 @@ parsemacrocase(struct parser *P) {
lexexpect(P, ')');
break;
} else {
- if (lexmatch(P, &tok, '&'))
- c.bodyarg = 1;
vec_push(&params, lexexpects(P, TKident, "parameter name").str);
- if (c.bodyarg) {
- lexmatch(P, &tok, ',');
- lexexpect(P, ')');
- break;
- } else if (!lexmatch(P, &tok, ',')) {
+ if (!lexmatch(P, &tok, ',')) {
lexexpect(P, ')');
break;
}
diff --git a/bootstrap/test.cff b/bootstrap/test.cff
index 6c0f605..011d386 100644
--- a/bootstrap/test.cff
+++ b/bootstrap/test.cff
@@ -20,18 +20,6 @@ enum Color {
static xs *void = {},
ok = 6;
-defmacro each(i, x, arr, &body) [
- for let i = 0; i < sizeof(arr)/sizeof(arr[0]); ++i {
- let x = arr[i];
- body
- }
-]
-defmacro times(n,&body) [
- for let $i = 0; $i < (n); ++$i {
- body
- }
-]
-
fn isort(xs *int, n usize) void {
fn icmp(lhs *const void, rhs *const void, _ *void) int {
let lhs = *as(*int)lhs,
@@ -52,14 +40,13 @@ extern fn main (argc int, argv **u8) int {
let p = &x;
printf("v = { %g, %g }\n", x.x, p.y);
- let xs [10]int = { [4] = 1, 2, [1 - 1] = 3 };
- isort(xs, 10);
-
- each(i, x, xs) {
- printf("%d\n", xs[i]);
- }
+ let is [10]int = { [4] = 1, 2, [1 - 1] = 3 };
+ isort(is, 10);
+ for let i = 0; i < 10; ++i {
+ printf("%d\n", is[i]);
+ }
- printf("sizeof(is) = %zu\n", sizeof(xs));
+ printf("sizeof(is) = %zu\n", sizeof(is));
printf("sizeof *void = %zu\n", sizeof *void);