| 1 |
// Copyright (C) 2020-2025 Free Software Foundation, Inc. |
| 2 |
|
| 3 |
// This file is part of GCC. |
| 4 |
|
| 5 |
// GCC is free software; you can redistribute it and/or modify it under |
| 6 |
// the terms of the GNU General Public License as published by the Free |
| 7 |
// Software Foundation; either version 3, or (at your option) any later |
| 8 |
// version. |
| 9 |
|
| 10 |
// GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
| 11 |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 13 |
// for more details. |
| 14 |
|
| 15 |
// You should have received a copy of the GNU General Public License |
| 16 |
// along with GCC; see the file COPYING3. If not see |
| 17 |
// <http://www.gnu.org/licenses/>. |
| 18 |
|
| 19 |
#ifndef RUST_KEYWORD_VALUES_H |
| 20 |
#define RUST_KEYWORD_VALUES_H |
| 21 |
|
| 22 |
#include "rust-token.h" |
| 23 |
|
| 24 |
// Append keywords made from multiple tokens to the existing token-keyword list |
| 25 |
#define RS_KEYWORD_LIST \ |
| 26 |
RS_TOKEN_LIST \ |
| 27 |
RS_TOKEN_KEYWORD_2015 (DOLLAR_CRATE, "$crate") \ |
| 28 |
RS_TOKEN_KEYWORD_2015 (PATH_ROOT, "{{root}}") \ |
| 29 |
RS_TOKEN_KEYWORD_2015 (STATIC_LIFETIME, "'static") \ |
| 30 |
RS_TOKEN_KEYWORD_2015 (UNDERSCORE_LIFETIME, "'_") |
| 31 |
|
| 32 |
namespace Rust { |
| 33 |
namespace Values { |
| 34 |
|
| 35 |
// TODO: Change this to a namespace + inline constexpr in the future |
| 36 |
class Keywords |
| 37 |
{ |
| 38 |
public: |
| 39 |
const static std::map<std::string, TokenId> keywords_tokens; |
| 40 |
|
| 41 |
const static std::set<std::string> keywords; |
| 42 |
// Rust keyword values |
| 43 |
public: |
| 44 |
#define RS_TOKEN(x, y) |
| 45 |
#define RS_TOKEN_KEYWORD_2015(tok, key) static constexpr auto &tok = key; |
| 46 |
#define RS_TOKEN_KEYWORD_2018 RS_TOKEN_KEYWORD_2015 |
| 47 |
RS_KEYWORD_LIST |
| 48 |
#undef RS_TOKEN_KEYWORD_2015 |
| 49 |
#undef RS_TOKEN_KEYWORD_2018 |
| 50 |
#undef RS_TOKEN |
| 51 |
}; |
| 52 |
|
| 53 |
class WeakKeywords |
| 54 |
{ |
| 55 |
public: |
| 56 |
static constexpr auto &AUTO = "auto"; |
| 57 |
static constexpr auto &BUILTIN = "builtin"; |
| 58 |
static constexpr auto &CATCH = "catch"; |
| 59 |
static constexpr auto &DEFAULT = "default"; |
| 60 |
static constexpr auto &GEN = "gen"; |
| 61 |
static constexpr auto &MACRO_RULES = "macro_rules"; |
| 62 |
static constexpr auto &RAW = "raw"; |
| 63 |
static constexpr auto &UNION = "union"; |
| 64 |
static constexpr auto &YEET = "yeet"; |
| 65 |
}; |
| 66 |
|
| 67 |
} // namespace Values |
| 68 |
} // namespace Rust |
| 69 |
|
| 70 |
#endif /* !RUST_KEYWORD_VALUES_H */ |