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: in debug log, print token subtype in ...



details:   https://anonhg.NetBSD.org/src/rev/6a00d0f933ea
branches:  trunk
changeset: 990631:6a00d0f933ea
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Oct 31 17:22:47 2021 +0000

description:
indent: in debug log, print token subtype in same line

The keyword 'void' is parsed as lsym_type in some cases and lsym_ident
in others. Its corresponding keyword is always kw_type though. Put the
subtype into the same line as the other token information.

diffstat:

 tests/usr.bin/indent/fmt_decl.c |  12 ++++++------
 usr.bin/indent/lexi.c           |  10 ++++++----
 2 files changed, 12 insertions(+), 10 deletions(-)

diffs (79 lines):

diff -r 6e11e3498b1d -r 6a00d0f933ea tests/usr.bin/indent/fmt_decl.c
--- a/tests/usr.bin/indent/fmt_decl.c   Sun Oct 31 16:42:16 2021 +0000
+++ b/tests/usr.bin/indent/fmt_decl.c   Sun Oct 31 17:22:47 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fmt_decl.c,v 1.8 2021/10/31 10:56:19 rillig Exp $      */
+/*     $NetBSD: fmt_decl.c,v 1.9 2021/10/31 17:22:48 rillig Exp $      */
 /* $FreeBSD: head/usr.bin/indent/tests/declarations.0 334478 2018-06-01 09:41:15Z pstef $ */
 
 /* See FreeBSD r303570 */
@@ -62,27 +62,27 @@
  * As of 2021-10-31, indent parses the following function definition as these
  * tokens:
  *
- * line 1: type "void"
+ * line 1: type type "void"
  * line 1: newline "\n"
  * line 2: funcname "t1"
  * line 2: newline "\n"                repeated, see search_stmt
  * line 3: funcname "t1"       XXX: wrong line_no
  * line 3: lparen_or_lbracket "("
- * line 3: ident "char"                XXX: should be 'type', intuitively
+ * line 3: ident type "char"
  * line 3: unary_op "*"
  * line 3: ident "a"
  * line 3: comma ","
- * line 3: ident "int"         XXX: should be 'type'
+ * line 3: ident type "int"
  * line 3: ident "b"
  * line 3: comma ","
  * line 3: newline "\n"
- * line 4: ident "void"                XXX: should be 'type'
+ * line 4: ident type "void"
  * line 4: lparen_or_lbracket "("
  * line 4: unary_op "*"
  * line 4: ident "fn"
  * line 4: rparen_or_rbracket ")"
  * line 4: lparen_or_lbracket "("
- * line 4: ident "void"                XXX: should be 'type'
+ * line 4: ident type "void"
  * line 4: rparen_or_rbracket ")"
  * line 4: rparen_or_rbracket ")"
  * line 4: newline "\n"
diff -r 6e11e3498b1d -r 6a00d0f933ea usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Sun Oct 31 16:42:16 2021 +0000
+++ b/usr.bin/indent/lexi.c     Sun Oct 31 17:22:47 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.121 2021/10/31 10:09:43 rillig Exp $        */
+/*     $NetBSD: lexi.c,v 1.122 2021/10/31 17:22:47 rillig Exp $        */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.121 2021/10/31 10:09:43 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.122 2021/10/31 17:22:47 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -305,14 +305,16 @@
 
     debug_println("");
     debug_printf("line %d: %s", line_no, lsym_name(lsym));
+    if (ps.curr_keyword != kw_0)
+       debug_printf(" %s", kw_name(ps.curr_keyword));
     debug_vis_range(" \"", token.s, token.e, "\"\n");
+
     debug_print_buf("label", &lab);
     debug_print_buf("code", &code);
     debug_print_buf("comment", &com);
 
-    // prev_token
+    debug_println("    ps.prev_token = %s", lsym_name(ps.prev_token));
     debug_ps_keyword(prev_keyword);
-    debug_ps_keyword(curr_keyword);
     debug_ps_bool(curr_newline);
     debug_ps_bool(curr_col_1);
     debug_ps_bool(next_unary);



Home | Main Index | Thread Index | Old Index