Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tromey@adacore.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 3/7] Change some Ada parser functions into methods
Date: Thu, 19 Nov 2026 13:48:58 -0500	[thread overview]
Message-ID: <7a117c30-a4fa-4d33-b89f-98f3baa8e7f0@simark.ca> (raw)
In-Reply-To: <20261119-more-parser-cleanups-v1-3-d85241f3fede@adacore.com>

On 11/19/26 12:58 PM, Tom Tromey wrote:
> This turns a few Ada parser functions into methods of ada_parse_state.
> This also renames some functions to conform to the gdb style.
> 
> This approach is somewhat cleaner.  Ultimately I think the Ada lexer
> (and hopefully someday the parser) would more resemble how the Rust
> parser works -- a self-contained class.

I think this is a good direction.

Do you plan on switching more functions to become methods and working
your way towards making ada-expt.y a "pure" parser?  Is that what you
mean by "resemble how the Rust parser works"?

I noted some minor comments below, the patch LGTM.

> @@ -378,14 +378,13 @@ ada_parse_state::process_id (std::string_view name0)
>  /* See ada-exp-parser.h.  */
>  
>  struct stoken
> -processString (const char *text, int len)
> +ada_parse_state::process_string (const char *text, const char *lim)

Sounds like that should take a string_view.

> diff --git a/gdb/ada-exp-parser.h b/gdb/ada-exp-parser.h
> index 4de2263ed6c..3d851e8fe7d 100644
> --- a/gdb/ada-exp-parser.h
> +++ b/gdb/ada-exp-parser.h
> @@ -137,6 +137,23 @@ struct ada_parse_state
>    */
>    stoken process_id (std::string_view name0);
>  
> +  /* Return TEXT (up to LIM), a string literal without surrounding
> +     quotes, with special hex character notations replaced with
> +     characters.  Result valid until the next call to ada_parse.  */
> +  struct stoken process_string (const char *text, const char *lim);
> +
> +  /* Interprets the prefix of NUM that consists of digits of the given BASE
> +     as an integer of that BASE, with the string EXP as an exponent.
> +     Puts value in yylval, and returns INT, if the string is valid.  Causes
> +     an error if the number is improperly formatted.  BASE, if NULL, defaults
> +     to "10", and EXP to "1".  The EXP does not contain a leading 'e' or 'E'.
> +  */
> +  int process_int (const char *base0, const char *num0, const char *exp0);

The names in the comment don't have the "0" suffix.  Does the 0 have a
meaning, like to indicate we expect this string to be null-terminated?

Simon

  reply	other threads:[~2026-11-19 18:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 17:58 [PATCH 0/7] More minor parser-related cleanups Tom Tromey
2026-11-19 17:58 ` [PATCH 1/7] Use compiled_regex in rust-parse.c Tom Tromey
2026-11-19 17:58 ` [PATCH 2/7] Move ada_tick_completer to ada-exp-parser.c Tom Tromey
2026-11-19 17:58 ` [PATCH 3/7] Change some Ada parser functions into methods Tom Tromey
2026-11-19 18:48   ` Simon Marchi [this message]
2026-11-20 20:57     ` Tom Tromey
2026-11-19 17:58 ` [PATCH 4/7] Simplify post-process-parser-output.sh Tom Tromey
2026-11-19 17:58 ` [PATCH 5/7] Remove fixed-sized buffer from ada_parse_state::lex_number Tom Tromey
2026-11-19 17:58 ` [PATCH 6/7] Hoist calls to canonicalize_numeral Tom Tromey
2026-11-19 17:58 ` [PATCH 7/7] Remove canonicalize_numeral Tom Tromey
2026-11-19 18:55 ` [PATCH 0/7] More minor parser-related cleanups Simon Marchi

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=7a117c30-a4fa-4d33-b89f-98f3baa8e7f0@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@adacore.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