aboutsummaryrefslogtreecommitdiff
path: root/gdb/parse.c
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2024-01-02 14:02:44 +0000
committerAndrew Burgess <aburgess@redhat.com>2024-01-04 09:24:18 +0000
commite89496f42ac7b2d6fbba15f98f3caf496de050f4 (patch)
tree0e411dc7a998c3a56e25bba1adde8ad2642d4122 /gdb/parse.c
parentc9f1e0dfc8f02a7772aa383cc305d9049075d1d8 (diff)
downloadgdb-e89496f42ac7b2d6fbba15f98f3caf496de050f4.zip
gdb-e89496f42ac7b2d6fbba15f98f3caf496de050f4.tar.gz
gdb-e89496f42ac7b2d6fbba15f98f3caf496de050f4.tar.bz2
gdb: merge error handling from different expression parsers
Many (all?) of the expression parsers implement yyerror to handle parser errors, and all of these functions are basically identical. This commit adds a new parser_state::parse_error() function, which implements the common error handling code, this function can then be called from all the different yyerror functions. The benefit of this is that (in a future commit) I can improve the error output, and all the expression parsers will benefit. This commit is pure refactoring though, and so, there should be no user visible changes after this commit. Approved-By: John Baldwin <jhb@FreeBSD.org>
Diffstat (limited to 'gdb/parse.c')
-rw-r--r--gdb/parse.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/gdb/parse.c b/gdb/parse.c
index b57d112..efac0de 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -244,6 +244,17 @@ parser_state::push_dollar (struct stoken str)
(create_internalvar (copy.c_str () + 1));
}
+/* See parser-defs.h. */
+
+void
+parser_state::parse_error (const char *msg)
+{
+ if (this->prev_lexptr)
+ this->lexptr = this->prev_lexptr;
+
+ error (_("A %s in expression, near `%s'."), msg, this->lexptr);
+}
+
const char *