Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: simon.marchi@polymtl.ca
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 10/17] gdb: rename LANG-exp.y to LANG-exp-parser.y
Date: Fri,  4 Sep 2026 12:56:42 -0400	[thread overview]
Message-ID: <20260904170338.1643894-11-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20260904170338.1643894-1-simon.marchi@polymtl.ca>

From: Simon Marchi <simon.marchi@efficios.com>

I would like to move the hand-written support code out of the expression
parsers, the way it was just done for cp-name-parser.y.  For
consistency, I would like to follow this naming scheme:

 - LANG-exp-parser.y: bison source file, generates LANG-exp-parser-gen.c
   and then LANG-exp-parser-gen.o.  These files will ultimately only
   contain the parser rules and the C++ code associated to them, ideally
   not anything too complex.

 - LANG-exp-parser.{c,h}: Hand-written support code for the parsers, as
   well as entry point to the parsers (wrappers around LANG_yyparse).  Much
   of this code currently lives at the bottom of .y files, even though it's
   just regular C++ code.

 - The existing files LANG-exp.{c,h} would be reserved for the expression
   evaluation side of things, which is separate from the parsing.

Therefore, rename all the .y files to end with "-parser.y".  I think this
makes things clear and also consistent with "cp-name-parser.y".

Change-Id: I10e8a4de7fa86c2b69b4d62581a9255929237294
---
 gdb/.gitignore                      | 28 +++++++--------
 gdb/Makefile.in                     | 55 +++++++++++++++--------------
 gdb/{ada-exp.y => ada-exp-parser.y} |  0
 gdb/ada-exp.h                       |  2 +-
 gdb/ada-lang.h                      |  2 +-
 gdb/ada-lex.l                       |  2 +-
 gdb/{c-exp.y => c-exp-parser.y}     |  0
 gdb/c-lang.h                        |  2 +-
 gdb/cp-name-parser.y                |  2 +-
 gdb/{d-exp.y => d-exp-parser.y}     |  2 +-
 gdb/d-lang.h                        |  2 +-
 gdb/{f-exp.y => f-exp-parser.y}     |  0
 gdb/{go-exp.y => go-exp-parser.y}   |  8 ++---
 gdb/{m2-exp.y => m2-exp-parser.y}   |  2 +-
 gdb/{p-exp.y => p-exp-parser.y}     |  2 +-
 15 files changed, 55 insertions(+), 54 deletions(-)
 rename gdb/{ada-exp.y => ada-exp-parser.y} (100%)
 rename gdb/{c-exp.y => c-exp-parser.y} (100%)
 rename gdb/{d-exp.y => d-exp-parser.y} (99%)
 rename gdb/{f-exp.y => f-exp-parser.y} (100%)
 rename gdb/{go-exp.y => go-exp-parser.y} (99%)
 rename gdb/{m2-exp.y => m2-exp-parser.y} (99%)
 rename gdb/{p-exp.y => p-exp-parser.y} (99%)

diff --git a/gdb/.gitignore b/gdb/.gitignore
index 6b5600dd695e..255cccbb3b24 100644
--- a/gdb/.gitignore
+++ b/gdb/.gitignore
@@ -5,25 +5,25 @@
 /version.c
 /xml-builtin.c
 
-/ada-exp-gen.c
-/ada-exp-gen.h
+/ada-exp-parser-gen.c
+/ada-exp-parser-gen.h
 /ada-lex-gen.c
 /ada-lex-gen.h
-/c-exp-gen.c
-/c-exp-gen.h
+/c-exp-parser-gen.c
+/c-exp-parser-gen.h
 /cp-name-parser-gen.c
 /cp-name-parser-gen.h
-/d-exp-gen.c
-/d-exp-gen.h
-/f-exp-gen.c
-/f-exp-gen.h
+/d-exp-parser-gen.c
+/d-exp-parser-gen.h
+/f-exp-parser-gen.c
+/f-exp-parser-gen.h
 /gdb
 /gcore
-/go-exp-gen.c
-/go-exp-gen.h
+/go-exp-parser-gen.c
+/go-exp-parser-gen.h
 /init.c
 /jit-reader.h
-/m2-exp-gen.c
-/m2-exp-gen.h
-/p-exp-gen.c
-/p-exp-gen.h
+/m2-exp-parser-gen.c
+/m2-exp-parser-gen.h
+/p-exp-parser-gen.c
+/p-exp-parser-gen.h
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index a7d79e08655e..1871ef255694 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1232,19 +1232,19 @@ COMMON_SFILES = \
 # Links made at configuration time should not be specified here, since
 # SFILES is used in building the distribution archive.
 SFILES = \
-	ada-exp.y \
+	ada-exp-parser.y \
 	arch/i386.c \
