From patchwork Tue Jan 30 12:06:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 194078 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1182376dyb; Tue, 30 Jan 2024 04:27:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHG5ayqu2qf0bSl90eW/OLEvP/yU9YohBYKx2hR3dr9CIpQTvN4OyFutLupYpPLf1gwp18b X-Received: by 2002:ac8:7d8f:0:b0:42b:d221:c598 with SMTP id c15-20020ac87d8f000000b0042bd221c598mr589504qtd.112.1706617620552; Tue, 30 Jan 2024 04:27:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706617620; cv=pass; d=google.com; s=arc-20160816; b=GvaxxwZOW5YcZT9bVUlP3ziF3iSUnQuiZRZs7L2Nql4yV78etlmURu5+ZsQDcQQM0f Q4q8H/kBnAJmaonz89FlKh8W59XHh+oT9JtV4tAHwh94J3wWvIQ8FS37aRtafSakQrKM D8265jA1+ETep0XKH2vayXkbsnZkaPSedagbNrMGN22NQfLEw3K9ZdmFfnNIDuYZCIog oQusvkWtQCnX1dVd9YiQdlk4XAzC+XMkjm4F6xTHkEOy5ThBtBfJfWtLWtYYoQaIstoq kciknfMg8IrWwiWz8tLng/ROYt/7n1Lj/4ccgLMmTE0k6lUf9FRauSAteCXmgx//Ut4x SE4Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=qWh0Q4x17LM2TyaXtoDWrBk2CzIUUbnfKfj9jSBUbCw=; fh=s1GzlUPo1djGkCl3rkRJI30hDOSCVwGp0RAbVwQ8dxQ=; b=vC1o+ndCzkjAinLefprw3XDPAxrYKV/4nYHPdsiy/6liGdKvoMkeg0Kc/Ehi5Z2vOL xF07Fp1fhSIa3J1lhoDi2GT0p2EnLaPj/icQEuZ5bJYw7T+r0KDsMyjkPuC0ZJ7fHdXm 59KnZGdGL43h4zzibk/vw6Lfr0Z6+RcXVre8G35qWpiYqpSd1PRnt7DOFoz43JPuluz5 OcgydHezrWIJkCjm/u+usLWQplESrCq3oj1zOv1GW1MLResx6IMojpP9h0YxyB+x7VLD HWG4cMm6nxBi42QPqu3m1tMWzlE/CY1xh3EDizdUyta8bIgs8CVKWU+Zip8vDWfYMHds 22uw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=JSPYyBwc; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id c1-20020ac87dc1000000b0042ab1b14360si2187679qte.131.2024.01.30.04.27.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:27:00 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=JSPYyBwc; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3B9DC386100F for ; Tue, 30 Jan 2024 12:27:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 0F772385801D for ; Tue, 30 Jan 2024 12:11:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0F772385801D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0F772385801D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::431 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616681; cv=none; b=PbMCXK96GcGzSa68ZoSDdX2y8oqduDp2JXXGKxaJLgxruUV20PlI2Mj2Yc8iQcWwchxQERUqySwB/WGkrP8VJP1yEF7hUBhHwcAJfHhKNnZM5k+b7A7oiVKfFBmyQ+cleXcnEG5z6fDzQxS96Sr76ro5gfII98ZSBFBCzuDo4Qw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616681; c=relaxed/simple; bh=6SVQGInhXthSVbm99z8Prg07atKX80OKKX5Kh6q9XTE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=MvDYOnz2hRTjIWoY5yV9YuXSvnzTn7/Vlwst6O1/qwF2J58EBG+So4E4Ds4QfnF2p3Tph+zK1OVAYAaM6PhdZpN/P7Wz9mkiW+e5dpGNzvmXbTkm9hEOJ/DjZtcA+Ze7lptjdt+FzxSxapDl5jA7lUc7EBfYVCSlDxGdrcCJ5r0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-33ae6dfa923so1618473f8f.1 for ; Tue, 30 Jan 2024 04:11:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1706616668; x=1707221468; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=qWh0Q4x17LM2TyaXtoDWrBk2CzIUUbnfKfj9jSBUbCw=; b=JSPYyBwcdKdlzLUzZFsM3gR4aTg70CYIEg8SyLLDJtvhqTu3vT9RxFheADsfzwKATA f8Y1iJcOq++vogdWcDbpbtOa/UfQaj7jZJQ7LT+dT43mVZOg1q2ojkqJHsjO+qRo5uR6 x8YkESRt6mOpAVj1J/Z9Yd4cyzxQui2z1uDr6oArj6k8CVmu3ZIqhIKRfTo/Kt3Y3zZm +E3wJ9DXgmoQRp6bIYx0Xa4hVuoW5u3r9/IHdNlLGIRgN6nIj/aiiqJGJS6IxI+sqx0F N+MHviBqulmFrm/uvsGAiwXQbjI4h0jBE361V8r5os3ivqI8rQEJBaDV8Zcv4QvIlujl mcVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706616668; x=1707221468; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=qWh0Q4x17LM2TyaXtoDWrBk2CzIUUbnfKfj9jSBUbCw=; b=ID2gUr/XFJge8VHGHPTTjLdSRPO9ZWptIPHSfKHlfJd5ALRzRH6p0b9ugRztjqqYxq PCEpsBfNQr1KIt0WIwYxmDIZ+KMy8pSxEGBtOqXwB6sl7TirY6sBDxMiUMfBrD1hwheS RA+m7JKITEodYeGcFhCwaLYpdQC7kybLVdQFxK58T4Sv6bMmTdugUfSsPyYpxznSA7RV KH/8n3grJZ6bzzdaYMng7wrEzsUDt6KvfuTcdzy5TGfOHy8+40CpZmRxaHNkSdhJ2bbA znA6F1k7czXu5yXfPGEjRGSr6h5cVkwMiPZRyEQqmjR/tmR2oqfkzcz1Bg78vjzOlIRb oXdg== X-Gm-Message-State: AOJu0Yxs7YfM0pfBzYqU2kHapn6Jh1lYe1e6zNcz/8RpUQuZyRdXHHxF mqSOMtiS/XjqU47Qnx8DeMUkn7uD8aVV3dwgvePR/NB1UXxC55Yu7GnJ4NnfdQp7VhPLVbGPZPM lTQ== X-Received: by 2002:a5d:69cc:0:b0:33a:e56f:1ddb with SMTP id s12-20020a5d69cc000000b0033ae56f1ddbmr6147355wrw.46.1706616667927; Tue, 30 Jan 2024 04:11:07 -0800 (PST) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id f9-20020a056000036900b00339307d9d31sm10569894wrf.112.2024.01.30.04.11.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:11:07 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Pierre-Emmanuel Patry Subject: [COMMITTED 025/101] gccrs: Add edition separation for keywords Date: Tue, 30 Jan 2024 13:06:41 +0100 Message-ID: <20240130121026.807464-28-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20240130121026.807464-2-arthur.cohen@embecosm.com> References: <20240130121026.807464-2-arthur.cohen@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: arthur.cohen@embecosm.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789518278228894828 X-GMAIL-MSGID: 1789518278228894828 From: Pierre-Emmanuel Patry It might be required in the future to get only the keywords from a specific edition. To do so we need a mean to differentiate keywords based on their edition. This commit changes the existing keyword macro to allow such behavior. gcc/rust/ChangeLog: * lex/rust-token.h (enum PrimitiveCoreType): Change enum macro calls. (RS_TOKEN_KEYWORD): Remove generic token keyword macro. (RS_TOKEN_KEYWORD_2015): Introduce keywords for edition 2015. (RS_TOKEN_KEYWORD_2018): Likewise with edition 2018. * lex/rust-token.cc (RS_TOKEN_KEYWORD): Remove old macro definition. (RS_TOKEN_KEYWORD_2015): Replace with 2015 definition... (RS_TOKEN_KEYWORD_2018): ... and 2018 definition. * util/rust-keyword-values.cc (RS_TOKEN_KEYWORD): Likewise. (RS_TOKEN_KEYWORD_2015): Likewise. (RS_TOKEN_KEYWORD_2018): Likewise. * util/rust-keyword-values.h (RS_TOKEN_KEYWORD): Likewise. (RS_TOKEN_KEYWORD_2015): Likewise. (RS_TOKEN_KEYWORD_2018): Likewise. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/lex/rust-token.cc | 24 ++++-- gcc/rust/lex/rust-token.h | 114 ++++++++++++++------------- gcc/rust/util/rust-keyword-values.cc | 6 +- gcc/rust/util/rust-keyword-values.h | 6 +- 4 files changed, 82 insertions(+), 68 deletions(-) diff --git a/gcc/rust/lex/rust-token.cc b/gcc/rust/lex/rust-token.cc index ea355051bba..7bb327358a2 100644 --- a/gcc/rust/lex/rust-token.cc +++ b/gcc/rust/lex/rust-token.cc @@ -31,9 +31,11 @@ get_token_description (TokenId id) #define RS_TOKEN(name, descr) \ case name: \ return descr; -#define RS_TOKEN_KEYWORD(x, y) RS_TOKEN (x, y) +#define RS_TOKEN_KEYWORD_2015(x, y) RS_TOKEN (x, y) +#define RS_TOKEN_KEYWORD_2018 RS_TOKEN_KEYWORD_2015 RS_TOKEN_LIST -#undef RS_TOKEN_KEYWORD +#undef RS_TOKEN_KEYWORD_2015 +#undef RS_TOKEN_KEYWORD_2018 #undef RS_TOKEN default: rust_unreachable (); @@ -50,9 +52,11 @@ token_id_to_str (TokenId id) #define RS_TOKEN(name, _) \ case name: \ return #name; -#define RS_TOKEN_KEYWORD(x, y) RS_TOKEN (x, y) +#define RS_TOKEN_KEYWORD_2015(x, y) RS_TOKEN (x, y) +#define RS_TOKEN_KEYWORD_2018 RS_TOKEN_KEYWORD_2015 RS_TOKEN_LIST -#undef RS_TOKEN_KEYWORD +#undef RS_TOKEN_KEYWORD_2015 +#undef RS_TOKEN_KEYWORD_2018 #undef RS_TOKEN default: rust_unreachable (); @@ -65,10 +69,12 @@ token_id_is_keyword (TokenId id) { switch (id) { -#define RS_TOKEN_KEYWORD(name, _) case name: +#define RS_TOKEN_KEYWORD_2015(name, _) case name: +#define RS_TOKEN_KEYWORD_2018 RS_TOKEN_KEYWORD_2015 #define RS_TOKEN(a, b) RS_TOKEN_LIST return true; -#undef RS_TOKEN_KEYWORD +#undef RS_TOKEN_KEYWORD_2015 +#undef RS_TOKEN_KEYWORD_2018 #undef RS_TOKEN default: return false; @@ -81,15 +87,17 @@ token_id_keyword_string (TokenId id) { switch (id) { -#define RS_TOKEN_KEYWORD(id, str_ptr) \ +#define RS_TOKEN_KEYWORD_2015(id, str_ptr) \ case id: { \ static const std::string str (str_ptr); \ return str; \ } \ rust_unreachable (); +#define RS_TOKEN_KEYWORD_2018 RS_TOKEN_KEYWORD_2015 #define RS_TOKEN(a, b) RS_TOKEN_LIST -#undef RS_TOKEN_KEYWORD +#undef RS_TOKEN_KEYWORD_2015 +#undef RS_TOKEN_KEYWORD_2018 #undef RS_TOKEN default: rust_unreachable (); diff --git a/gcc/rust/lex/rust-token.h b/gcc/rust/lex/rust-token.h index 50513acb68d..df321000511 100644 --- a/gcc/rust/lex/rust-token.h +++ b/gcc/rust/lex/rust-token.h @@ -59,8 +59,8 @@ enum PrimitiveCoreType }; // RS_TOKEN(name, description) -// RS_TOKEN_KEYWORD(name, identifier) -// +// RS_TOKEN_KEYWORD_{2015,2018}(name, identifier) + // Keep RS_TOKEN_KEYWORD sorted /* note that abstract, async, become, box, do, final, macro, override, priv, @@ -148,68 +148,70 @@ enum PrimitiveCoreType RS_TOKEN (INNER_DOC_COMMENT, "#![doc]") \ RS_TOKEN (OUTER_DOC_COMMENT, "#[doc]") \ /* have "weak" union and 'static keywords? */ \ - RS_TOKEN_KEYWORD (ABSTRACT, "abstract") /* unused */ \ - RS_TOKEN_KEYWORD (AS, "as") \ - RS_TOKEN_KEYWORD (ASYNC, "async") /* unused */ \ - RS_TOKEN_KEYWORD (AUTO, "auto") \ - RS_TOKEN_KEYWORD (BECOME, "become") /* unused */ \ - RS_TOKEN_KEYWORD (BOX, "box") /* unused */ \ - RS_TOKEN_KEYWORD (BREAK, "break") \ - RS_TOKEN_KEYWORD (CONST, "const") \ - RS_TOKEN_KEYWORD (CONTINUE, "continue") \ - RS_TOKEN_KEYWORD (CRATE, "crate") \ + RS_TOKEN_KEYWORD_2015 (ABSTRACT, "abstract") /* unused */ \ + RS_TOKEN_KEYWORD_2015 (AS, "as") \ + RS_TOKEN_KEYWORD_2018 (ASYNC, "async") /* unused */ \ + RS_TOKEN_KEYWORD_2015 (AUTO, "auto") \ + RS_TOKEN_KEYWORD_2015 (BECOME, "become") /* unused */ \ + RS_TOKEN_KEYWORD_2015 (BOX, "box") /* unused */ \ + RS_TOKEN_KEYWORD_2015 (BREAK, "break") \ + RS_TOKEN_KEYWORD_2015 (CONST, "const") \ + RS_TOKEN_KEYWORD_2015 (CONTINUE, "continue") \ + RS_TOKEN_KEYWORD_2015 (CRATE, "crate") \ /* FIXME: Do we need to add $crate (DOLLAR_CRATE) as a reserved kw? */ \ - RS_TOKEN_KEYWORD (DO, "do") /* unused */ \ - RS_TOKEN_KEYWORD (DYN, "dyn") \ - RS_TOKEN_KEYWORD (ELSE, "else") \ - RS_TOKEN_KEYWORD (ENUM_KW, "enum") \ - RS_TOKEN_KEYWORD (EXTERN_KW, "extern") \ - RS_TOKEN_KEYWORD (FALSE_LITERAL, "false") \ - RS_TOKEN_KEYWORD (FINAL_KW, "final") /* unused */ \ - RS_TOKEN_KEYWORD (FN_KW, "fn") \ - RS_TOKEN_KEYWORD (FOR, "for") \ - RS_TOKEN_KEYWORD (IF, "if") \ - RS_TOKEN_KEYWORD (IMPL, "impl") \ - RS_TOKEN_KEYWORD (IN, "in") \ - RS_TOKEN_KEYWORD (LET, "let") \ - RS_TOKEN_KEYWORD (LOOP, "loop") \ - RS_TOKEN_KEYWORD (MACRO, "macro") \ - RS_TOKEN_KEYWORD (MATCH_KW, "match") \ - RS_TOKEN_KEYWORD (MOD, "mod") \ - RS_TOKEN_KEYWORD (MOVE, "move") \ - RS_TOKEN_KEYWORD (MUT, "mut") \ - RS_TOKEN_KEYWORD (OVERRIDE_KW, "override") /* unused */ \ - RS_TOKEN_KEYWORD (PRIV, "priv") /* unused */ \ - RS_TOKEN_KEYWORD (PUB, "pub") \ - RS_TOKEN_KEYWORD (REF, "ref") \ - RS_TOKEN_KEYWORD (RETURN_KW, "return") \ - RS_TOKEN_KEYWORD (SELF_ALIAS, \ - "Self") /* mrustc does not treat this as a reserved word*/ \ - RS_TOKEN_KEYWORD (SELF, "self") \ - RS_TOKEN_KEYWORD (STATIC_KW, "static") \ - RS_TOKEN_KEYWORD (STRUCT_KW, "struct") \ - RS_TOKEN_KEYWORD (SUPER, "super") \ - RS_TOKEN_KEYWORD (TRAIT, "trait") \ - RS_TOKEN_KEYWORD (TRUE_LITERAL, "true") \ - RS_TOKEN_KEYWORD (TRY, "try") /* unused */ \ - RS_TOKEN_KEYWORD (TYPE, "type") \ - RS_TOKEN_KEYWORD (TYPEOF, "typeof") /* unused */ \ - RS_TOKEN_KEYWORD (UNSAFE, "unsafe") \ - RS_TOKEN_KEYWORD (UNSIZED, "unsized") /* unused */ \ - RS_TOKEN_KEYWORD (USE, "use") \ - RS_TOKEN_KEYWORD (VIRTUAL, "virtual") /* unused */ \ - RS_TOKEN_KEYWORD (WHERE, "where") \ - RS_TOKEN_KEYWORD (WHILE, "while") \ - RS_TOKEN_KEYWORD (YIELD, "yield") /* unused */ \ + RS_TOKEN_KEYWORD_2015 (DO, "do") /* unused */ \ + RS_TOKEN_KEYWORD_2018 (DYN, "dyn") \ + RS_TOKEN_KEYWORD_2015 (ELSE, "else") \ + RS_TOKEN_KEYWORD_2015 (ENUM_KW, "enum") \ + RS_TOKEN_KEYWORD_2015 (EXTERN_KW, "extern") \ + RS_TOKEN_KEYWORD_2015 (FALSE_LITERAL, "false") \ + RS_TOKEN_KEYWORD_2015 (FINAL_KW, "final") /* unused */ \ + RS_TOKEN_KEYWORD_2015 (FN_KW, "fn") \ + RS_TOKEN_KEYWORD_2015 (FOR, "for") \ + RS_TOKEN_KEYWORD_2015 (IF, "if") \ + RS_TOKEN_KEYWORD_2015 (IMPL, "impl") \ + RS_TOKEN_KEYWORD_2015 (IN, "in") \ + RS_TOKEN_KEYWORD_2015 (LET, "let") \ + RS_TOKEN_KEYWORD_2015 (LOOP, "loop") \ + RS_TOKEN_KEYWORD_2015 (MACRO, "macro") \ + RS_TOKEN_KEYWORD_2015 (MATCH_KW, "match") \ + RS_TOKEN_KEYWORD_2015 (MOD, "mod") \ + RS_TOKEN_KEYWORD_2015 (MOVE, "move") \ + RS_TOKEN_KEYWORD_2015 (MUT, "mut") \ + RS_TOKEN_KEYWORD_2015 (OVERRIDE_KW, "override") /* unused */ \ + RS_TOKEN_KEYWORD_2015 (PRIV, "priv") /* unused */ \ + RS_TOKEN_KEYWORD_2015 (PUB, "pub") \ + RS_TOKEN_KEYWORD_2015 (REF, "ref") \ + RS_TOKEN_KEYWORD_2015 (RETURN_KW, "return") \ + RS_TOKEN_KEYWORD_2015 ( \ + SELF_ALIAS, "Self") /* mrustc does not treat this as a reserved word*/ \ + RS_TOKEN_KEYWORD_2015 (SELF, "self") \ + RS_TOKEN_KEYWORD_2015 (STATIC_KW, "static") \ + RS_TOKEN_KEYWORD_2015 (STRUCT_KW, "struct") \ + RS_TOKEN_KEYWORD_2015 (SUPER, "super") \ + RS_TOKEN_KEYWORD_2015 (TRAIT, "trait") \ + RS_TOKEN_KEYWORD_2015 (TRUE_LITERAL, "true") \ + RS_TOKEN_KEYWORD_2015 (TRY, "try") /* unused */ \ + RS_TOKEN_KEYWORD_2015 (TYPE, "type") \ + RS_TOKEN_KEYWORD_2015 (TYPEOF, "typeof") /* unused */ \ + RS_TOKEN_KEYWORD_2015 (UNSAFE, "unsafe") \ + RS_TOKEN_KEYWORD_2015 (UNSIZED, "unsized") /* unused */ \ + RS_TOKEN_KEYWORD_2015 (USE, "use") \ + RS_TOKEN_KEYWORD_2015 (VIRTUAL, "virtual") /* unused */ \ + RS_TOKEN_KEYWORD_2015 (WHERE, "where") \ + RS_TOKEN_KEYWORD_2015 (WHILE, "while") \ + RS_TOKEN_KEYWORD_2015 (YIELD, "yield") /* unused */ \ RS_TOKEN (LAST_TOKEN, "") // Contains all token types. Crappy implementation via x-macros. enum TokenId { #define RS_TOKEN(name, _) name, -#define RS_TOKEN_KEYWORD(x, y) RS_TOKEN (x, y) +#define RS_TOKEN_KEYWORD_2015(x, y) RS_TOKEN (x, y) +#define RS_TOKEN_KEYWORD_2018 RS_TOKEN_KEYWORD_2015 RS_TOKEN_LIST -#undef RS_TOKEN_KEYWORD +#undef RS_TOKEN_KEYWORD_2015 +#undef RS_TOKEN_KEYWORD_2018 #undef RS_TOKEN }; diff --git a/gcc/rust/util/rust-keyword-values.cc b/gcc/rust/util/rust-keyword-values.cc index 58a404dc2aa..8aa5ef1371a 100644 --- a/gcc/rust/util/rust-keyword-values.cc +++ b/gcc/rust/util/rust-keyword-values.cc @@ -28,9 +28,11 @@ get_keywords () { std::map m = { #define RS_TOKEN(x, y) -#define RS_TOKEN_KEYWORD(tok, key) {key, tok}, +#define RS_TOKEN_KEYWORD_2015(tok, key) {key, tok}, +#define RS_TOKEN_KEYWORD_2018 RS_TOKEN_KEYWORD_2015 RS_TOKEN_LIST -#undef RS_TOKEN_KEYWORD +#undef RS_TOKEN_KEYWORD_2015 +#undef RS_TOKEN_KEYWORD_2018 #undef RS_TOKEN }; return m; diff --git a/gcc/rust/util/rust-keyword-values.h b/gcc/rust/util/rust-keyword-values.h index 3edae55c76e..769b2100c41 100644 --- a/gcc/rust/util/rust-keyword-values.h +++ b/gcc/rust/util/rust-keyword-values.h @@ -33,9 +33,11 @@ public: // Rust keyword values public: #define RS_TOKEN(x, y) -#define RS_TOKEN_KEYWORD(tok, key) static constexpr auto &tok = key; +#define RS_TOKEN_KEYWORD_2015(tok, key) static constexpr auto &tok = key; +#define RS_TOKEN_KEYWORD_2018 RS_TOKEN_KEYWORD_2015 RS_TOKEN_LIST -#undef RS_TOKEN_KEYWORD +#undef RS_TOKEN_KEYWORD_2015 +#undef RS_TOKEN_KEYWORD_2018 #undef RS_TOKEN };