From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by sourceware.org (Postfix) with ESMTPS id 9B11A3858D3C for ; Fri, 18 Mar 2022 16:00:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9B11A3858D3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f43.google.com with SMTP id t24so2129982wra.2 for ; Fri, 18 Mar 2022 09:00:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=YHHP4ty2KUNJMJhls2bRptFSblk6axa8FhRGtUXEZdc=; b=YYXo1MkTe6TxpgSPuoi0a7m4wBFvEyJNWP629ESzljNLoW85hnJmOv8SSYUunst7eN Lj3Y+NzKhOFnhscCvgq509AuoGMnIr6f7ELU2hGtwZ/TK138vqimX891vKnsi9x454BF DrSUEhV4dHXlceXPp+uLUFsb39llfgzpIdcwF1TP4X9MPxYYNO44StYwWkqL/2R6Y7v0 BxxS4qDwxfRbxDfpu+New6/2y+CfkbVL6EmnFWAsQfzx5NDJDwcyHY77lCV0p5BhC/s4 uEae8+KwDMl4usS+CD1AGC8fmV/uwG4wNVvIZXVFqAj1R05r5Wksh2ndg3j0yTbmWOgI weew== X-Gm-Message-State: AOAM5331kLd96fBtZ41pDQDVsnopNrH56tK8qppOyM8l9Wd5tlgoasKl 3DVE3JjZIGiK07e+uzctNyrxwf40lZs= X-Google-Smtp-Source: ABdhPJxKi4EoNSHaVWOPNDZrFFW4qzKtP8AqvbEG7anrAXkmq4qcN0ewuYzE8QwThe3UHPz6kyYcLQ== X-Received: by 2002:a05:6000:1688:b0:203:8efe:e0b0 with SMTP id y8-20020a056000168800b002038efee0b0mr8156906wrd.289.1647619233408; Fri, 18 Mar 2022 09:00:33 -0700 (PDT) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id a25-20020a5d4579000000b00203ee633c2asm3422472wrc.1.2022.03.18.09.00.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Mar 2022 09:00:32 -0700 (PDT) Message-ID: <1cd1981e-658e-dd2f-1ab7-e696dd7ef2ff@palves.net> Date: Fri, 18 Mar 2022 16:00:31 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH] Add Rust parser check for end of expression Content-Language: en-US To: Tom Tromey , gdb-patches@sourceware.org References: <20220318044450.221851-1-tom@tromey.com> From: Pedro Alves In-Reply-To: <20220318044450.221851-1-tom@tromey.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Mar 2022 16:00:38 -0000 On 2022-03-18 04:44, Tom Tromey wrote: > I noticed that "print 5," passed in Rust -- the parser wasn't checking > that the entire input was used. This patch fixes the problem. This > in turn pointed out another bug in the parser, namely that it didn't > lex the next token after handling a string token. This is also fixed > here. OOC, is the lex-next-token bug something that is also covered by the added test? It doesn't seem to use strings. Pedro Alves > --- > gdb/rust-parse.c | 6 +++++- > gdb/testsuite/gdb.rust/expr.exp | 2 ++ > 2 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c > index 4006df7086b..7d7d882872c 100644 > --- a/gdb/rust-parse.c > +++ b/gdb/rust-parse.c > @@ -271,7 +271,10 @@ struct rust_parser > operation_up parse_entry_point () > { > lex (); > - return parse_expr (); > + operation_up result = parse_expr (); > + if (current_token != 0) > + error (_("Syntax error near '%s'"), pstate->prev_lexptr); > + return result; > } > > operation_up parse_tuple (); > @@ -2020,6 +2023,7 @@ rust_parser::parse_atom (bool required) > > case STRING: > result = parse_string (); > + lex (); > break; > > case BYTESTRING: > diff --git a/gdb/testsuite/gdb.rust/expr.exp b/gdb/testsuite/gdb.rust/expr.exp > index 0c445897338..bb0222bed4b 100644 > --- a/gdb/testsuite/gdb.rust/expr.exp > +++ b/gdb/testsuite/gdb.rust/expr.exp > @@ -145,3 +145,5 @@ gdb_test "print 0x0 as fn(i64) -> ()" " = \\\(\\*mut fn \\\(i64\\\) -> \\\(\\\)\ > gdb_test "print r#" "No symbol 'r' in current context" > > gdb_test "printf \"%d %d\\n\", 23+1, 23-1" "24 22" > + > +gdb_test "print 5," "Syntax error near ','"