Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/indent indent: merge parser symbols for stmt and stm...
details: https://anonhg.NetBSD.org/src/rev/a83100b5854c
branches: trunk
changeset: 376364:a83100b5854c
user: rillig <rillig%NetBSD.org@localhost>
date: Wed Jun 14 07:20:54 2023 +0000
description:
indent: merge parser symbols for stmt and stmt_list
They were handled in exactly the same way.
diffstat:
distrib/sets/lists/tests/mi | 4 +-
tests/usr.bin/indent/Makefile | 3 +-
tests/usr.bin/indent/psym_stmt.c | 39 ++++++++++++++++++++++++++++-
tests/usr.bin/indent/psym_stmt_list.c | 47 -----------------------------------
usr.bin/indent/debug.c | 5 +--
usr.bin/indent/indent.c | 6 ++--
usr.bin/indent/indent.h | 3 +-
usr.bin/indent/parse.c | 11 ++-----
8 files changed, 51 insertions(+), 67 deletions(-)
diffs (252 lines):
diff -r 16b5b6500c46 -r a83100b5854c distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Wed Jun 14 02:28:41 2023 +0000
+++ b/distrib/sets/lists/tests/mi Wed Jun 14 07:20:54 2023 +0000
@@ -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 -r 16b5b6500c46 -r a83100b5854c tests/usr.bin/indent/Makefile
--- a/tests/usr.bin/indent/Makefile Wed Jun 14 02:28:41 2023 +0000
+++ b/tests/usr.bin/indent/Makefile Wed Jun 14 07:20:54 2023 +0000
@@ -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 -r 16b5b6500c46 -r a83100b5854c tests/usr.bin/indent/psym_stmt.c
--- a/tests/usr.bin/indent/psym_stmt.c Wed Jun 14 02:28:41 2023 +0000
+++ b/tests/usr.bin/indent/psym_stmt.c Wed Jun 14 07:20:54 2023 +0000
@@ -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 -r 16b5b6500c46 -r a83100b5854c tests/usr.bin/indent/psym_stmt_list.c
--- a/tests/usr.bin/indent/psym_stmt_list.c Wed Jun 14 02:28:41 2023 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 -r 16b5b6500c46 -r a83100b5854c usr.bin/indent/debug.c
--- a/usr.bin/indent/debug.c Wed Jun 14 02:28:41 2023 +0000
+++ b/usr.bin/indent/debug.c Wed Jun 14 07:20:54 2023 +0000
@@ -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 -r 16b5b6500c46 -r a83100b5854c usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c Wed Jun 14 02:28:41 2023 +0000
+++ b/usr.bin/indent/indent.c Wed Jun 14 07:20:54 2023 +0000
@@ -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 l
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 -r 16b5b6500c46 -r a83100b5854c usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h Wed Jun 14 02:28:41 2023 +0000
+++ b/usr.bin/indent/indent.h Wed Jun 14 07:20:54 2023 +0000
@@ -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 -r 16b5b6500c46 -r a83100b5854c usr.bin/indent/parse.c
--- a/usr.bin/indent/parse.c Wed Jun 14 02:28:41 2023 +0000
+++ b/usr.bin/indent/parse.c Wed Jun 14 07:20:54 2023 +0000
@@ -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 *psy
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 *psy
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. */
Home |
Main Index |
Thread Index |
Old Index