diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2020-01-28 16:00:13 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2020-01-28 16:00:13 +0000 |
commit | 5bd9fa5125033e094911c8a4b73ed4a2b1598e01 (patch) | |
tree | d9484a6ff599d6cd1b472297a635e75e949184cf /usr.sbin | |
parent | a09d1ee7eb5a927cdb1a7affe87567bfd3bdcdaa (diff) |
Simplify statement rules by using an optional new line.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/btrace/bt_parse.y | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/usr.sbin/btrace/bt_parse.y b/usr.sbin/btrace/bt_parse.y index f69f256d6eb..cc5a9f41e94 100644 --- a/usr.sbin/btrace/bt_parse.y +++ b/usr.sbin/btrace/bt_parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: bt_parse.y,v 1.5 2020/01/28 12:13:49 mpi Exp $ */ +/* $OpenBSD: bt_parse.y,v 1.6 2020/01/28 16:00:12 mpi Exp $ */ /* * Copyright (c) 2019 - 2020 Martin Pieuchot <mpi@openbsd.org> @@ -212,16 +212,19 @@ arglist : arg | arglist ',' arg { $$ = ba_append($1, $3); } ; -stmt : '\n' { $$ = NULL; } - | gvar '=' arg ';' { $$ = bv_set($1, $3); } - | gvar '[' arg ']' '=' marg ';' { $$ = bm_set($1, $3, $6); } - | fnN '(' arglist ')' ';' { $$ = bs_new($1, $3, NULL); } - | fn1 '(' arg ')' ';' { $$ = bs_new($1, $3, NULL); } - | fn0 '(' ')' ';' { $$ = bs_new($1, NULL, NULL); } - | mfn1 '(' map ')' ';' { $$ = bm_fn($1, $3, NULL); } +NL : /* empty */ | '\n' ; -stmtlist : stmt +stmt : ';' NL { $$ = NULL; } + | gvar '=' arg { $$ = bv_set($1, $3); } + | gvar '[' arg ']' '=' marg { $$ = bm_set($1, $3, $6); } + | fnN '(' arglist ')' { $$ = bs_new($1, $3, NULL); } + | fn1 '(' arg ')' { $$ = bs_new($1, $3, NULL); } + | fn0 '(' ')' { $$ = bs_new($1, NULL, NULL); } + | mfn1 '(' map ')' { $$ = bm_fn($1, $3, NULL); } + ; + +stmtlist : stmt | stmtlist stmt { $$ = bs_append($1, $2); } ; @@ -381,11 +384,12 @@ bs_append(struct bt_stmt *ds0, struct bt_stmt *ds1) { struct bt_stmt *bs = ds0; - assert(ds1 != NULL); - if (ds0 == NULL) return ds1; + if (ds1 == NULL) + return ds0; + while (SLIST_NEXT(bs, bs_next) != NULL) bs = SLIST_NEXT(bs, bs_next); |