aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/ast')
-rw-r--r--gcc/rust/ast/rust-ast-collector.cc13
-rw-r--r--gcc/rust/ast/rust-ast.h24
2 files changed, 24 insertions, 13 deletions
diff --git a/gcc/rust/ast/rust-ast-collector.cc b/gcc/rust/ast/rust-ast-collector.cc
index 8f394e5..5b12875 100644
--- a/gcc/rust/ast/rust-ast-collector.cc
+++ b/gcc/rust/ast/rust-ast-collector.cc
@@ -17,6 +17,7 @@
// <http://www.gnu.org/licenses/>.
#include "rust-ast-collector.h"
#include "rust-item.h"
+#include "rust-keyword-values.h"
namespace Rust {
namespace AST {
@@ -461,11 +462,11 @@ TokenCollector::visit (Lifetime &lifetime)
break;
case Lifetime::LifetimeType::STATIC:
push (Rust::Token::make_lifetime (lifetime.get_locus (),
- std::move ("static")));
+ Values::Keywords::STATIC_KW));
break;
case Lifetime::LifetimeType::WILDCARD:
- push (
- Rust::Token::make_lifetime (lifetime.get_locus (), std::move ("_")));
+ push (Rust::Token::make_lifetime (lifetime.get_locus (),
+ Values::Keywords::UNDERSCORE));
break;
}
}
@@ -787,9 +788,9 @@ TokenCollector::visit (Literal &lit, location_t locus)
lit.get_type_hint ()));
break;
case Literal::LitType::BOOL: {
- if (value == "false")
+ if (value == Values::Keywords::FALSE_LITERAL)
push (Rust::Token::make (FALSE_LITERAL, locus));
- else if (value == "true")
+ else if (value == Values::Keywords::TRUE_LITERAL)
push (Rust::Token::make (TRUE_LITERAL, locus));
else
rust_unreachable (); // Not a boolean
@@ -1484,7 +1485,7 @@ TokenCollector::visit (AwaitExpr &expr)
visit (expr.get_awaited_expr ());
push (Rust::Token::make (DOT, expr.get_locus ()));
// TODO: Check status of await keyword (Context dependant ?)
- push (Rust::Token::make_identifier (UNDEF_LOCATION, "await"));
+ push (Rust::Token::make_identifier (UNDEF_LOCATION, Values::Keywords::AWAIT));
}
void
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);
}