aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-11-15 16:24:56 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-30 12:36:44 +0100
commit7f6319671e348bfd64cd1f468d19db3be50b5a93 (patch)
tree3268305ad76520c3e117194786a774b06c6d0192 /gcc
parent72792563e60fb56b42c2e96b3ae27d28e09c2e7d (diff)
downloadgcc-7f6319671e348bfd64cd1f468d19db3be50b5a93.zip
gcc-7f6319671e348bfd64cd1f468d19db3be50b5a93.tar.gz
gcc-7f6319671e348bfd64cd1f468d19db3be50b5a93.tar.bz2
gccrs: Replace TOK suffix with KW
TOK suffix was chosen to disambiguate some identifiers with c++ reserved keyword. Even though this list lies within the rust-token header, this macro is used in many context sometimes unrelated with the lexer and tokens. This TOK suffix may appear surprising in such context. gcc/rust/ChangeLog: * lex/rust-token.h (enum PrimitiveCoreType): Change keyword suffix from tok to kw. * ast/rust-ast-collector.cc (TokenCollector::visit): Update suffix to match the new declaration. * lex/rust-lex.cc (Lexer::parse_raw_identifier): Likewise. * parse/rust-parse-impl.h (can_tok_start_type): Likewise. (Parser::parse_item): Likewise. (Parser::parse_vis_item): Likewise. (Parser::parse_extern_crate): Likewise. (Parser::parse_function): Likewise. (Parser::parse_function_qualifiers): Likewise. (Parser::parse_struct): Likewise. (Parser::parse_enum): Likewise. (Parser::parse_static_item): Likewise. (Parser::parse_trait_item): Likewise. (Parser::parse_inherent_impl_item): Likewise. (Parser::parse_trait_impl_item): Likewise. (Parser::parse_extern_block): Likewise. (Parser::parse_external_item): Likewise. (Parser::parse_stmt): Likewise. (Parser::parse_return_expr): Likewise. (Parser::parse_match_expr): Likewise. (Parser::parse_type): Likewise. (Parser::parse_for_prefixed_type): Likewise. (Parser::parse_type_no_bounds): Likewise. (Parser::parse_stmt_or_expr): Likewise. * parse/rust-parse.cc (peculiar_fragment_match_compatible): Likewie. * util/rust-token-converter.cc (convert): Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/ast/rust-ast-collector.cc30
-rw-r--r--gcc/rust/lex/rust-lex.cc2
-rw-r--r--gcc/rust/lex/rust-token.h20
-rw-r--r--gcc/rust/parse/rust-parse-impl.h134
-rw-r--r--gcc/rust/parse/rust-parse.cc18
-rw-r--r--gcc/rust/util/rust-token-converter.cc18
6 files changed, 111 insertions, 111 deletions
diff --git a/gcc/rust/ast/rust-ast-collector.cc b/gcc/rust/ast/rust-ast-collector.cc
index 7d3d3e2..8f394e5 100644
--- a/gcc/rust/ast/rust-ast-collector.cc
+++ b/gcc/rust/ast/rust-ast-collector.cc
@@ -332,7 +332,7 @@ TokenCollector::visit (FunctionQualifiers &qualifiers)
push (Rust::Token::make (UNSAFE, qualifiers.get_locus ()));
if (qualifiers.is_extern ())
{
- push (Rust::Token::make (EXTERN_TOK, qualifiers.get_locus ()));
+ push (Rust::Token::make (EXTERN_KW, qualifiers.get_locus ()));
if (qualifiers.has_abi ())
{
push (Rust::Token::make_string (UNDEF_LOCATION,
@@ -1323,7 +1323,7 @@ TokenCollector::visit (RangeToInclExpr &expr)
void
TokenCollector::visit (ReturnExpr &expr)
{
- push (Rust::Token::make (RETURN_TOK, expr.get_locus ()));
+ push (Rust::Token::make (RETURN_KW, expr.get_locus ()));
if (expr.has_returned_expr ())
visit (expr.get_returned_expr ());
}
@@ -1463,7 +1463,7 @@ TokenCollector::visit (MatchCase &match_case)
void
TokenCollector::visit (MatchExpr &expr)
{
- push (Rust::Token::make (MATCH_TOK, expr.get_locus ()));
+ push (Rust::Token::make (MATCH_KW, expr.get_locus ()));
visit (expr.get_scrutinee_expr ());
push (Rust::Token::make (LEFT_CURLY, UNDEF_LOCATION));
newline ();
@@ -1609,7 +1609,7 @@ void
TokenCollector::visit (ExternCrate &crate)
{
visit_items_as_lines (crate.get_outer_attrs ());
- push (Rust::Token::make (EXTERN_TOK, crate.get_locus ()));
+ push (Rust::Token::make (EXTERN_KW, crate.get_locus ()));
push (Rust::Token::make (CRATE, UNDEF_LOCATION));
auto ref = crate.get_referenced_crate ();
push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (ref)));
@@ -1717,7 +1717,7 @@ TokenCollector::visit (Function &function)
auto qualifiers = function.get_qualifiers ();
visit (qualifiers);
- push (Rust::Token::make (FN_TOK, function.get_locus ()));
+ push (Rust::Token::make (FN_KW, function.get_locus ()));
auto name = function.get_function_name ().as_string ();
push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (name)));
if (function.has_generics ())
@@ -1778,7 +1778,7 @@ TokenCollector::visit (StructStruct &struct_item)
if (struct_item.has_visibility ())
visit (struct_item.get_visibility ());
auto struct_name = struct_item.get_identifier ().as_string ();
- push (Rust::Token::make (STRUCT_TOK, struct_item.get_locus ()));
+ push (Rust::Token::make (STRUCT_KW, struct_item.get_locus ()));
push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (struct_name)));
if (struct_item.has_generics ())
@@ -1800,7 +1800,7 @@ TokenCollector::visit (TupleStruct &tuple_struct)
{
visit_items_as_lines (tuple_struct.get_outer_attrs ());
auto struct_name = tuple_struct.get_identifier ().as_string ();
- push (Rust::Token::make (STRUCT_TOK, tuple_struct.get_locus ()));
+ push (Rust::Token::make (STRUCT_KW, tuple_struct.get_locus ()));
push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (struct_name)));
if (tuple_struct.has_generics ())
visit (tuple_struct.get_generic_params ());
@@ -1856,7 +1856,7 @@ TokenCollector::visit (Enum &enumeration)
visit_items_as_lines (enumeration.get_outer_attrs ());
if (enumeration.has_visibility ())
visit (enumeration.get_visibility ());
- push (Rust::Token::make (ENUM_TOK, enumeration.get_locus ()));
+ push (Rust::Token::make (ENUM_KW, enumeration.get_locus ()));
auto id = enumeration.get_identifier ().as_string ();
push (
Rust::Token::make_identifier (enumeration.get_locus (), std::move (id)));
@@ -1915,7 +1915,7 @@ void
TokenCollector::visit (StaticItem &item)
{
visit_items_as_lines (item.get_outer_attrs ());
- push (Rust::Token::make (STATIC_TOK, item.get_locus ()));
+ push (Rust::Token::make (STATIC_KW, item.get_locus ()));
if (item.is_mutable ())
push (Rust::Token::make (MUT, UNDEF_LOCATION));
@@ -1961,7 +1961,7 @@ TokenCollector::visit (TraitItemFunc &item)
auto func = item.get_trait_function_decl ();
auto id = func.get_identifier ().as_string ();
- push (Rust::Token::make (FN_TOK, item.get_locus ()));
+ push (Rust::Token::make (FN_KW, item.get_locus ()));
push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id)));
push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));
@@ -2000,7 +2000,7 @@ TokenCollector::visit (TraitItemMethod &item)
auto method = item.get_trait_method_decl ();
auto id = method.get_identifier ().as_string ();
- push (Rust::Token::make (FN_TOK, item.get_locus ()));
+ push (Rust::Token::make (FN_KW, item.get_locus ()));
push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id)));
push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));
@@ -2112,7 +2112,7 @@ TokenCollector::visit (ExternalStaticItem &item)
visit_items_as_lines (item.get_outer_attrs ());
if (item.has_visibility ())
visit (item.get_visibility ());
- push (Rust::Token::make (STATIC_TOK, item.get_locus ()));
+ push (Rust::Token::make (STATIC_KW, item.get_locus ()));
if (item.is_mut ())
push (Rust::Token::make (MUT, UNDEF_LOCATION));
push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id)));
@@ -2131,7 +2131,7 @@ TokenCollector::visit (ExternalFunctionItem &function)
auto id = function.get_identifier ().as_string ();
- push (Rust::Token::make (FN_TOK, function.get_locus ()));
+ push (Rust::Token::make (FN_KW, function.get_locus ()));
push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id)));
if (function.has_generics ())
visit (function.get_generic_params ());
@@ -2152,7 +2152,7 @@ void
TokenCollector::visit (ExternBlock &block)
{
visit_items_as_lines (block.get_outer_attrs ());
- push (Rust::Token::make (EXTERN_TOK, block.get_locus ()));
+ push (Rust::Token::make (EXTERN_KW, block.get_locus ()));
if (block.has_abi ())
{
@@ -2821,7 +2821,7 @@ TokenCollector::visit (BareFunctionType &type)
visit (type.get_function_qualifiers ());
- push (Rust::Token::make (FN_TOK, type.get_locus ()));
+ push (Rust::Token::make (FN_KW, type.get_locus ()));
push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));
visit_items_joined_by_separator (type.get_function_params (), COMMA);
diff --git a/gcc/rust/lex/rust-lex.cc b/gcc/rust/lex/rust-lex.cc
index 107dbad..2d41c11 100644
--- a/gcc/rust/lex/rust-lex.cc
+++ b/gcc/rust/lex/rust-lex.cc
@@ -1940,7 +1940,7 @@ Lexer::parse_raw_identifier (location_t loc)
using namespace Rust::Values;
std::set<std::string> invalid{
- Keywords::CRATE, Keywords::EXTERN_TOK, Keywords::SELF,
+ Keywords::CRATE, Keywords::EXTERN_KW, Keywords::SELF,
Keywords::SUPER, Keywords::SELF_ALIAS,
};
diff --git a/gcc/rust/lex/rust-token.h b/gcc/rust/lex/rust-token.h
index 5da8b6c..50513ac 100644
--- a/gcc/rust/lex/rust-token.h
+++ b/gcc/rust/lex/rust-token.h
@@ -162,11 +162,11 @@ enum PrimitiveCoreType
RS_TOKEN_KEYWORD (DO, "do") /* unused */ \
RS_TOKEN_KEYWORD (DYN, "dyn") \
RS_TOKEN_KEYWORD (ELSE, "else") \
- RS_TOKEN_KEYWORD (ENUM_TOK, "enum") \
- RS_TOKEN_KEYWORD (EXTERN_TOK, "extern") \
+ RS_TOKEN_KEYWORD (ENUM_KW, "enum") \
+ RS_TOKEN_KEYWORD (EXTERN_KW, "extern") \
RS_TOKEN_KEYWORD (FALSE_LITERAL, "false") \
- RS_TOKEN_KEYWORD (FINAL_TOK, "final") /* unused */ \
- RS_TOKEN_KEYWORD (FN_TOK, "fn") \
+ 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") \
@@ -174,20 +174,20 @@ enum PrimitiveCoreType
RS_TOKEN_KEYWORD (LET, "let") \
RS_TOKEN_KEYWORD (LOOP, "loop") \
RS_TOKEN_KEYWORD (MACRO, "macro") \
- RS_TOKEN_KEYWORD (MATCH_TOK, "match") \
+ 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_TOK, "override") /* unused */ \
- RS_TOKEN_KEYWORD (PRIV, "priv") /* unused */ \
+ 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_TOK, "return") \
+ 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_TOK, "static") \
- RS_TOKEN_KEYWORD (STRUCT_TOK, "struct") \
+ 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") \
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index 45c72e4..8b00614 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -160,8 +160,8 @@ can_tok_start_type (TokenId id)
case ASYNC:
case CONST:
case UNSAFE:
- case EXTERN_TOK:
- case FN_TOK:
+ case EXTERN_KW:
+ case FN_KW:
case IMPL:
case DYN:
case QUESTION_MARK:
@@ -1114,14 +1114,14 @@ Parser<ManagedTokenSource>::parse_item (bool called_from_statement)
return nullptr;
case PUB:
case MOD:
- case EXTERN_TOK:
+ case EXTERN_KW:
case USE:
- case FN_TOK:
+ case FN_KW:
case TYPE:
- case STRUCT_TOK:
- case ENUM_TOK:
+ case STRUCT_KW:
+ case ENUM_KW:
case CONST:
- case STATIC_TOK:
+ case STATIC_KW:
case AUTO:
case TRAIT:
case IMPL:
@@ -1302,7 +1302,7 @@ Parser<ManagedTokenSource>::parse_vis_item (AST::AttrVec outer_attrs)
{
case MOD:
return parse_module (std::move (vis), std::move (outer_attrs));
- case EXTERN_TOK:
+ case EXTERN_KW:
// lookahead to resolve syntactical production
t = lexer.peek_token (1);
@@ -1310,7 +1310,7 @@ Parser<ManagedTokenSource>::parse_vis_item (AST::AttrVec outer_attrs)
{
case CRATE:
return parse_extern_crate (std::move (vis), std::move (outer_attrs));
- case FN_TOK: // extern function
+ case FN_KW: // extern function
return parse_function (std::move (vis), std::move (outer_attrs));
case LEFT_CURLY: // extern block
return parse_extern_block (std::move (vis), std::move (outer_attrs));
@@ -1320,7 +1320,7 @@ Parser<ManagedTokenSource>::parse_vis_item (AST::AttrVec outer_attrs)
switch (t->get_id ())
{
- case FN_TOK:
+ case FN_KW:
return parse_function (std::move (vis), std::move (outer_attrs));
case LEFT_CURLY:
return parse_extern_block (std::move (vis),
@@ -1345,13 +1345,13 @@ Parser<ManagedTokenSource>::parse_vis_item (AST::AttrVec outer_attrs)
}
case USE:
return parse_use_decl (std::move (vis), std::move (outer_attrs));
- case FN_TOK:
+ case FN_KW:
return parse_function (std::move (vis), std::move (outer_attrs));
case TYPE:
return parse_type_alias (std::move (vis), std::move (outer_attrs));
- case STRUCT_TOK:
+ case STRUCT_KW:
return parse_struct (std::move (vis), std::move (outer_attrs));
- case ENUM_TOK:
+ case ENUM_KW:
return parse_enum (std::move (vis), std::move (outer_attrs));
// TODO: implement union keyword but not really because of
// context-dependence case UNION: crappy hack to do union "keyword"
@@ -1376,8 +1376,8 @@ Parser<ManagedTokenSource>::parse_vis_item (AST::AttrVec outer_attrs)
case UNDERSCORE:
return parse_const_item (std::move (vis), std::move (outer_attrs));
case UNSAFE:
- case EXTERN_TOK:
- case FN_TOK:
+ case EXTERN_KW:
+ case FN_KW:
return parse_function (std::move (vis), std::move (outer_attrs));
default:
add_error (
@@ -1388,7 +1388,7 @@ Parser<ManagedTokenSource>::parse_vis_item (AST::AttrVec outer_attrs)
lexer.skip_token (1); // TODO: is this right thing to do?
return nullptr;
}
- case STATIC_TOK:
+ case STATIC_KW:
return parse_static_item (std::move (vis), std::move (outer_attrs));
case AUTO:
case TRAIT:
@@ -1404,8 +1404,8 @@ Parser<ManagedTokenSource>::parse_vis_item (AST::AttrVec outer_attrs)
case AUTO:
case TRAIT:
return parse_trait (std::move (vis), std::move (outer_attrs));
- case EXTERN_TOK:
- case FN_TOK:
+ case EXTERN_KW:
+ case FN_KW:
return parse_function (std::move (vis), std::move (outer_attrs));
case IMPL:
return parse_impl (std::move (vis), std::move (outer_attrs));
@@ -2482,7 +2482,7 @@ Parser<ManagedTokenSource>::parse_extern_crate (AST::Visibility vis,
AST::AttrVec outer_attrs)
{
location_t locus = lexer.peek_token ()->get_locus ();
- if (!skip_token (EXTERN_TOK))
+ if (!skip_token (EXTERN_KW))
{
skip_after_semicolon ();
return nullptr;
@@ -2854,7 +2854,7 @@ Parser<ManagedTokenSource>::parse_function (AST::Visibility vis,
// Get qualifiers for function if they exist
AST::FunctionQualifiers qualifiers = parse_function_qualifiers ();
- skip_token (FN_TOK);
+ skip_token (FN_KW);
// Save function name token
const_TokenPtr function_name_tok = expect_token (IDENTIFIER);
@@ -2962,7 +2962,7 @@ Parser<ManagedTokenSource>::parse_function_qualifiers ()
has_unsafe = true;
}
- if (lexer.peek_token ()->get_id () == EXTERN_TOK)
+ if (lexer.peek_token ()->get_id () == EXTERN_KW)
{
lexer.skip_token ();
has_extern = true;
@@ -4193,7 +4193,7 @@ Parser<ManagedTokenSource>::parse_struct (AST::Visibility vis,
/* Tuple struct <- 'struct' IDENTIFIER generic_params? '(' tuple_fields? ')'
* where_clause? ';' */
location_t locus = lexer.peek_token ()->get_locus ();
- skip_token (STRUCT_TOK);
+ skip_token (STRUCT_KW);
// parse struct name
const_TokenPtr name_tok = expect_token (IDENTIFIER);
@@ -4521,7 +4521,7 @@ Parser<ManagedTokenSource>::parse_enum (AST::Visibility vis,
AST::AttrVec outer_attrs)
{
location_t locus = lexer.peek_token ()->get_locus ();
- skip_token (ENUM_TOK);
+ skip_token (ENUM_KW);
// parse enum name
const_TokenPtr enum_name_tok = expect_token (IDENTIFIER);
@@ -4856,7 +4856,7 @@ Parser<ManagedTokenSource>::parse_static_item (AST::Visibility vis,
AST::AttrVec outer_attrs)
{
location_t locus = lexer.peek_token ()->get_locus ();
- skip_token (STATIC_TOK);
+ skip_token (STATIC_KW);
// determine whether static item is mutable
bool is_mut = false;
@@ -5024,8 +5024,8 @@ Parser<ManagedTokenSource>::parse_trait_item ()
// TODO: find out how to disable gcc "implicit fallthrough" error
gcc_fallthrough ();
case UNSAFE:
- case EXTERN_TOK:
- case FN_TOK: {
+ case EXTERN_KW:
+ case FN_KW: {
/* function and method can't be disambiguated by lookahead alone
* (without a lot of work and waste), so either make a
* "parse_trait_function_or_method" or parse here mostly and pass in
@@ -5035,7 +5035,7 @@ Parser<ManagedTokenSource>::parse_trait_item ()
// parse function or method qualifiers
AST::FunctionQualifiers qualifiers = parse_function_qualifiers ();
- skip_token (FN_TOK);
+ skip_token (FN_KW);
// parse function or method name
const_TokenPtr ident_tok = expect_token (IDENTIFIER);
@@ -5484,9 +5484,9 @@ Parser<ManagedTokenSource>::parse_inherent_impl_item ()
// TODO: is a recursive call to parse_inherent_impl_item better?
switch (lexer.peek_token ()->get_id ())
{
- case EXTERN_TOK:
+ case EXTERN_KW:
case UNSAFE:
- case FN_TOK:
+ case FN_KW:
// function or method
return parse_inherent_impl_function_or_method (std::move (vis),
std::move (
@@ -5503,8 +5503,8 @@ Parser<ManagedTokenSource>::parse_inherent_impl_item ()
return parse_const_item (std::move (vis),
std::move (outer_attrs));
case UNSAFE:
- case EXTERN_TOK:
- case FN_TOK:
+ case EXTERN_KW:
+ case FN_KW:
return parse_inherent_impl_function_or_method (std::move (vis),
std::move (
outer_attrs));
@@ -5526,9 +5526,9 @@ Parser<ManagedTokenSource>::parse_inherent_impl_item ()
return nullptr;
}
}
- case EXTERN_TOK:
+ case EXTERN_KW:
case UNSAFE:
- case FN_TOK:
+ case FN_KW:
// function or method
return parse_inherent_impl_function_or_method (
AST::Visibility::create_private (), std::move (outer_attrs));
@@ -5544,8 +5544,8 @@ Parser<ManagedTokenSource>::parse_inherent_impl_item ()
return parse_const_item (AST::Visibility::create_private (),
std::move (outer_attrs));
case UNSAFE:
- case EXTERN_TOK:
- case FN_TOK:
+ case EXTERN_KW:
+ case FN_KW:
return parse_inherent_impl_function_or_method (
AST::Visibility::create_private (), std::move (outer_attrs));
default:
@@ -5583,7 +5583,7 @@ Parser<ManagedTokenSource>::parse_inherent_impl_function_or_method (
// parse function or method qualifiers
AST::FunctionQualifiers qualifiers = parse_function_qualifiers ();
- skip_token (FN_TOK);
+ skip_token (FN_KW);
// parse function or method name
const_TokenPtr ident_tok = expect_token (IDENTIFIER);
@@ -5720,9 +5720,9 @@ Parser<ManagedTokenSource>::parse_trait_impl_item ()
return parse_macro_invocation_semi (std::move (outer_attrs));
case TYPE:
return parse_type_alias (visibility, std::move (outer_attrs));
- case EXTERN_TOK:
+ case EXTERN_KW:
case UNSAFE:
- case FN_TOK:
+ case FN_KW:
// function or method
return parse_trait_impl_function_or_method (visibility,
std::move (outer_attrs));
@@ -5737,8 +5737,8 @@ Parser<ManagedTokenSource>::parse_trait_impl_item ()
case UNDERSCORE:
return parse_const_item (visibility, std::move (outer_attrs));
case UNSAFE:
- case EXTERN_TOK:
- case FN_TOK:
+ case EXTERN_KW:
+ case FN_KW:
return parse_trait_impl_function_or_method (visibility,
std::move (outer_attrs));
default:
@@ -5786,7 +5786,7 @@ Parser<ManagedTokenSource>::parse_trait_impl_function_or_method (
// parse function or method qualifiers
AST::FunctionQualifiers qualifiers = parse_function_qualifiers ();
- skip_token (FN_TOK);
+ skip_token (FN_KW);
// parse function or method name
const_TokenPtr ident_tok = expect_token (IDENTIFIER);
@@ -5931,7 +5931,7 @@ Parser<ManagedTokenSource>::parse_extern_block (AST::Visibility vis,
AST::AttrVec outer_attrs)
{
location_t locus = lexer.peek_token ()->get_locus ();
- skip_token (EXTERN_TOK);
+ skip_token (EXTERN_KW);
// detect optional abi name
std::string abi;
@@ -6167,7 +6167,7 @@ Parser<ManagedTokenSource>::parse_external_item ()
{
case IDENTIFIER:
return parse_macro_invocation_semi (outer_attrs);
- case STATIC_TOK: {
+ case STATIC_KW: {
// parse extern static item
lexer.skip_token ();
@@ -6217,7 +6217,7 @@ Parser<ManagedTokenSource>::parse_external_item ()
has_mut, std::move (vis),
std::move (outer_attrs), locus));
}
- case FN_TOK:
+ case FN_KW:
return parse_external_function_item (std::move (vis),
std::move (outer_attrs));
case TYPE:
@@ -6266,14 +6266,14 @@ Parser<ManagedTokenSource>::parse_stmt (ParseRestrictions restrictions)
return parse_let_stmt (std::move (outer_attrs), restrictions);
case PUB:
case MOD:
- case EXTERN_TOK:
+ case EXTERN_KW:
case USE:
- case FN_TOK:
+ case FN_KW:
case TYPE:
- case STRUCT_TOK:
- case ENUM_TOK:
+ case STRUCT_KW:
+ case ENUM_KW:
case CONST:
- case STATIC_TOK:
+ case STATIC_KW:
case AUTO:
case TRAIT:
case IMPL:
@@ -7675,7 +7675,7 @@ Parser<ManagedTokenSource>::parse_return_expr (AST::AttrVec outer_attrs,
if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
- skip_token (RETURN_TOK);
+ skip_token (RETURN_KW);
}
// parse expression to return, if it exists
@@ -8448,7 +8448,7 @@ Parser<ManagedTokenSource>::parse_match_expr (AST::AttrVec outer_attrs,
if (locus == UNKNOWN_LOCATION)
{
locus = lexer.peek_token ()->get_locus ();
- skip_token (MATCH_TOK);
+ skip_token (MATCH_KW);
}
/* parse scrutinee expression, which is required (and HACK to prevent struct
@@ -9246,8 +9246,8 @@ Parser<ManagedTokenSource>::parse_type (bool save_errors)
case ASYNC:
case CONST:
case UNSAFE:
- case EXTERN_TOK:
- case FN_TOK:
+ case EXTERN_KW:
+ case FN_KW:
// bare function type (with no for lifetimes)
return parse_bare_function_type (std::vector<AST::LifetimeParam> ());
case IMPL:
@@ -9563,8 +9563,8 @@ Parser<ManagedTokenSource>::parse_for_prefixed_type ()
case ASYNC:
case CONST:
case UNSAFE:
- case EXTERN_TOK:
- case FN_TOK:
+ case EXTERN_KW:
+ case FN_KW:
return parse_bare_function_type (std::move (for_lifetimes));
case SCOPE_RESOLUTION:
case IDENTIFIER:
@@ -9686,7 +9686,7 @@ Parser<ManagedTokenSource>::parse_bare_function_type (
AST::FunctionQualifiers qualifiers = parse_function_qualifiers ();
- if (!skip_token (FN_TOK))
+ if (!skip_token (FN_KW))
return nullptr;
if (!skip_token (LEFT_PAREN))
@@ -10072,8 +10072,8 @@ Parser<ManagedTokenSource>::parse_type_no_bounds ()
case ASYNC:
case CONST:
case UNSAFE:
- case EXTERN_TOK:
- case FN_TOK:
+ case EXTERN_KW:
+ case FN_KW:
// bare function type (with no for lifetimes)
return parse_bare_function_type (std::vector<AST::LifetimeParam> ());
case IMPL:
@@ -11632,14 +11632,14 @@ Parser<ManagedTokenSource>::parse_stmt_or_expr ()
}
case PUB:
case MOD:
- case EXTERN_TOK:
+ case EXTERN_KW:
case USE:
- case FN_TOK:
+ case FN_KW:
case TYPE:
- case STRUCT_TOK:
- case ENUM_TOK:
+ case STRUCT_KW:
+ case ENUM_KW:
case CONST:
- case STATIC_TOK:
+ case STATIC_KW:
case AUTO:
case TRAIT:
case IMPL: {
@@ -11670,8 +11670,8 @@ Parser<ManagedTokenSource>::parse_stmt_or_expr ()
parse_vis_item (std::move (outer_attrs)));
return ExprOrStmt (std::move (item));
}
- case EXTERN_TOK:
- case FN_TOK: {
+ case EXTERN_KW:
+ case FN_KW: {
// unsafe function
std::unique_ptr<AST::VisItem> item (
parse_vis_item (std::move (outer_attrs)));
@@ -12535,7 +12535,7 @@ Parser<ManagedTokenSource>::null_denotation_not_path (
case DOT_DOT_EQ:
// range to inclusive expr
return parse_range_to_inclusive_expr (tok, std::move (outer_attrs));
- case RETURN_TOK:
+ case RETURN_KW:
// FIXME: is this really a null denotation expression?
return parse_return_expr (std::move (outer_attrs), tok->get_locus ());
case BREAK:
@@ -12578,7 +12578,7 @@ Parser<ManagedTokenSource>::null_denotation_not_path (
case FOR:
return parse_for_loop_expr (std::move (outer_attrs),
AST::LoopLabel::error ());
- case MATCH_TOK:
+ case MATCH_KW:
// also an expression with block
return parse_match_expr (std::move (outer_attrs), tok->get_locus ());
case LEFT_SQUARE:
diff --git a/gcc/rust/parse/rust-parse.cc b/gcc/rust/parse/rust-parse.cc
index 0f91c7f..504a409 100644
--- a/gcc/rust/parse/rust-parse.cc
+++ b/gcc/rust/parse/rust-parse.cc
@@ -194,11 +194,11 @@ peculiar_fragment_match_compatible (const AST::MacroMatchFragment &last_match,
DO,
DYN,
ELSE,
- ENUM_TOK,
- EXTERN_TOK,
+ ENUM_KW,
+ EXTERN_KW,
FALSE_LITERAL,
- FINAL_TOK,
- FN_TOK,
+ FINAL_KW,
+ FN_KW,
FOR,
IF,
IMPL,
@@ -206,18 +206,18 @@ peculiar_fragment_match_compatible (const AST::MacroMatchFragment &last_match,
LET,
LOOP,
MACRO,
- MATCH_TOK,
+ MATCH_KW,
MOD,
MOVE,
MUT,
- OVERRIDE_TOK,
+ OVERRIDE_KW,
PUB,
REF,
- RETURN_TOK,
+ RETURN_KW,
SELF_ALIAS,
SELF,
- STATIC_TOK,
- STRUCT_TOK,
+ STATIC_KW,
+ STRUCT_KW,
SUPER,
TRAIT,
TRUE_LITERAL,
diff --git a/gcc/rust/util/rust-token-converter.cc b/gcc/rust/util/rust-token-converter.cc
index 537bca3..41f8105 100644
--- a/gcc/rust/util/rust-token-converter.cc
+++ b/gcc/rust/util/rust-token-converter.cc
@@ -134,10 +134,10 @@ convert (const std::vector<const_TokenPtr> &tokens)
case DO:
case DYN:
case ELSE:
- case ENUM_TOK:
- case EXTERN_TOK:
- case FINAL_TOK:
- case FN_TOK:
+ case ENUM_KW:
+ case EXTERN_KW:
+ case FINAL_KW:
+ case FN_KW:
case FOR:
case IF:
case IMPL:
@@ -145,19 +145,19 @@ convert (const std::vector<const_TokenPtr> &tokens)
case LET:
case LOOP:
case MACRO:
- case MATCH_TOK:
+ case MATCH_KW:
case MOD:
case MOVE:
case MUT:
- case OVERRIDE_TOK:
+ case OVERRIDE_KW:
case PRIV:
case PUB:
case REF:
- case RETURN_TOK:
+ case RETURN_KW:
case SELF_ALIAS:
case SELF:
- case STATIC_TOK:
- case STRUCT_TOK:
+ case STATIC_KW:
+ case STRUCT_KW:
case SUPER:
case TRAIT:
case TRY: