{
visit_items_as_lines (union_item.get_outer_attrs ());
auto id = union_item.get_identifier ().as_string ();
- push (Rust::Token::make_identifier (union_item.get_locus (), "union"));
+ push (Rust::Token::make_identifier (union_item.get_locus (),
+ Values::WeakKeywords::UNION));
push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id)));
if (union_item.has_generics ())
auto rule_name = rules_def.get_rule_name ().as_string ();
- push (Rust::Token::make_identifier (rules_def.get_locus (), "macro_rules"));
+ push (Rust::Token::make_identifier (rules_def.get_locus (),
+ Values::WeakKeywords::MACRO_RULES));
push (Rust::Token::make (EXCLAM, UNDEF_LOCATION));
push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (rule_name)));
bool allowed_macro_name = (macro_name == IDENTIFIER || macro_name == TRY);
- return t->get_str () == "macro_rules"
+ return t->get_str () == Values::WeakKeywords::MACRO_RULES
&& lexer.peek_token (1)->get_id () == EXCLAM && allowed_macro_name;
}
// crappy hack to do union "keyword"
case IDENTIFIER:
// TODO: ensure std::string and literal comparison works
- if (t->get_str () == "union"
+ if (t->get_str () == Values::WeakKeywords::UNION
&& lexer.peek_token (1)->get_id () == IDENTIFIER)
{
return parse_vis_item (std::move (outer_attrs));
// or should this go straight to parsing union?
}
- else if (t->get_str () == "default"
+ else if (t->get_str () == Values::WeakKeywords::DEFAULT
&& lexer.peek_token (1)->get_id () != EXCLAM)
{
add_error (Error (t->get_locus (),
// TODO: implement union keyword but not really because of
// context-dependence case UNION: crappy hack to do union "keyword"
case IDENTIFIER:
- if (t->get_str () == "union"
+ if (t->get_str () == Values::WeakKeywords::UNION
&& lexer.peek_token (1)->get_id () == IDENTIFIER)
{
return parse_union (std::move (vis), std::move (outer_attrs));
{
// ensure that first token is identifier saying "macro_rules"
const_TokenPtr t = lexer.peek_token ();
- if (t->get_id () != IDENTIFIER || t->get_str () != "macro_rules")
+ if (t->get_id () != IDENTIFIER
+ || t->get_str () != Values::WeakKeywords::MACRO_RULES)
{
Error error (
t->get_locus (),
/* hack - "weak keyword" by finding identifier called "union" (lookahead in
* item switch) */
const_TokenPtr union_keyword = expect_token (IDENTIFIER);
- rust_assert (union_keyword->get_str () == "union");
+ rust_assert (union_keyword->get_str () == Values::WeakKeywords::UNION);
location_t locus = union_keyword->get_locus ();
// parse actual union name
// semi
return parse_macro_invocation_semi (std::move (outer_attrs));
case IDENTIFIER:
- if (lexer.peek_token ()->get_str () == "default")
+ if (lexer.peek_token ()->get_str () == Values::WeakKeywords::DEFAULT)
return parse_trait_impl_function_or_method (visibility,
std::move (outer_attrs));
else
auto is_default = false;
auto t = lexer.peek_token ();
- if (t->get_id () == IDENTIFIER && t->get_str () == "default")
+ if (t->get_id () == IDENTIFIER
+ && t->get_str () == Values::WeakKeywords::DEFAULT)
{
is_default = true;
lexer.skip_token ();
break;
// crappy hack to do union "keyword"
case IDENTIFIER:
- if (t->get_str () == "union"
+ if (t->get_str () == Values::WeakKeywords::UNION
&& lexer.peek_token (1)->get_id () == IDENTIFIER)
{
return parse_vis_item (std::move (outer_attrs));
// crappy hack to do union "keyword"
case IDENTIFIER:
- if (t->get_str () == "union"
+ if (t->get_str () == Values::WeakKeywords::UNION
&& lexer.peek_token (1)->get_id () == IDENTIFIER)
{
std::unique_ptr<AST::VisItem> item (
return ExprOrStmt (std::move (item));
// or should this go straight to parsing union?
}
- else if (t->get_str () == "macro_rules"
+ else if (t->get_str () == Values::WeakKeywords::MACRO_RULES
&& lexer.peek_token (1)->get_id () == EXCLAM)
{
// macro_rules! macro item