aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-ast.h
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-11-16 13:41:46 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-30 12:36:44 +0100
commitf1c7ce7e185444f498f8cb17a3c0f813a83fe3f3 (patch)
tree682014e39adb5ea8b56b8f123e329531e9b566ca /gcc/rust/ast/rust-ast.h
parentad2ff326cce7519587973c22e87288783e8f5e57 (diff)
downloadgcc-f1c7ce7e185444f498f8cb17a3c0f813a83fe3f3.zip
gcc-f1c7ce7e185444f498f8cb17a3c0f813a83fe3f3.tar.gz
gcc-f1c7ce7e185444f498f8cb17a3c0f813a83fe3f3.tar.bz2
gccrs: Replace some keyword raw values
Raw values cannot be understood easily by most tools. This commit replace some raw values with their variable counterpart. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Replace raw value with keyword call. * ast/rust-ast.h: Likewise. * parse/rust-parse-impl.h (Parser::parse_path_ident_segment): Likewise. (Parser::parse_macro_match_fragment): Likewise. (Parser::parse_extern_crate): Likewise. (Parser::parse_use_tree): Likewise. (Parser::parse_const_item): Likewise. (Parser::parse_literal_expr): Likewise. (Parser::parse_maybe_named_param): Likewise. (Parser::parse_pattern_no_alt): Likewise. (Parser::left_denotation): Likewise. (Parser::parse_path_in_expression_pratt): Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/ast/rust-ast.h')
-rw-r--r--gcc/rust/ast/rust-ast.h24
1 files changed, 17 insertions, 7 deletions
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index 47c02d6..4049e4d 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -25,6 +25,7 @@
#include "rust-token.h"
#include "rust-location.h"
#include "rust-diagnostics.h"
+#include "rust-keyword-values.h"
namespace Rust {
// TODO: remove typedefs and make actual types for these
@@ -393,14 +394,20 @@ public:
const std::string &get_segment_name () const { return segment_name; }
bool is_super_path_seg () const
{
- return as_string ().compare ("super") == 0;
+ return as_string ().compare (Values::Keywords::SUPER) == 0;
}
bool is_crate_path_seg () const
{
- return as_string ().compare ("crate") == 0;
+ return as_string ().compare (Values::Keywords::CRATE) == 0;
+ }
+ bool is_lower_self_seg () const
+ {
+ return as_string ().compare (Values::Keywords::SELF) == 0;
+ }
+ bool is_big_self () const
+ {
+ return as_string ().compare (Values::Keywords::SELF_ALIAS) == 0;
}
- bool is_lower_self_seg () const { return as_string ().compare ("self") == 0; }
- bool is_big_self () const { return as_string ().compare ("Self") == 0; }
};
// A simple path without generic or type arguments
@@ -562,7 +569,8 @@ public:
location_t crate_vis_location)
{
return Visibility (PUB_CRATE,
- SimplePath::from_str ("crate", crate_tok_location),
+ SimplePath::from_str (Values::Keywords::CRATE,
+ crate_tok_location),
crate_vis_location);
}
@@ -571,7 +579,8 @@ public:
location_t self_vis_location)
{
return Visibility (PUB_SELF,
- SimplePath::from_str ("self", self_tok_location),
+ SimplePath::from_str (Values::Keywords::SELF,
+ self_tok_location),
self_vis_location);
}
@@ -580,7 +589,8 @@ public:
location_t super_vis_location)
{
return Visibility (PUB_SUPER,
- SimplePath::from_str ("super", super_tok_location),
+ SimplePath::from_str (Values::Keywords::SUPER,
+ super_tok_location),
super_vis_location);
}