summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2023-06-14 07:20:54 +0000
committerrillig <rillig@NetBSD.org>2023-06-14 07:20:54 +0000
commitd3955ebbcb30368c577a941895b3efdeec2c4756 (patch)
treeb00c8ab62e3075036d7549399761c7a2b9c178ef
parent54ead8e566e43151ef45d234720331ce3e06e3cf (diff)
indent: merge parser symbols for stmt and stmt_list
They were handled in exactly the same way.
-rw-r--r--distrib/sets/lists/tests/mi4
-rw-r--r--tests/usr.bin/indent/Makefile3
-rw-r--r--tests/usr.bin/indent/psym_stmt.c39
-rw-r--r--tests/usr.bin/indent/psym_stmt_list.c47
-rw-r--r--usr.bin/indent/debug.c5
-rw-r--r--usr.bin/indent/indent.c6
-rw-r--r--usr.bin/indent/indent.h3
-rw-r--r--usr.bin/indent/parse.c11
8 files changed, 51 insertions, 67 deletions
diff --git a/distrib/sets/lists/tests/mi b/distrib/sets/lists/tests/mi
index 15ca5fbcc02..68b55a7607b 100644
--- a/distrib/sets/lists/tests/mi
+++ b/distrib/sets/lists/tests/mi
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1266 2023/06/01 07:27:30 rillig Exp $
+# $NetBSD: mi,v 1.1267 2023/06/14 07:20:54 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -5252,7 +5252,7 @@
./usr/tests/usr.bin/indent/psym_rbrace.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/psym_semicolon.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/psym_stmt.c tests-usr.bin-tests compattestfile,atf
-./usr/tests/usr.bin/indent/psym_stmt_list.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/psym_stmt_list.c tests-obsolete obsolete,atf
./usr/tests/usr.bin/indent/psym_switch_expr.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/psym_while_expr.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/struct.0 tests-obsolete obsolete,atf
diff --git a/tests/usr.bin/indent/Makefile b/tests/usr.bin/indent/Makefile
index 38a5fc0da7b..79213bca83b 100644
--- a/tests/usr.bin/indent/Makefile
+++ b/tests/usr.bin/indent/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.47 2023/05/20 21:32:05 rillig Exp $
+# $NetBSD: Makefile,v 1.48 2023/06/14 07:20:55 rillig Exp $
.include <bsd.own.mk>
@@ -109,7 +109,6 @@ FILES+= psym_lbrace.c
FILES+= psym_rbrace.c
FILES+= psym_semicolon.c
FILES+= psym_stmt.c
-FILES+= psym_stmt_list.c
FILES+= psym_switch_expr.c
FILES+= psym_while_expr.c
FILES+= t_options.lua
diff --git a/tests/usr.bin/indent/psym_stmt.c b/tests/usr.bin/indent/psym_stmt.c
index b51855d2e6d..9c68f1c4195 100644
--- a/tests/usr.bin/indent/psym_stmt.c
+++ b/tests/usr.bin/indent/psym_stmt.c
@@ -1,4 +1,4 @@
-/* $NetBSD: psym_stmt.c,v 1.6 2023/06/09 10:24:55 rillig Exp $ */
+/* $NetBSD: psym_stmt.c,v 1.7 2023/06/14 07:20:55 rillig Exp $ */
/*
* Tests for the parser symbol psym_stmt, which represents a statement on the
@@ -39,3 +39,40 @@ function(void)
//indent end
//indent run-equals-input -di0 -nlp -ci4
+
+
+//indent input
+void
+function(void)
+{
+ stmt();
+ int var;
+ stmt();
+ {
+ stmt();
+ int var;
+ stmt();
+ }
+}
+//indent end
+
+//indent run-equals-input -ldi0
+
+
+//indent input
+void
+return_after_rbrace(void)
+{
+ {}return;
+}
+//indent end
+
+//indent run
+void
+return_after_rbrace(void)
+{
+ {
+ }
+ return;
+}
+//indent end
diff --git a/tests/usr.bin/indent/psym_stmt_list.c b/tests/usr.bin/indent/psym_stmt_list.c
deleted file mode 100644
index 2700378548d..00000000000
--- a/tests/usr.bin/indent/psym_stmt_list.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/* $NetBSD: psym_stmt_list.c,v 1.5 2023/06/02 15:07:46 rillig Exp $ */
-
-/*
- * Tests for the parser symbol psym_stmt_list, which represents a list of
- * statements.
- *
- * Since C99, in such a statement list, statements can be intermixed with
- * declarations.
- *
- * TODO: explain why psym_stmt and psym_stmt_list are both necessary.
- */
-
-//indent input
-void
-function(void)
-{
- stmt();
- int var;
- stmt();
- {
- stmt();
- int var;
- stmt();
- }
-}
-//indent end
-
-//indent run-equals-input -ldi0
-
-
-//indent input
-void
-return_after_rbrace(void)
-{
- {}return;
-}
-//indent end
-
-//indent run
-void
-return_after_rbrace(void)
-{
- {
- }
- return;
-}
-//indent end
diff --git a/usr.bin/indent/debug.c b/usr.bin/indent/debug.c
index 65eb119b457..2866834077a 100644
--- a/usr.bin/indent/debug.c
+++ b/usr.bin/indent/debug.c
@@ -1,4 +1,4 @@
-/* $NetBSD: debug.c,v 1.53 2023/06/10 21:36:38 rillig Exp $ */
+/* $NetBSD: debug.c,v 1.54 2023/06/14 07:20:55 rillig Exp $ */
/*-
* Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: debug.c,v 1.53 2023/06/10 21:36:38 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.54 2023/06/14 07:20:55 rillig Exp $");
#include <stdarg.h>
#include <string.h>
@@ -99,7 +99,6 @@ const char *const psym_name[] = {
"}",
"decl",
"stmt",
- "stmt_list",
"for_exprs",
"if_expr",
"if_expr_stmt",
diff --git a/usr.bin/indent/indent.c b/usr.bin/indent/indent.c
index cc0e30fb366..606b1549585 100644
--- a/usr.bin/indent/indent.c
+++ b/usr.bin/indent/indent.c
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.357 2023/06/10 21:36:38 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.358 2023/06/14 07:20:55 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: indent.c,v 1.357 2023/06/10 21:36:38 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.358 2023/06/14 07:20:55 rillig Exp $");
#include <sys/param.h>
#include <err.h>
@@ -184,7 +184,7 @@ ind_add(int ind, const char *s, size_t len)
static void
init_globals(void)
{
- ps.psyms.sym[0] = psym_stmt_list;
+ ps.psyms.sym[0] = psym_stmt;
ps.prev_lsym = lsym_semicolon;
ps.next_col_1 = true;
ps.lbrace_kind = psym_lbrace_block;
diff --git a/usr.bin/indent/indent.h b/usr.bin/indent/indent.h
index b62a4c15d9e..e43fbd5ae93 100644
--- a/usr.bin/indent/indent.h
+++ b/usr.bin/indent/indent.h
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.h,v 1.188 2023/06/10 21:36:38 rillig Exp $ */
+/* $NetBSD: indent.h,v 1.189 2023/06/14 07:20:55 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -129,7 +129,6 @@ typedef enum parser_symbol {
psym_rbrace, /* not stored on the stack */
psym_decl,
psym_stmt,
- psym_stmt_list,
psym_for_exprs, /* 'for' '(' ... ')' */
psym_if_expr, /* 'if' '(' expr ')' */
psym_if_expr_stmt, /* 'if' '(' expr ')' stmt */
diff --git a/usr.bin/indent/parse.c b/usr.bin/indent/parse.c
index bb35f30acb0..0534f56fa92 100644
--- a/usr.bin/indent/parse.c
+++ b/usr.bin/indent/parse.c
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.72 2023/06/10 17:35:40 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.73 2023/06/14 07:20:55 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: parse.c,v 1.72 2023/06/10 17:35:40 rillig Exp $");
+__RCSID("$NetBSD: parse.c,v 1.73 2023/06/14 07:20:55 rillig Exp $");
#include <err.h>
@@ -54,8 +54,7 @@ psyms_reduce_stmt(struct psym_stack *psyms)
switch (psyms->sym[psyms->top - 1]) {
case psym_stmt:
- case psym_stmt_list:
- psyms->sym[--psyms->top] = psym_stmt_list;
+ psyms->sym[--psyms->top] = psym_stmt;
return true;
case psym_do:
@@ -67,7 +66,6 @@ psyms_reduce_stmt(struct psym_stack *psyms)
psyms->sym[--psyms->top] = psym_if_expr_stmt;
int i = psyms->top - 1;
while (psyms->sym[i] != psym_stmt &&
- psyms->sym[i] != psym_stmt_list &&
psyms->sym[i] != psym_lbrace_block)
--i;
ps.ind_level_follow = psyms->ind_level[i];
@@ -162,8 +160,7 @@ parse(parser_symbol psym)
case psym_lbrace_enum:
ps.break_after_comma = false;
if (psyms->sym[psyms->top] == psym_decl
- || psyms->sym[psyms->top] == psym_stmt
- || psyms->sym[psyms->top] == psym_stmt_list)
+ || psyms->sym[psyms->top] == psym_stmt)
++ps.ind_level_follow;
else if (code.len == 0) {
/* It is part of a while, for, etc. */