From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 09/12] Move "paren_depth" into ada_parse_state
Date: Thu, 21 Mar 2024 13:03:37 -0600 [thread overview]
Message-ID: <20240321-ada-iterated-assign-v1-9-925cdd4f1f4a@adacore.com> (raw)
In-Reply-To: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com>
This moves the "paren_depth" global into ada_parse_state.
---
gdb/ada-exp.y | 3 +++
gdb/ada-lex.l | 12 ++++--------
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index 73178a58a0c..2b058571492 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -103,6 +103,9 @@ struct ada_parse_state
auto_obstack temp_space;
+ /* Depth of parentheses, used by the lexer. */
+ int paren_depth = 0;
+
private:
/* We don't have a good way to manage non-POD data in Yacc, so store
diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l
index 90cb5ba1b8a..9161c4377c0 100644
--- a/gdb/ada-lex.l
+++ b/gdb/ada-lex.l
@@ -108,9 +108,6 @@ static bool returned_complete = false;
pstate->lexptr += 1; \
}
-/* Depth of parentheses. */
-static int paren_depth;
-
%}
%option case-insensitive interactive nodefault noyywrap
@@ -268,7 +265,7 @@ false { return FALSEKEYWORD; }
[-&*+{}@/:<>=|;\[\]] { return yytext[0]; }
-"," { if (paren_depth == 0 && pstate->comma_terminates)
+"," { if (ada_parser->paren_depth == 0 && pstate->comma_terminates)
{
rewind_to_char (',');
return 0;
@@ -277,15 +274,15 @@ false { return FALSEKEYWORD; }
return ',';
}
-"(" { paren_depth += 1; return '('; }
-")" { if (paren_depth == 0)
+"(" { ada_parser->paren_depth += 1; return '('; }
+")" { if (ada_parser->paren_depth == 0)
{
rewind_to_char (')');
return 0;
}
else
{
- paren_depth -= 1;
+ ada_parser->paren_depth -= 1;
return ')';
}
}
@@ -349,7 +346,6 @@ static void
lexer_init (FILE *inp)
{
BEGIN INITIAL;
- paren_depth = 0;
returned_complete = false;
yyrestart (inp);
}
--
2.43.0
next prev parent reply other threads:[~2024-03-21 19:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-21 19:03 [PATCH 00/12] Ada iterated assignment, plus parser cleanups Tom Tromey
2024-03-21 19:03 ` [PATCH 01/12] Introduce and use aggregate_assigner type Tom Tromey
2024-03-21 19:03 ` [PATCH 02/12] Implement Ada 2022 iterated assignment Tom Tromey
2024-03-21 19:03 ` [PATCH 03/12] Introduce ada_parse_state Tom Tromey
2024-03-21 19:03 ` [PATCH 04/12] Move "int_storage" global into ada_parse_state Tom Tromey
2024-03-21 19:03 ` [PATCH 05/12] Move "components" and "associations" " Tom Tromey
2024-03-21 19:03 ` [PATCH 06/12] Move "assignments" global " Tom Tromey
2024-03-21 19:03 ` [PATCH 07/12] Move "iterated_associations" " Tom Tromey
2024-03-21 19:03 ` [PATCH 08/12] Move "temp_parse_space" " Tom Tromey
2024-03-21 19:03 ` Tom Tromey [this message]
2024-03-21 19:03 ` [PATCH 10/12] Move "returned_complete" " Tom Tromey
2024-03-21 19:03 ` [PATCH 11/12] Remove "numbuf" global Tom Tromey
2024-03-21 19:03 ` [PATCH 12/12] Constify ada-lex.l:attributes Tom Tromey
2024-04-02 17:35 ` [PATCH 00/12] Ada iterated assignment, plus parser cleanups Tom Tromey
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=20240321-ada-iterated-assign-v1-9-925cdd4f1f4a@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
/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