-	c-exp.y \
+	c-exp-parser.y \
 	cp-name-parser.y \
-	d-exp.y \
+	d-exp-parser.y \
 	dtrace-probe.c \
 	elf-none-tdep.c \
-	f-exp.y \
+	f-exp-parser.y \
 	gcore-elf.c \
 	gdb.c \
-	go-exp.y \
-	m2-exp.y \
-	p-exp.y \
+	go-exp-parser.y \
+	m2-exp-parser.y \
+	p-exp-parser.y \
 	proc-service.list \
 	ser-base.c \
 	ser-unix.c \
@@ -2059,15 +2059,15 @@ REQUIRED_SUBDIRS = doc | testsuite | data-directory
 
 # Parser intermediate files.
 YYFILES = \
-	ada-exp-gen.c \
+	ada-exp-parser-gen.c \
 	ada-lex-gen.c \
-	c-exp-gen.c \
+	c-exp-parser-gen.c \
 	cp-name-parser-gen.c \
-	d-exp-gen.c \
-	f-exp-gen.c \
-	go-exp-gen.c \
-	m2-exp-gen.c \
-	p-exp-gen.c
+	d-exp-parser-gen.c \
+	f-exp-parser-gen.c \
+	go-exp-parser-gen.c \
+	m2-exp-parser-gen.c \
+	p-exp-parser-gen.c
 
 # ada-lex-gen.c is included by another file, so it shouldn't wind up as
 # a .o itself.
@@ -2376,7 +2376,7 @@ INIT_FILES_FILTER_OUT = \
 
 INIT_FILES = \
 	$(patsubst %.o,%.c, \
-	  $(patsubst %-exp-gen.o,%-exp.y, \
+	  $(patsubst %-exp-parser-gen.o,%-exp-parser.y, \
 	    $(filter-out $(INIT_FILES_FILTER_OUT), $(COMMON_OBS))))
 
 init.c: stamp-init; @true
@@ -2718,12 +2718,13 @@ po/$(PACKAGE).pot: force
 #
 # YACC/LEX dependencies
 #
-# LANG-exp-gen.c is generated in objdir from LANG-exp.y if it doesn't
-# exist in srcdir, then compiled in objdir to LANG-exp-gen.o.  If we
-# said LANG-exp-gen.c rather than ./c-exp-gen.c some makes would
-# sometimes re-write it into $(srcdir)/c-exp-gen.c.  Remove bogus
+# LANG-exp-parser-gen.c is generated in objdir from LANG-exp-parser.y if
+# it doesn't exist in srcdir, then compiled in objdir to
+# LANG-exp-parser-gen.o.  If we said LANG-exp-parser-gen.c rather than
+# ./c-exp-parser-gen.c some makes would sometimes re-write it into
+# $(srcdir)/c-exp-parser-gen.c.  Remove bogus
 # decls for malloc/realloc/free which conflict with everything else.
-# Strictly speaking c-exp-gen.c should therefore depend on
+# Strictly speaking c-exp-parser-gen.c should therefore depend on
 # Makefile.in, but that was a pretty big annoyance.
 
 # Cancel make's built-in rules for producing a .c file from a .y or .l
@@ -2741,15 +2742,15 @@ POST_PROCESS_PARSER_OUTPUT = $(SHELL) $(POST_PROCESS_PARSER_OUTPUT_SH)
 # The prefix to give to the symbols each parser or lexer generator
 # produces, so that they can coexist in the same program.  There is no
 # rule tying it to the file name, so spell it out for each one.
-YY_PREFIX_ada-exp = ada_yy
+YY_PREFIX_ada-exp-parser = ada_yy
 YY_PREFIX_ada-lex = ada_yy
-YY_PREFIX_c-exp = c_yy
+YY_PREFIX_c-exp-parser = c_yy
 YY_PREFIX_cp-name-parser = cpname_yy
-YY_PREFIX_d-exp = d_yy
-YY_PREFIX_f-exp = f_yy
-YY_PREFIX_go-exp = go_yy
-YY_PREFIX_m2-exp = m2_yy
-YY_PREFIX_p-exp = pascal_yy
+YY_PREFIX_d-exp-parser = d_yy
+YY_PREFIX_f-exp-parser = f_yy
+YY_PREFIX_go-exp-parser = go_yy
+YY_PREFIX_m2-exp-parser = m2_yy
+YY_PREFIX_p-exp-parser = pascal_yy
 
 %-gen.c %-gen.h: %.y $(POST_PROCESS_PARSER_OUTPUT_SH)
 	$(ECHO_YACC) $(SHELL) $(YLWRAP) $< \
diff --git a/gdb/ada-exp.y b/gdb/ada-exp-parser.y
similarity index 100%
rename from gdb/ada-exp.y
rename to gdb/ada-exp-parser.y
diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h
index be9b441d0c1f..459b7d37b038 100644
--- a/gdb/ada-exp.h
+++ b/gdb/ada-exp.h
@@ -453,7 +453,7 @@ class ada_structop_operation
 private:
 
   /* We may need to provide a prefix to field name completion.  See
-     ada-exp.y:find_completion_bounds for details.  */
+     ada-exp-parser.y:find_completion_bounds for details.  */
   std::string m_prefix;
 };
 
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index bc821bdaa07f..e224f99dcc19 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -153,7 +153,7 @@ extern int ada_get_field_index (const struct type *type,
 				const char *field_name,
 				int maybe_missing);
 
