From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Pps2GN9D4mr71z4AWB0awg (envelope-from ) for ; Wed, 28 Oct 2026 14:50:07 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=SNqqmV0S; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 49C951E007; Wed, 28 Oct 2026 14:50:07 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id EDDBF1E007 for ; Wed, 28 Oct 2026 14:50:05 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 97FD64BA23F5 for ; Wed, 28 Oct 2026 18:50:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 97FD64BA23F5 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=SNqqmV0S Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by sourceware.org (Postfix) with ESMTPS id 468654BA2E1A for ; Wed, 28 Oct 2026 18:49:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 468654BA2E1A Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 468654BA2E1A Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::231 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1793213377; cv=none; b=B9SSMi3qQw5LUODu/Gi5CQ3JdqNIHCp6qpqWuK3SoHLlVTVtGfbtttmrumWUpEV3TEUf4iesC8zJhV2muhI+SkeyRC8AmdxwTlliljUv853XReX4E2DYhqi9DnBJfyrOJxYZbUwJ0u8kLFMNNozGyzin2li68cyQxrogaEzzvkg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1793213377; c=relaxed/simple; bh=6wSMowcDAK653jgpAQqBhpvOwaCJ6BLlYHOuYbjgbSQ=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=mdfNhlID5+VZiaG+LxQeMXuPADDjSVvHuNK+ziHMJ0jOtWNp231JIFFZpYJVic2MJKH+R1RejiP/s9G2ApZpRUGEXARN3upZLUpYx0KWguqJDJ243lrPJSd8nXyG7vtG1aOV/NKkY7Is+LkWTBDUGstpgeX2aGi+DHdQhNlHtD8= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=SNqqmV0S DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 468654BA2E1A Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-4f14642adb4so775255b6e.1 for ; Wed, 28 Oct 2026 11:49:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1793213376; x=1793818176; darn=sourceware.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=fxOtMvkxTbn0qhakK6YbOhRk+wiEldxXA5gkn4vQr4A=; b=SNqqmV0SuOV1j4MBCUVe5dMcL64Iina3+AVoxBJuR3pQQ2S1JN4d6SBk0slOzkx6Wa kIr9j8WLXfSHH1JTYHY+w9t+tp+ACfahbCjQmcI3WKkvDLmj4QTxtfrNr/zcRVM91KpM ojd5gB4SKUgM4fq7XGQlvDuqV4vfTVSIpFI7NXilWQk2go0LWONgPaFdRN2x4UbxTpGy 7DXWlxoVdFpykK5G3y+L5zehtzC77zfOaVoDgVcy9Zmsh+x4nqrPC+oGy82575KPu7nI z+CIwI1MK2/6oEa5SRgKfc6rQs1UK8xiWRjR4nkU2YQ0hvQ57Qz6JcIsFpQpZps5jCn2 4OCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793213376; x=1793818176; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=fxOtMvkxTbn0qhakK6YbOhRk+wiEldxXA5gkn4vQr4A=; b=AdRo2zFzgdsFjyqP69xgfAbs9g/5d57HfStDp5vTQm8R1Cqy6AacIJ9dopMw48a7Hm NZbNtBrva7i1lABvU0DVnKmiR79QCl12k5TwLAO4m/ozwdrUPsS/BWINUGoiGLcOOQUE G7jqMUYvWsawOmn0RGj3jnJ+IK0Cw6rs7c2Xt0EYMzjA/iTV8IdLE/xg2Wua1fOCYOwt oB3MWPk3ruo+73zX6XhNpMvYqVd6dawxa7S8scJ6mXFDoweAqYfjrECU7xujfUL6fxsH UuGYerM29r4Pqgm/wSj46YRs3dIP0LJ+KhYbxYsXj6xQ2V5GtmR32nxD9nn48nb0rjxB zSGw== X-Gm-Message-State: AFq9FYJBNJoUZk58p2SVbFOf522jzLZoIFRsjNZU3wMJfClxz2bn9SWw VQaat4vp/Jf2FTai27/Id6wUVDCq/urdIuD6ZJD95YpFzdZqRDILmEQV/ReZbXBRHYF355kKPH0 +y8BxEg== X-Gm-Gg: AYBFou1I93sNqstr0m+gMs2U2E4AjN1bi2u+nDol0kKBhIsPJ8jKWtIDIX3J3rg+xNx mQBMUU8TQuYUQbs602o7OLWP4+PFHwC7+sfTdC1B+dzGbROC0d1oBVdjeX6T3XZjF7JhGE22tjH Am+3q9xKm8qYzATISvtkLEZwyty0+J+fDKTqBSkgxgcLfRdwFLn4Ufuat8OrMKx4RORsZPU1B20 glr5n3bt+R2aOmVmlqLyP38p7r33m3+a43MN2MTZpzlW8Ssddm1OZAw528uQ+DLsC0dggalZyVP MPnb0FplKjmJ0yCdIj7bc94F23f9YDaAHv1/QO4YcaK4Y9Ceeo7n8+3FTsOhozN50UeK6hosny1 +vL73fdkW8KR/Fd0onIL5czHiQIbvOq2Rl6BhFdPwvnoVe2wKUdJngt3Gm8eQPsXyV5OsD9hRaB kJGXjE08w5+lCNsukPRTEkHDXNBSkYUDDF1hvqWHqr4/PxXpcuxZv0THyCJoKZ+FFG76ZDN7OaH iA2FROb6OUDVz/X71QsWr2QycJKofFMzLtFmSMqMtGtu0LzXRe8VczPtZecli+Ju1rJ/xaHIK2D AKT6EKA77EYvHcdBS0szgMVpMNp+ci6Ws0QTk279WmPQ6b2dD/cLK+7utMrmiUc= X-Received: by 2002:a05:6808:124b:b0:4a3:fb6c:9adf with SMTP id 5614622812f47-563a205da91mr1900069b6e.12.1793213376519; Wed, 28 Oct 2026 11:49:36 -0700 (PDT) Received: from [192.168.0.26] (97-122-110-129.hlrn.qwest.net. [97.122.110.129]) by smtp.gmail.com with ESMTPSA id 5614622812f47-563c3638604sm2002697b6e.1.2026.10.28.11.49.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2026 11:49:36 -0700 (PDT) From: Tom Tromey Date: Wed, 28 Oct 2026 12:49:34 -0600 Subject: [PATCH 2/2] Remove rust_parser::reset MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261028-rust-no-reset-v1-2-a57eab44c9a5@adacore.com> References: <20261028-rust-no-reset-v1-0-a57eab44c9a5@adacore.com> In-Reply-To: <20261028-rust-no-reset-v1-0-a57eab44c9a5@adacore.com> To: gdb-patches@sourceware.org Cc: Tom Tromey X-Mailer: b4 0.15.2 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org rust_parser::reset is a bit of a hack: it exists only for self-testing, and it modifies the underlying parser_state object -- but incompletely (for instance, it doesn't update start_of_input). It seems to me that it's fine for self-testing to simply create a new parser object for each test. This allows for the removal of the 'reset' method. --- gdb/rust-parse.c | 283 ++++++++++++++++++++++++++----------------------------- 1 file changed, 136 insertions(+), 147 deletions(-) diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c index 9aaf85dc81c..fc441a1b042 100644 --- a/gdb/rust-parse.c +++ b/gdb/rust-parse.c @@ -314,21 +314,6 @@ struct rust_parser const domain_search_flags domain); struct type *rust_lookup_type (const char *name); - /* Clear some state. This is only used for testing. */ -#if GDB_SELF_TEST - void reset (const char *input) - { - pstate->prev_lexptr = nullptr; - pstate->lexptr = input; - paren_depth = 0; - current_token = 0; - current_int_val = {}; - current_float_val = {}; - current_string_val = {}; - current_opcode = OP_NULL; - } -#endif /* GDB_SELF_TEST */ - /* Storage for use while parsing. */ auto_obstack obstack; @@ -2172,13 +2157,9 @@ rust_language::parser (struct parser_state *state) const /* A test helper that lexes a string, expecting a single token. */ static void -rust_lex_test_one (rust_parser *parser, const char *input, int expected) +rust_lex_test_one (rust_parser *parser, int expected) { - int token; - - parser->reset (input); - - token = parser->lex_one_token (false); + int token = parser->lex_one_token (false); SELF_CHECK (token == expected); if (token) @@ -2191,23 +2172,27 @@ rust_lex_test_one (rust_parser *parser, const char *input, int expected) /* Test that INPUT lexes as the integer VALUE. */ static void -rust_lex_int_test (rust_parser *parser, const char *input, - ULONGEST value, int kind) +rust_lex_int_test (const char *input, ULONGEST value, int kind) { - rust_lex_test_one (parser, input, kind); - SELF_CHECK (parser->current_int_val.val == value); + parser_state ps (language_def (language_rust), current_inferior ()->arch (), + nullptr, 0, 0, input, false, nullptr); + rust_parser parser (&ps); + rust_lex_test_one (&parser, kind); + SELF_CHECK (parser.current_int_val.val == value); } /* Test that INPUT throws an exception with text ERR. */ static void -rust_lex_exception_test (rust_parser *parser, const char *input, - const char *err) +rust_lex_exception_test (const char *input, const char *err) { + parser_state ps (language_def (language_rust), current_inferior ()->arch (), + nullptr, 0, 0, input, false, nullptr); + rust_parser parser (&ps); try { /* The "kind" doesn't matter. */ - rust_lex_test_one (parser, input, DECIMAL_INTEGER); + rust_lex_test_one (&parser, DECIMAL_INTEGER); SELF_CHECK (0); } catch (const gdb_exception_error &except) @@ -2220,24 +2205,28 @@ rust_lex_exception_test (rust_parser *parser, const char *input, VALUE. KIND holds the expected token kind. */ static void -rust_lex_stringish_test (rust_parser *parser, const char *input, - const char *value, int kind) +rust_lex_stringish_test (const char *input, const char *value, int kind) { - rust_lex_test_one (parser, input, kind); - SELF_CHECK (parser->current_string_val == value); + parser_state ps (language_def (language_rust), current_inferior ()->arch (), + nullptr, 0, 0, input, false, nullptr); + rust_parser parser (&ps); + rust_lex_test_one (&parser, kind); + SELF_CHECK (parser.current_string_val == value); } /* Helper to test that a string parses as a given token sequence. */ static void -rust_lex_test_sequence (rust_parser *parser, const char *input, int len, - const int expected[]) +rust_lex_test_sequence (const char *input, int len, const int expected[], + bool completion = false) { - parser->reset (input); + parser_state ps (language_def (language_rust), current_inferior ()->arch (), + nullptr, 0, 0, input, completion, nullptr); + rust_parser parser (&ps); for (int i = 0; i < len; ++i) { - int token = parser->lex_one_token (false); + int token = parser.lex_one_token (false); SELF_CHECK (token == expected[i]); } } @@ -2245,167 +2234,167 @@ rust_lex_test_sequence (rust_parser *parser, const char *input, int len, /* Tests for an integer-parsing corner case. */ static void -rust_lex_test_trailing_dot (rust_parser *parser) +rust_lex_test_trailing_dot () { const int expected1[] = { INTEGER, '.', IDENT, '(', ')', 0 }; const int expected2[] = { INTEGER, '.', IDENT, '(', ')', 0 }; const int expected3[] = { FLOAT, EQEQ, '(', ')', 0 }; const int expected4[] = { INTEGER, DOTDOT, INTEGER, 0 }; - rust_lex_test_sequence (parser, "23.g()", ARRAY_SIZE (expected1), expected1); - rust_lex_test_sequence (parser, "23_0.g()", ARRAY_SIZE (expected2), - expected2); - rust_lex_test_sequence (parser, "23.==()", ARRAY_SIZE (expected3), - expected3); - rust_lex_test_sequence (parser, "23..25", ARRAY_SIZE (expected4), expected4); + rust_lex_test_sequence ("23.g()", ARRAY_SIZE (expected1), expected1); + rust_lex_test_sequence ("23_0.g()", ARRAY_SIZE (expected2), expected2); + rust_lex_test_sequence ("23.==()", ARRAY_SIZE (expected3), expected3); + rust_lex_test_sequence ("23..25", ARRAY_SIZE (expected4), expected4); } /* Tests of completion. */ static void -rust_lex_test_completion (rust_parser *parser) +rust_lex_test_completion () { const int expected[] = { IDENT, '.', COMPLETE, 0 }; - parser->pstate->parse_completion = true; - - rust_lex_test_sequence (parser, "something.wha", ARRAY_SIZE (expected), - expected); - rust_lex_test_sequence (parser, "something.", ARRAY_SIZE (expected), - expected); - - parser->pstate->parse_completion = false; + rust_lex_test_sequence ("something.wha", ARRAY_SIZE (expected), + expected, true); + rust_lex_test_sequence ("something.", ARRAY_SIZE (expected), + expected, true); } /* Test pushback. */ static void -rust_lex_test_push_back (rust_parser *parser) +rust_lex_test_push_back () { - int token; - - parser->reset (">>="); + parser_state ps (language_def (language_rust), current_inferior ()->arch (), + nullptr, 0, 0, ">>=", false, nullptr); + rust_parser parser (&ps); - token = parser->lex_one_token (false); + int token = parser.lex_one_token (false); SELF_CHECK (token == COMPOUND_ASSIGN); - SELF_CHECK (parser->current_opcode == BINOP_RSH); + SELF_CHECK (parser.current_opcode == BINOP_RSH); - parser->push_back ('='); + parser.push_back ('='); - token = parser->lex_one_token (false); + token = parser.lex_one_token (false); SELF_CHECK (token == '='); - token = parser->lex_one_token (false); + token = parser.lex_one_token (false); SELF_CHECK (token == 0); } -/* Unit test the lexer. */ +/* Test a simple parse. */ static void -rust_lex_tests () +rust_simple (const char *input, int expected) { - /* Set up dummy "parser", so that rust_type works. */ parser_state ps (language_def (language_rust), current_inferior ()->arch (), - nullptr, 0, 0, nullptr, 0, nullptr); + nullptr, 0, 0, input, false, nullptr); rust_parser parser (&ps); + rust_lex_test_one (&parser, expected); +} + +/* Unit test the lexer. */ - rust_lex_test_one (&parser, "", 0); - rust_lex_test_one (&parser, " \t \n \r ", 0); - rust_lex_test_one (&parser, "thread 23", 0); - rust_lex_test_one (&parser, "task 23", 0); - rust_lex_test_one (&parser, "th 104", 0); - rust_lex_test_one (&parser, "ta 97", 0); - - rust_lex_int_test (&parser, "'z'", 'z', INTEGER); - rust_lex_int_test (&parser, "'\\xff'", 0xff, INTEGER); - rust_lex_int_test (&parser, "'\\u{1016f}'", 0x1016f, INTEGER); - rust_lex_int_test (&parser, "b'z'", 'z', INTEGER); - rust_lex_int_test (&parser, "b'\\xfe'", 0xfe, INTEGER); - rust_lex_int_test (&parser, "b'\\xFE'", 0xfe, INTEGER); - rust_lex_int_test (&parser, "b'\\xfE'", 0xfe, INTEGER); +static void +rust_lex_tests () +{ + rust_simple ("", 0); + rust_simple (" \t \n \r ", 0); + rust_simple ("thread 23", 0); + rust_simple ("task 23", 0); + rust_simple ("th 104", 0); + rust_simple ("ta 97", 0); + + rust_lex_int_test ("'z'", 'z', INTEGER); + rust_lex_int_test ("'\\xff'", 0xff, INTEGER); + rust_lex_int_test ("'\\u{1016f}'", 0x1016f, INTEGER); + rust_lex_int_test ("b'z'", 'z', INTEGER); + rust_lex_int_test ("b'\\xfe'", 0xfe, INTEGER); + rust_lex_int_test ("b'\\xFE'", 0xfe, INTEGER); + rust_lex_int_test ("b'\\xfE'", 0xfe, INTEGER); /* Test all escapes in both modes. */ - rust_lex_int_test (&parser, "'\\n'", '\n', INTEGER); - rust_lex_int_test (&parser, "'\\r'", '\r', INTEGER); - rust_lex_int_test (&parser, "'\\t'", '\t', INTEGER); - rust_lex_int_test (&parser, "'\\\\'", '\\', INTEGER); - rust_lex_int_test (&parser, "'\\0'", '\0', INTEGER); - rust_lex_int_test (&parser, "'\\''", '\'', INTEGER); - rust_lex_int_test (&parser, "'\\\"'", '"', INTEGER); - - rust_lex_int_test (&parser, "b'\\n'", '\n', INTEGER); - rust_lex_int_test (&parser, "b'\\r'", '\r', INTEGER); - rust_lex_int_test (&parser, "b'\\t'", '\t', INTEGER); - rust_lex_int_test (&parser, "b'\\\\'", '\\', INTEGER); - rust_lex_int_test (&parser, "b'\\0'", '\0', INTEGER); - rust_lex_int_test (&parser, "b'\\''", '\'', INTEGER); - rust_lex_int_test (&parser, "b'\\\"'", '"', INTEGER); - - rust_lex_exception_test (&parser, "'z", "Unterminated character literal"); - rust_lex_exception_test (&parser, "b'\\x0'", "Not enough hex digits seen"); - rust_lex_exception_test (&parser, "b'\\u{0}'", + rust_lex_int_test ("'\\n'", '\n', INTEGER); + rust_lex_int_test ("'\\r'", '\r', INTEGER); + rust_lex_int_test ("'\\t'", '\t', INTEGER); + rust_lex_int_test ("'\\\\'", '\\', INTEGER); + rust_lex_int_test ("'\\0'", '\0', INTEGER); + rust_lex_int_test ("'\\''", '\'', INTEGER); + rust_lex_int_test ("'\\\"'", '"', INTEGER); + + rust_lex_int_test ("b'\\n'", '\n', INTEGER); + rust_lex_int_test ("b'\\r'", '\r', INTEGER); + rust_lex_int_test ("b'\\t'", '\t', INTEGER); + rust_lex_int_test ("b'\\\\'", '\\', INTEGER); + rust_lex_int_test ("b'\\0'", '\0', INTEGER); + rust_lex_int_test ("b'\\''", '\'', INTEGER); + rust_lex_int_test ("b'\\\"'", '"', INTEGER); + + rust_lex_exception_test ("'z", "Unterminated character literal"); + rust_lex_exception_test ("b'\\x0'", "Not enough hex digits seen"); + rust_lex_exception_test ("b'\\u{0}'", "Unicode escape in byte literal"); - rust_lex_exception_test (&parser, "'\\x0'", "Not enough hex digits seen"); - rust_lex_exception_test (&parser, "'\\u0'", "Missing '{' in Unicode escape"); - rust_lex_exception_test (&parser, "'\\u{0", "Missing '}' in Unicode escape"); - rust_lex_exception_test (&parser, "'\\u{0000007}", "Overlong hex escape"); - rust_lex_exception_test (&parser, "'\\u{}", "Not enough hex digits seen"); - rust_lex_exception_test (&parser, "'\\Q'", "Invalid escape \\Q in literal"); - rust_lex_exception_test (&parser, "b'\\Q'", "Invalid escape \\Q in literal"); - - rust_lex_int_test (&parser, "23", 23, INTEGER); - rust_lex_int_test (&parser, "2_344__29", 234429, INTEGER); - rust_lex_int_test (&parser, "0x1f", 0x1f, INTEGER); - rust_lex_int_test (&parser, "23usize", 23, INTEGER); - rust_lex_int_test (&parser, "23i32", 23, INTEGER); - rust_lex_int_test (&parser, "0x1_f", 0x1f, INTEGER); - rust_lex_int_test (&parser, "0b1_101011__", 0x6b, INTEGER); - rust_lex_int_test (&parser, "0o001177i64", 639, INTEGER); - rust_lex_int_test (&parser, "0x123456789u64", 0x123456789ull, INTEGER); - - rust_lex_test_trailing_dot (&parser); - - rust_lex_test_one (&parser, "23.", FLOAT); - rust_lex_test_one (&parser, "23.99f32", FLOAT); - rust_lex_test_one (&parser, "23e7", FLOAT); - rust_lex_test_one (&parser, "23E-7", FLOAT); - rust_lex_test_one (&parser, "23e+7", FLOAT); - rust_lex_test_one (&parser, "23.99e+7f64", FLOAT); - rust_lex_test_one (&parser, "23.82f32", FLOAT); - - rust_lex_stringish_test (&parser, "hibob", "hibob", IDENT); - rust_lex_stringish_test (&parser, "hibob__93", "hibob__93", IDENT); - rust_lex_stringish_test (&parser, "thread", "thread", IDENT); - rust_lex_stringish_test (&parser, "r#true", "true", IDENT); + rust_lex_exception_test ("'\\x0'", "Not enough hex digits seen"); + rust_lex_exception_test ("'\\u0'", "Missing '{' in Unicode escape"); + rust_lex_exception_test ("'\\u{0", "Missing '}' in Unicode escape"); + rust_lex_exception_test ("'\\u{0000007}", "Overlong hex escape"); + rust_lex_exception_test ("'\\u{}", "Not enough hex digits seen"); + rust_lex_exception_test ("'\\Q'", "Invalid escape \\Q in literal"); + rust_lex_exception_test ("b'\\Q'", "Invalid escape \\Q in literal"); + + rust_lex_int_test ("23", 23, INTEGER); + rust_lex_int_test ("2_344__29", 234429, INTEGER); + rust_lex_int_test ("0x1f", 0x1f, INTEGER); + rust_lex_int_test ("23usize", 23, INTEGER); + rust_lex_int_test ("23i32", 23, INTEGER); + rust_lex_int_test ("0x1_f", 0x1f, INTEGER); + rust_lex_int_test ("0b1_101011__", 0x6b, INTEGER); + rust_lex_int_test ("0o001177i64", 639, INTEGER); + rust_lex_int_test ("0x123456789u64", 0x123456789ull, INTEGER); + + rust_lex_test_trailing_dot (); + + rust_simple ("23.", FLOAT); + rust_simple ("23.99f32", FLOAT); + rust_simple ("23e7", FLOAT); + rust_simple ("23E-7", FLOAT); + rust_simple ("23e+7", FLOAT); + rust_simple ("23.99e+7f64", FLOAT); + rust_simple ("23.82f32", FLOAT); + + rust_lex_stringish_test ("hibob", "hibob", IDENT); + rust_lex_stringish_test ("hibob__93", "hibob__93", IDENT); + rust_lex_stringish_test ("thread", "thread", IDENT); + rust_lex_stringish_test ("r#true", "true", IDENT); const int expected1[] = { IDENT, INTEGER, 0 }; - rust_lex_test_sequence (&parser, "r#thread 23", ARRAY_SIZE (expected1), + rust_lex_test_sequence ("r#thread 23", ARRAY_SIZE (expected1), expected1); const int expected2[] = { IDENT, '#', 0 }; - rust_lex_test_sequence (&parser, "r#", ARRAY_SIZE (expected2), expected2); - - rust_lex_stringish_test (&parser, "\"string\"", "string", STRING); - rust_lex_stringish_test (&parser, "\"str\\ting\"", "str\ting", STRING); - rust_lex_stringish_test (&parser, "\"str\\\"ing\"", "str\"ing", STRING); - rust_lex_stringish_test (&parser, "r\"str\\ing\"", "str\\ing", STRING); - rust_lex_stringish_test (&parser, "r#\"str\\ting\"#", "str\\ting", STRING); - rust_lex_stringish_test (&parser, "r###\"str\\\"ing\"###", "str\\\"ing", + rust_lex_test_sequence ("r#", ARRAY_SIZE (expected2), expected2); + + rust_lex_stringish_test ("\"string\"", "string", STRING); + rust_lex_stringish_test ("\"str\\ting\"", "str\ting", STRING); + rust_lex_stringish_test ("\"str\\\"ing\"", "str\"ing", STRING); + rust_lex_stringish_test ("r\"str\\ing\"", "str\\ing", STRING); + rust_lex_stringish_test ("r#\"str\\ting\"#", "str\\ting", STRING); + rust_lex_stringish_test ("r###\"str\\\"ing\"###", "str\\\"ing", STRING); - rust_lex_stringish_test (&parser, "b\"string\"", "string", BYTESTRING); - rust_lex_stringish_test (&parser, "b\"\x73tring\"", "string", BYTESTRING); - rust_lex_stringish_test (&parser, "b\"str\\\"ing\"", "str\"ing", BYTESTRING); - rust_lex_stringish_test (&parser, "br####\"\\x73tring\"####", "\\x73tring", + rust_lex_stringish_test ("b\"string\"", "string", BYTESTRING); + rust_lex_stringish_test ("b\"\x73tring\"", "string", BYTESTRING); + rust_lex_stringish_test ("b\"str\\\"ing\"", "str\"ing", BYTESTRING); + rust_lex_stringish_test ("br####\"\\x73tring\"####", "\\x73tring", BYTESTRING); for (const auto &candidate : identifier_tokens) - rust_lex_test_one (&parser, candidate.name, candidate.value); + rust_simple (candidate.name, candidate.value); for (const auto &candidate : operator_tokens) - rust_lex_test_one (&parser, candidate.name, candidate.value); + rust_simple (candidate.name, candidate.value); - rust_lex_test_completion (&parser); - rust_lex_test_push_back (&parser); + rust_lex_test_completion (); + rust_lex_test_push_back (); } #endif /* GDB_SELF_TEST */ -- 2.56.0