public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Move "paren_depth" into ada_parse_state
@ 2024-04-02 17:36 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2024-04-02 17:36 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d9346cbfcbf5705d6ee93e9b7b3e789489c50ebd
commit d9346cbfcbf5705d6ee93e9b7b3e789489c50ebd
Author: Tom Tromey <tromey@adacore.com>
Date: Thu Mar 14 12:29:40 2024 -0600
Move "paren_depth" into ada_parse_state
This moves the "paren_depth" global into ada_parse_state.
Diff:
---
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 b685ce968f7..21a384bc692 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -102,6 +102,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);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-04-02 17:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-02 17:36 [binutils-gdb] Move "paren_depth" into ada_parse_state Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).