[PATCH] Pass pratt parsed token to expr parser functions to fix expr locus
Thomas Schwinge
thomas@codesourcery.com
Thu Jul 29 15:18:50 GMT 2021
Hi!
On 2021-07-29T12:55:38+0200, Mark Wielaard <mark@klomp.org> wrote:
> On Thu, 2021-07-29 at 09:25 +0800, The Other via Gcc-rust wrote:
>> I think the core idea of this patch (fixing locations) is very
>> important and useful.
Agreed.
>> But isn’t it overkill to pass the token in instead of just the
>> location? You can avoid a fairly expensive shared_ptr copy by doing
>> so.
>
> I hadn't even noticed it was a smart pointer. At least the abstraction
> works transparently.
Wouldn't 'const_TokenPtr &pratt_parsed_token' work, passing a C++
reference? (Or am I missing some C++ "detail"; I haven't looked
carefully.)
> My idea was that the code might want to double
> check/assert it was the correct token (as it does in the case the
> parser function is called directly and it has to consume the first
> token itself).
That also makes sense to me. (Defensive programming; verify input data
to be what you expect to see.)
Grüße
Thomas
> But yes, things might be even simpler by passing the location directly.
> I'll try to rewrite the code tonight to pass a location and see how
> that looks.
>
> Thanks,
>
> Mark
> --
> Gcc-rust mailing list
> Gcc-rust@gcc.gnu.org
> https://gcc.gnu.org/mailman/listinfo/gcc-rust
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
More information about the Gcc-rust
mailing list