-extern int ada_parse (struct parser_state *);    /* Defined in ada-exp.y */
+extern int ada_parse (struct parser_state *);    /* Defined in ada-exp-parser.y */
 
 			/* Defined in ada-typeprint.c */
 extern void ada_print_type (struct type *, const char *, struct ui_file *, int,
diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l
index 65989ebd0a56..dab1ad0d0067 100644
--- a/gdb/ada-lex.l
+++ b/gdb/ada-lex.l
@@ -18,7 +18,7 @@
 
 /*----------------------------------------------------------------------*/
 
-/* The converted version of this file is to be included in ada-exp.y, */
+/* The converted version of this file is to be included in ada-exp-parser.y, */
 /* the Ada parser for gdb.  The function yylex obtains characters from */
 /* the global pointer lexptr.  It returns a syntactic category for */
 /* each successive token and places a semantic value into yylval */
diff --git a/gdb/c-exp.y b/gdb/c-exp-parser.y
similarity index 100%
rename from gdb/c-exp.y
rename to gdb/c-exp-parser.y
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index dd1fbaefe8eb..f4458f3566db 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -58,7 +58,7 @@ enum c_string_type_values : unsigned
 
 DEF_ENUM_FLAGS_TYPE (enum c_string_type_values, c_string_type);
 
-/* Defined in c-exp.y.  */
+/* Defined in c-exp-parser.y.  */
 
 extern int c_parse (struct parser_state *);
 
diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y
index 687380c4ca68..57247f459fab 100644
--- a/gdb/cp-name-parser.y
+++ b/gdb/cp-name-parser.y
@@ -2,7 +2,7 @@
 
    Copyright (C) 2003-2026 Free Software Foundation, Inc.
 
-   Parts of the lexer are based on c-exp.y from GDB.
+   Parts of the lexer are based on c-exp-parser.y from GDB.
 
    This file is part of GDB.
 
diff --git a/gdb/d-exp.y b/gdb/d-exp-parser.y
similarity index 99%
rename from gdb/d-exp.y
rename to gdb/d-exp-parser.y
index 3b3a212cd741..ee23a6c3254c 100644
--- a/gdb/d-exp.y
+++ b/gdb/d-exp-parser.y
@@ -17,7 +17,7 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-/* This file is derived from c-exp.y, jv-exp.y.  */
+/* This file is derived from c-exp-parser.y, jv-exp.y.  */
 
 /* Parse a D expression from text in a string,
    and return the result as a struct expression pointer.
diff --git a/gdb/d-lang.h b/gdb/d-lang.h
index 7921d3ac804b..e8752ac95306 100644
--- a/gdb/d-lang.h
+++ b/gdb/d-lang.h
@@ -54,7 +54,7 @@ struct builtin_d_type
   struct type *builtin_dchar = nullptr;
 };
 
-/* Defined in d-exp.y.  */
+/* Defined in d-exp-parser.y.  */
 
 extern int d_parse (struct parser_state *);
 
diff --git a/gdb/f-exp.y b/gdb/f-exp-parser.y
similarity index 100%
rename from gdb/f-exp.y
rename to gdb/f-exp-parser.y
diff --git a/gdb/go-exp.y b/gdb/go-exp-parser.y
similarity index 99%
rename from gdb/go-exp.y
rename to gdb/go-exp-parser.y
index 1384c3ebeeec..ce29a00e1228 100644
--- a/gdb/go-exp.y
+++ b/gdb/go-exp-parser.y
@@ -17,7 +17,7 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-/* This file is derived from c-exp.y, p-exp.y.  */
+/* This file is derived from c-exp-parser.y, p-exp-parser.y.  */
 
 /* Parse a Go expression from text in a string,
    and return the result as a struct expression pointer.
@@ -626,9 +626,9 @@ name_not_typename
    LEN is the number of characters in it.  */
 
 /* FIXME: Needs some error checking for the float case.  */
-/* FIXME(dje): IWBN to use c-exp.y's parse_number if we could.
+/* FIXME(dje): IWBN to use c-exp-parser.y's parse_number if we could.
    That will require moving the guts into a function that we both call
-   as our YYSTYPE is different than c-exp.y's  */
+   as our YYSTYPE is different than c-exp-parser.y's  */
 
 static int
 parse_number (struct parser_state *par_state,
@@ -1422,7 +1422,7 @@ classify_name (struct parser_state *par_state, const struct block *block)
   return NAME;
 }
 
-/* This is taken from c-exp.y mostly to get something working.
+/* This is taken from c-exp-parser.y mostly to get something working.
    The basic structure has been kept because we may yet need some of it.  */
 
 static int
diff --git a/gdb/m2-exp.y b/gdb/m2-exp-parser.y
similarity index 99%
rename from gdb/m2-exp.y
rename to gdb/m2-exp-parser.y
index fae0f86ffdae..0f1c62c7ae52 100644
--- a/gdb/m2-exp.y
+++ b/gdb/m2-exp-parser.y
@@ -1,6 +1,6 @@
 /* YACC grammar for Modula-2 expressions, for GDB.
    Copyright (C) 1986-2026 Free Software Foundation, Inc.
-   Generated from expread.y (now c-exp.y) and contributed by the Department
+   Generated from expread.y (now c-exp-parser.y) and contributed by the Department
    of Computer Science at the State University of New York at Buffalo, 1991.
 
    This file is part of GDB.
diff --git a/gdb/p-exp.y b/gdb/p-exp-parser.y
similarity index 99%
rename from gdb/p-exp.y
rename to gdb/p-exp-parser.y
index dd4ae2cb209b..0bb2fca36965 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp-parser.y
@@ -16,7 +16,7 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-/* This file is derived from c-exp.y */
+/* This file is derived from c-exp-parser.y */
 
 /* Parse a Pascal expression from text in a string,
    and return the result as a  struct expression  pointer.
-- 
2.55.0


  parent reply	other threads:[~2026-09-04 17:06 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04 16:56 [PATCH 00/17] Move C++ support code out of .y files simon.marchi
2026-09-04 16:56 ` [PATCH 01/17] gdb/ada-exp-parser: remove name_info struct simon.marchi
2026-09-04 16:56 ` [PATCH 02/17] gdb: replace parse_type macros with functions simon.marchi
2026-09-04 16:56 ` [PATCH 03/17] gdb: suffix flex/bison output files with -gen.c simon.marchi
2026-09-04 16:56 ` [PATCH 04/17] gdb: move parser output post-processing to a script simon.marchi
2026-09-05  0:38   ` Kevin Buettner
2026-09-05  3:59     ` Simon Marchi
2026-09-04 16:56 ` [PATCH 05/17] gdb: let the parser and lexer generators prefix their symbols simon.marchi
2026-09-04 16:56 ` [PATCH 06/17] gdb: separate cp-name-parser's symbol prefix with an underscore simon.marchi
2026-09-04 16:56 ` [PATCH 07/17] gdb: make $(YACC) and $(FLEX) generate headers simon.marchi
2026-09-04 16:56 ` [PATCH 08/17] gdb: add check for stale build generated files simon.marchi
2026-09-04 16:56 ` [PATCH 09/17] gdb: move cp-name-parser.y's support code to cp-name-parser.c simon.marchi
2026-09-04 16:56 ` simon.marchi [this message]
2026-09-04 16:56 ` [PATCH 11/17] gdb: move c-exp-parser.y's support code to c-exp-parser.c simon.marchi
2026-09-04 16:56 ` [PATCH 12/17] gdb: move ada-exp-parser.y's support code to ada-exp-parser.c simon.marchi
2026-09-05  0:16   ` Kevin Buettner
2026-09-04 16:56 ` [PATCH 13/17] gdb: move d-exp-parser.y's support code to d-exp-parser.c simon.marchi
2026-09-04 16:56 ` [PATCH 14/17] gdb: move f-exp-parser.y's support code to f-exp-parser.c simon.marchi
2026-09-04 16:56 ` [PATCH 15/17] gdb: move go-exp-parser.y's support code to go-exp-parser.c simon.marchi
2026-09-04 16:56 ` [PATCH 16/17] gdb: move m2-exp-parser.y's support code to m2-exp-parser.c simon.marchi
2026-09-05  0:30   ` Kevin Buettner
2026-09-05  4:04     ` Simon Marchi
2026-09-04 16:56 ` [PATCH 17/17] gdb: move p-exp-parser.y's support code to p-exp-parser.c simon.marchi
2026-09-05  0:29   ` Kevin Buettner
2026-09-05  0:50 ` [PATCH 00/17] Move C++ support code out of .y files Kevin Buettner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260904170338.1643894-11-simon.marchi@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox