void
TokenCollector::comment (std::string comment)
{
- tokens.emplace_back (comment);
+ tokens.emplace_back (CollectItem::make_comment (comment));
}
void
-TokenCollector::begin_internal_comment (std::string comment)
+TokenCollector::begin_describe_node (const std::string &node_name)
{
- std::string symbol_begin ("(");
+ const std::string symbol_begin ("(");
- tokens.push_back ({comment + symbol_begin, CollectItem::Comment::Internal});
+ tokens.emplace_back (
+ CollectItem::make_node_description (node_name + symbol_begin));
}
void
-TokenCollector::end_internal_comment (std::string comment)
+TokenCollector::end_describe_node (const std::string &node_name)
{
- std::string symbol_end (")!");
+ const std::string symbol_end (")!");
- tokens.push_back ({symbol_end + comment, CollectItem::Comment::Internal});
+ tokens.push_back (
+ CollectItem::make_node_description (symbol_end + node_name));
}
void
-TokenCollector::internal_comment (std::string node_name,
- std::function<void ()> visitor)
+TokenCollector::describe_node (const std::string &node_name,
+ std::function<void ()> visitor)
{
- begin_internal_comment (node_name);
+ begin_describe_node (node_name);
visitor ();
- end_internal_comment (node_name);
+ end_describe_node (node_name);
}
void
void
TokenCollector::visit (FunctionParam ¶m)
{
- internal_comment (std::string ("FunctionParam"), [this, ¶m] () {
+ describe_node (std::string ("FunctionParam"), [this, ¶m] () {
visit_items_as_lines (param.get_outer_attrs ());
if (!param.is_variadic ())
{
void
TokenCollector::visit (VariadicParam ¶m)
{
- internal_comment (std::string ("VariadicParam"), [this, ¶m] () {
+ describe_node (std::string ("VariadicParam"), [this, ¶m] () {
if (param.has_pattern ())
{
visit (param.get_pattern ());
void
TokenCollector::visit (Attribute &attrib)
{
- internal_comment (std::string ("Attribute"), [this, &attrib] () {
+ describe_node (std::string ("Attribute"), [this, &attrib] () {
push (Rust::Token::make (HASH, attrib.get_locus ()));
if (attrib.is_inner_attribute ())
push (Rust::Token::make (EXCLAM, UNDEF_LOCATION));
}
push (Rust::Token::make (RIGHT_SQUARE, UNDEF_LOCATION));
});
-
- end_internal_comment ("Attribute");
}
void
TokenCollector::visit (SimplePath &path)
{
- internal_comment (std::string ("SimplePath"), [this, &path] () {
+ describe_node (std::string ("SimplePath"), [this, &path] () {
if (path.has_opening_scope_resolution ())
{
push (Rust::Token::make (SCOPE_RESOLUTION, path.get_locus ()));
void
TokenCollector::visit (SimplePathSegment &segment)
{
- internal_comment (std::string ("SimplePathSegment"), [this, &segment] () {
+ describe_node (std::string ("SimplePathSegment"), [this, &segment] () {
auto name = segment.get_segment_name ();
if (segment.is_crate_path_seg ())
{
void
TokenCollector::visit (Visibility &vis)
{
- internal_comment (std::string ("Visibility"), [this, &vis] () {
+ describe_node (std::string ("Visibility"), [this, &vis] () {
switch (vis.get_vis_type ())
{
case Visibility::PUB:
void
TokenCollector::visit (std::vector<std::unique_ptr<GenericParam>> ¶ms)
{
- internal_comment (std::string ("GenericParam"), [this, ¶ms] () {
+ describe_node (std::string ("GenericParam"), [this, ¶ms] () {
push (Rust::Token::make (LEFT_ANGLE, UNDEF_LOCATION));
visit_items_joined_by_separator (params, COMMA);
push (Rust::Token::make (RIGHT_ANGLE, UNDEF_LOCATION));
void
TokenCollector::visit (TupleField &field)
{
- internal_comment (std::string ("TupleField"), [this, &field] () {
+ describe_node (std::string ("TupleField"), [this, &field] () {
for (auto attr : field.get_outer_attrs ())
{
visit (attr);
void
TokenCollector::visit (StructField &field)
{
- internal_comment (std::string ("StructField"), [this, &field] () {
+ describe_node (std::string ("StructField"), [this, &field] () {
for (auto attr : field.get_outer_attrs ())
{
visit (attr);
void
TokenCollector::visit (std::vector<LifetimeParam> &for_lifetimes)
{
- internal_comment (std::string ("LifetimeParam"), [this, &for_lifetimes] () {
+ describe_node (std::string ("LifetimeParam"), [this, &for_lifetimes] () {
push (Rust::Token::make (FOR, UNDEF_LOCATION));
push (Rust::Token::make (LEFT_ANGLE, UNDEF_LOCATION));
visit_items_joined_by_separator (for_lifetimes, COMMA);
// Syntax:
// `const`? `async`? `unsafe`? (`extern` Abi?)?
// unsafe? (extern Abi?)?
- internal_comment (std::string ("FunctionQualifiers"), [this, &qualifiers] () {
+ describe_node (std::string ("FunctionQualifiers"), [this, &qualifiers] () {
if (qualifiers.is_async ())
push (Rust::Token::make (ASYNC, qualifiers.get_locus ()));
if (qualifiers.is_const ())
// Syntax:
// OuterAttribute* ( ( IDENTIFIER | _ ) : )? Type
- internal_comment (std::string ("MaybeNamedParam"), [this, ¶m] () {
+ describe_node (std::string ("MaybeNamedParam"), [this, ¶m] () {
for (auto attr : param.get_outer_attrs ())
{
visit (attr);
void
TokenCollector::visit (DelimTokenTree &delim_tok_tree)
{
- internal_comment (std::string ("DelimTokenTree"), [this, &delim_tok_tree] () {
+ describe_node (std::string ("DelimTokenTree"), [this, &delim_tok_tree] () {
for (auto &token : delim_tok_tree.to_token_stream ())
{
visit (token);
void
TokenCollector::visit (AttrInputMetaItemContainer &container)
{
- internal_comment (std::string ("AttrInputMetaItemContainer"),
- [this, &container] () {
- for (auto &item : container.get_items ())
- {
- visit (item);
- }
- });
+ describe_node (std::string ("AttrInputMetaItemContainer"),
+ [this, &container] () {
+ for (auto &item : container.get_items ())
+ {
+ visit (item);
+ }
+ });
}
void
TokenCollector::visit (IdentifierExpr &ident_expr)
{
- internal_comment (std::string ("IdentifierExpr"), [this, &ident_expr] () {
+ describe_node (std::string ("IdentifierExpr"), [this, &ident_expr] () {
auto ident = ident_expr.get_ident ().as_string ();
push (Rust::Token::make_identifier (ident_expr.get_locus (),
std::move (ident)));
// | 'static
// | '_
- internal_comment (std::string ("Lifetime"), [this, &lifetime] () {
+ describe_node (std::string ("Lifetime"), [this, &lifetime] () {
auto name = lifetime.get_lifetime_name ();
switch (lifetime.get_lifetime_type ())
{
// ( Lifetime + )* Lifetime?
// TODO what to do with outer attr? They are not mentioned in the reference.
- internal_comment (std::string ("LifetimeParam"), [this, &lifetime_param] () {
+ describe_node (std::string ("LifetimeParam"), [this, &lifetime_param] () {
visit_items_as_lines (lifetime_param.get_outer_attrs ());
auto lifetime = lifetime_param.get_lifetime ();
visit (lifetime);
{
// Syntax:
// const IDENTIFIER : Type ( = Block | IDENTIFIER | -?LITERAL )?
- internal_comment (std::string ("ConstGenericParam"), [this, ¶m] () {
+ describe_node (std::string ("ConstGenericParam"), [this, ¶m] () {
visit_items_as_lines (param.get_outer_attrs ());
push (Rust::Token::make (CONST, param.get_locus ()));
auto id = param.get_name ().as_string ();
void
TokenCollector::visit (PathExprSegment &segment)
{
- internal_comment (std::string ("PathExprSegment"), [this, &segment] () {
+ describe_node (std::string ("PathExprSegment"), [this, &segment] () {
visit (segment.get_ident_segment ());
if (segment.has_generic_args ())
{
void
TokenCollector::visit (PathInExpression &path)
{
- internal_comment (std::string ("PathInExpression"), [this, &path] () {
+ describe_node (std::string ("PathInExpression"), [this, &path] () {
if (path.is_lang_item ())
{
push (Rust::Token::make (TokenId::HASH, path.get_locus ()));
{
// Syntax:
// PathIdentSegment
- internal_comment (std::string ("TypePathSegment"), [this, &segment] () {
+ describe_node (std::string ("TypePathSegment"), [this, &segment] () {
auto locus = segment.is_lang_item ()
? segment.get_locus ()
: segment.get_ident_segment ().get_locus ();
// GenericArgs :
// `<` `>`
// | `<` ( GenericArg `,` )* GenericArg `,`? `>`
- internal_comment (std::string ("TypePathSegmentGeneric"), [this,
- &segment] () {
+ describe_node (std::string ("TypePathSegmentGeneric"), [this, &segment] () {
auto ident_segment = segment.get_ident_segment ();
auto id = ident_segment.as_string ();
push (Rust::Token::make_identifier (ident_segment.get_locus (),
{
// Syntax:
// IDENTIFIER `=` Type
- internal_comment (std::string ("GenericArgsBinding"), [this, &binding] () {
+ describe_node (std::string ("GenericArgsBinding"), [this, &binding] () {
auto identifier = binding.get_identifier ().as_string ();
push (Rust::Token::make_identifier (binding.get_locus (),
std::move (identifier)));
{
// `GenericArg` implements `accept_vis` but it is not useful for this case
// as it ignores unresolved cases (`Kind::Either`).
- internal_comment (std::string ("GenericArg"), [this, &arg] () {
+ describe_node (std::string ("GenericArg"), [this, &arg] () {
switch (arg.get_kind ())
{
case GenericArg::Kind::Const:
{
// Syntax:
// PathIdentSegment `::`? (TypePathFn)?
- internal_comment (std::string ("TypePathSegmentFunction"), [this,
- &segment] () {
+ describe_node (std::string ("TypePathSegmentFunction"), [this, &segment] () {
auto ident_segment = segment.get_ident_segment ();
auto id = ident_segment.as_string ();
push (Rust::Token::make_identifier (ident_segment.get_locus (),
// `(` TypePathFnInputs? `)` (`->` Type)?
// TypePathFnInputs :
// Type (`,` Type)* `,`?
- internal_comment (std::string ("TypePathFunction"), [this, &type_path_fn] () {
+ describe_node (std::string ("TypePathFunction"), [this, &type_path_fn] () {
push (Rust::Token::make (LEFT_PAREN, type_path_fn.get_locus ()));
if (type_path_fn.has_inputs ())
visit_items_joined_by_separator (type_path_fn.get_params (), COMMA);
{
// Syntax:
// `::`? TypePathSegment (`::` TypePathSegment)*
- internal_comment (std::string ("TypePath"), [this, &path] () {
+ describe_node (std::string ("TypePath"), [this, &path] () {
if (path.has_opening_scope_resolution_op ())
push (Rust::Token::make (SCOPE_RESOLUTION, path.get_locus ()));
void
TokenCollector::visit (PathIdentSegment &segment)
{
- internal_comment (std::string ("PathIdentSegment"), [this, &segment] () {
+ describe_node (std::string ("PathIdentSegment"), [this, &segment] () {
if (segment.is_super_path_seg ())
{
push (Rust::Token::make (SUPER, segment.get_locus ()));
void
TokenCollector::visit (QualifiedPathInExpression &path)
{
- internal_comment (std::string ("QualifiedPathInExpression"), [this,
- &path] () {
+ describe_node (std::string ("QualifiedPathInExpression"), [this, &path] () {
visit (path.get_qualified_path_type ());
for (auto &segment : path.get_segments ())
{
void
TokenCollector::visit (QualifiedPathType &path)
{
- internal_comment (std::string ("QualifiedPathType"), [this, &path] () {
+ describe_node (std::string ("QualifiedPathType"), [this, &path] () {
push (Rust::Token::make (LEFT_ANGLE, path.get_locus ()));
visit (path.get_type ());
if (path.has_as_clause ())
void
TokenCollector::visit (QualifiedPathInType &path)
{
- internal_comment (std::string ("QualifiedPathInType"), [this, &path] () {
+ describe_node (std::string ("QualifiedPathInType"), [this, &path] () {
visit (path.get_qualified_path_type ());
push (Rust::Token::make (SCOPE_RESOLUTION, UNDEF_LOCATION));
void
TokenCollector::visit (LiteralExpr &expr)
{
- internal_comment (std::string ("LiteralExpr"), [this, &expr] () {
+ describe_node (std::string ("LiteralExpr"), [this, &expr] () {
auto lit = expr.get_literal ();
visit (lit, expr.get_locus ());
});
void
TokenCollector::visit (AttrInputLiteral &literal)
{
- internal_comment (std::string ("AttrInputLiteral"), [this, &literal] () {
+ describe_node (std::string ("AttrInputLiteral"), [this, &literal] () {
push (Rust::Token::make (EQUAL, UNDEF_LOCATION));
visit (literal.get_literal ());
});
void
TokenCollector::visit (AttrInputMacro ¯o)
{
- internal_comment (std::string ("AttrInputMacro"), [this, ¯o] () {
+ describe_node (std::string ("AttrInputMacro"), [this, ¯o] () {
push (Rust::Token::make (EQUAL, UNDEF_LOCATION));
visit (macro.get_macro ());
});
void
TokenCollector::visit (MetaItemLitExpr &item)
{
- internal_comment (std::string ("MetaItemLitExpr"), [this, &item] () {
+ describe_node (std::string ("MetaItemLitExpr"), [this, &item] () {
auto lit = item.get_literal ();
visit (lit);
});
void
TokenCollector::visit (MetaItemPathExpr &item)
{
- internal_comment (std::string ("MetaItemPathLit"), [this, &item] () {
+ describe_node (std::string ("MetaItemPathLit"), [this, &item] () {
auto &path = item.get_path ();
auto &expr = item.get_expr ();
visit (path);
void
TokenCollector::visit (BorrowExpr &expr)
{
- internal_comment (std::string ("BorrowExpr"), [this, &expr] () {
+ describe_node (std::string ("BorrowExpr"), [this, &expr] () {
push (Rust::Token::make (AMP, expr.get_locus ()));
if (expr.get_is_double_borrow ())
push (Rust::Token::make (AMP, UNDEF_LOCATION));
void
TokenCollector::visit (DereferenceExpr &expr)
{
- internal_comment (std::string ("DereferenceExpr"), [this, &expr] () {
+ describe_node (std::string ("DereferenceExpr"), [this, &expr] () {
push (Rust::Token::make (ASTERISK, expr.get_locus ()));
visit (expr.get_dereferenced_expr ());
});
void
TokenCollector::visit (ErrorPropagationExpr &expr)
{
- internal_comment (std::string ("ErrorPropagationExpr"), [this, &expr] () {
+ describe_node (std::string ("ErrorPropagationExpr"), [this, &expr] () {
visit (expr.get_propagating_expr ());
push (Rust::Token::make (QUESTION_MARK, expr.get_locus ()));
});
void
TokenCollector::visit (NegationExpr &expr)
{
- internal_comment (std::string ("NegationExpr"), [this, &expr] () {
+ describe_node (std::string ("NegationExpr"), [this, &expr] () {
switch (expr.get_expr_type ())
{
case NegationOperator::NEGATE:
void
TokenCollector::visit (ArithmeticOrLogicalExpr &expr)
{
- internal_comment (std::string ("ArithmeticOrLogicalExpr"), [this, &expr] () {
+ describe_node (std::string ("ArithmeticOrLogicalExpr"), [this, &expr] () {
visit (expr.get_left_expr ());
switch (expr.get_expr_type ())
{
void
TokenCollector::visit (ComparisonExpr &expr)
{
- internal_comment (std::string ("ComparisonExpr"), [this, &expr] () {
+ describe_node (std::string ("ComparisonExpr"), [this, &expr] () {
visit (expr.get_left_expr ());
switch (expr.get_expr_type ())
void
TokenCollector::visit (LazyBooleanExpr &expr)
{
- internal_comment (std::string ("LazyBooleanExpr"), [this, &expr] () {
+ describe_node (std::string ("LazyBooleanExpr"), [this, &expr] () {
visit (expr.get_left_expr ());
switch (expr.get_expr_type ())
void
TokenCollector::visit (TypeCastExpr &expr)
{
- internal_comment (std::string ("TypeCastExpr"), [this, &expr] () {
+ describe_node (std::string ("TypeCastExpr"), [this, &expr] () {
visit (expr.get_casted_expr ());
push (Rust::Token::make (AS, expr.get_locus ()));
visit (expr.get_type_to_cast_to ());
void
TokenCollector::visit (AssignmentExpr &expr)
{
- internal_comment (std::string ("AssignementExpr"), [this, &expr] () {
+ describe_node (std::string ("AssignementExpr"), [this, &expr] () {
expr.visit_lhs (*this);
push (Rust::Token::make (EQUAL, expr.get_locus ()));
expr.visit_rhs (*this);
void
TokenCollector::visit (CompoundAssignmentExpr &expr)
{
- internal_comment (std::string ("CompoundAssignmentExpr"), [this, &expr] () {
+ describe_node (std::string ("CompoundAssignmentExpr"), [this, &expr] () {
visit (expr.get_left_expr ());
switch (expr.get_expr_type ())
void
TokenCollector::visit (GroupedExpr &expr)
{
- internal_comment (std::string ("GroupedExpr"), [this, &expr] () {
+ describe_node (std::string ("GroupedExpr"), [this, &expr] () {
push (Rust::Token::make (LEFT_PAREN, expr.get_locus ()));
visit (expr.get_expr_in_parens ());
push (Rust::Token::make (RIGHT_PAREN, expr.get_locus ()));
void
TokenCollector::visit (ArrayElemsValues &elems)
{
- internal_comment (std::string ("ArraysElemValues"), [this, &elems] () {
+ describe_node (std::string ("ArraysElemValues"), [this, &elems] () {
visit_items_joined_by_separator (elems.get_values (), COMMA);
});
}
void
TokenCollector::visit (ArrayElemsCopied &elems)
{
- internal_comment (std::string ("ArrayElemsCopied"), [this, &elems] () {
+ describe_node (std::string ("ArrayElemsCopied"), [this, &elems] () {
visit (elems.get_elem_to_copy ());
push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION));
visit (elems.get_num_copies ());
void
TokenCollector::visit (ArrayExpr &expr)
{
- internal_comment (std::string ("ArrayExpr"), [this, &expr] () {
+ describe_node (std::string ("ArrayExpr"), [this, &expr] () {
push (Rust::Token::make (LEFT_SQUARE, expr.get_locus ()));
visit (expr.get_array_elems ());
push (Rust::Token::make (RIGHT_SQUARE, UNDEF_LOCATION));
void
TokenCollector::visit (ArrayIndexExpr &expr)
{
- internal_comment (std::string ("ArrayIndexExpr"), [this, &expr] () {
+ describe_node (std::string ("ArrayIndexExpr"), [this, &expr] () {
visit (expr.get_array_expr ());
push (Rust::Token::make (LEFT_SQUARE, expr.get_locus ()));
visit (expr.get_index_expr ());
void
TokenCollector::visit (TupleExpr &expr)
{
- internal_comment (std::string ("TupleExpr"), [this, &expr] () {
+ describe_node (std::string ("TupleExpr"), [this, &expr] () {
visit_items_as_lines (expr.get_outer_attrs ());
push (Rust::Token::make (LEFT_PAREN, expr.get_locus ()));
visit_items_joined_by_separator (expr.get_tuple_elems (), COMMA);
void
TokenCollector::visit (TupleIndexExpr &expr)
{
- internal_comment (std::string ("TupleIndexExpr"), [this, &expr] () {
+ describe_node (std::string ("TupleIndexExpr"), [this, &expr] () {
visit (expr.get_tuple_expr ());
push (Rust::Token::make (DOT, expr.get_locus ()));
push (Rust::Token::make_int (UNDEF_LOCATION,
void
TokenCollector::visit (StructExprStruct &expr)
{
- internal_comment (std::string ("StructExprStruct"),
- [this, &expr] () { visit (expr.get_struct_name ()); });
+ describe_node (std::string ("StructExprStruct"),
+ [this, &expr] () { visit (expr.get_struct_name ()); });
}
void
TokenCollector::visit (StructExprFieldIdentifier &expr)
{
- internal_comment (std::string ("StructExprFieldIdentifier"), [this,
- &expr] () {
+ describe_node (std::string ("StructExprFieldIdentifier"), [this, &expr] () {
visit_items_as_lines (expr.get_outer_attrs ());
auto id = expr.get_field_name ().as_string ();
push (Rust::Token::make_identifier (expr.get_locus (), std::move (id)));
void
TokenCollector::visit (StructExprFieldIdentifierValue &expr)
{
- internal_comment (std::string ("StructExprFieldIdentifierValue"), [this,
- &expr] () {
+ describe_node (std::string ("StructExprFieldIdentifierValue"), [this,
+ &expr] () {
visit_items_as_lines (expr.get_outer_attrs ());
auto id = expr.get_field_name ();
push (Rust::Token::make_identifier (expr.get_locus (), std::move (id)));
void
TokenCollector::visit (StructExprFieldIndexValue &expr)
{
- internal_comment (std::string ("StructExprFieldIndexValue"), [this,
- &expr] () {
+ describe_node (std::string ("StructExprFieldIndexValue"), [this, &expr] () {
visit_items_as_lines (expr.get_outer_attrs ());
push (Rust::Token::make_int (expr.get_locus (),
std::to_string (expr.get_index ())));
void
TokenCollector::visit (StructBase &base)
{
- internal_comment (std::string ("StructBase"), [this, &base] () {
+ describe_node (std::string ("StructBase"), [this, &base] () {
push (Rust::Token::make (DOT_DOT, UNDEF_LOCATION));
visit (base.get_base_struct ());
});
void
TokenCollector::visit (StructExprStructFields &expr)
{
- internal_comment (std::string ("StructExprStructFields"), [this, &expr] () {
+ describe_node (std::string ("StructExprStructFields"), [this, &expr] () {
visit (expr.get_struct_name ());
push (Rust::Token::make (LEFT_CURLY, expr.get_locus ()));
visit_items_joined_by_separator (expr.get_fields (), COMMA);
void
TokenCollector::visit (CallExpr &expr)
{
- internal_comment (std::string ("CallExpr"), [this, &expr] () {
+ describe_node (std::string ("CallExpr"), [this, &expr] () {
visit (expr.get_function_expr ());
push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));
void
TokenCollector::visit (MethodCallExpr &expr)
{
- internal_comment (std::string ("MethodCallExpr"), [this, &expr] () {
+ describe_node (std::string ("MethodCallExpr"), [this, &expr] () {
visit (expr.get_receiver_expr ());
push (Rust::Token::make (DOT, expr.get_locus ()));
visit (expr.get_method_name ());
void
TokenCollector::visit (FieldAccessExpr &expr)
{
- internal_comment (std::string ("FieldAccessExpr"), [this, &expr] () {
+ describe_node (std::string ("FieldAccessExpr"), [this, &expr] () {
visit (expr.get_receiver_expr ());
push (Rust::Token::make (DOT, expr.get_locus ()));
auto field_name = expr.get_field_name ().as_string ();
void
TokenCollector::visit (ClosureParam ¶m)
{
- internal_comment (std::string ("ClosureParam"), [this, ¶m] () {
+ describe_node (std::string ("ClosureParam"), [this, ¶m] () {
visit_items_as_lines (param.get_outer_attrs ());
visit (param.get_pattern ());
if (param.has_type_given ())
void
TokenCollector::visit_closure_common (ClosureExpr &expr)
{
- internal_comment (std::string ("ClosureExpr"), [this, &expr] () {
+ describe_node (std::string ("ClosureExpr"), [this, &expr] () {
if (expr.get_has_move ())
{
push (Rust::Token::make (MOVE, expr.get_locus ()));
void
TokenCollector::visit (ClosureExprInner &expr)
{
- internal_comment (std::string ("ClosureExprInner"), [this, &expr] () {
+ describe_node (std::string ("ClosureExprInner"), [this, &expr] () {
visit_closure_common (expr);
visit (expr.get_definition_expr ());
});
void
TokenCollector::visit (BlockExpr &expr)
{
- internal_comment (std::string ("BlockExpr"), [this, &expr] () {
+ describe_node (std::string ("BlockExpr"), [this, &expr] () {
visit_items_as_lines (expr.get_outer_attrs ());
push (Rust::Token::make (LEFT_CURLY, expr.get_locus ()));
newline ();
void
TokenCollector::visit (ClosureExprInnerTyped &expr)
{
- internal_comment (std::string ("ClosureExprInnerTyped"), [this, &expr] () {
+ describe_node (std::string ("ClosureExprInnerTyped"), [this, &expr] () {
visit_closure_common (expr);
push (Rust::Token::make (RETURN_TYPE, expr.get_locus ()));
visit (expr.get_return_type ());
void
TokenCollector::visit (ContinueExpr &expr)
{
- internal_comment (std::string ("ContinueExpr"), [this, &expr] () {
+ describe_node (std::string ("ContinueExpr"), [this, &expr] () {
push (Rust::Token::make (CONTINUE, expr.get_locus ()));
if (expr.has_label ())
visit (expr.get_label_unchecked ());
void
TokenCollector::visit (BreakExpr &expr)
{
- internal_comment (std::string ("BreakExpr"), [this, &expr] () {
+ describe_node (std::string ("BreakExpr"), [this, &expr] () {
push (Rust::Token::make (BREAK, expr.get_locus ()));
if (expr.has_label ())
visit (expr.get_label_unchecked ());
void
TokenCollector::visit (RangeFromToExpr &expr)
{
- internal_comment (std::string ("RangeFromToExpr"), [this, &expr] () {
+ describe_node (std::string ("RangeFromToExpr"), [this, &expr] () {
visit (expr.get_from_expr ());
push (Rust::Token::make (DOT_DOT, expr.get_locus ()));
visit (expr.get_to_expr ());
void
TokenCollector::visit (RangeFromExpr &expr)
{
- internal_comment (std::string ("RangeFromExpr"), [this, &expr] () {
+ describe_node (std::string ("RangeFromExpr"), [this, &expr] () {
visit (expr.get_from_expr ());
push (Rust::Token::make (DOT_DOT, expr.get_locus ()));
});
void
TokenCollector::visit (RangeToExpr &expr)
{
- internal_comment (std::string ("RangeToExpr"), [this, &expr] () {
+ describe_node (std::string ("RangeToExpr"), [this, &expr] () {
push (Rust::Token::make (DOT_DOT, expr.get_locus ()));
visit (expr.get_to_expr ());
});
void
TokenCollector::visit (RangeFullExpr &expr)
{
- internal_comment (std::string ("RangeFullExpr"), [this, &expr] () {
+ describe_node (std::string ("RangeFullExpr"), [this, &expr] () {
push (Rust::Token::make (DOT_DOT, expr.get_locus ()));
});
}
void
TokenCollector::visit (RangeFromToInclExpr &expr)
{
- internal_comment (std::string ("RangeFromToInclExpr"), [this, &expr] () {
+ describe_node (std::string ("RangeFromToInclExpr"), [this, &expr] () {
visit (expr.get_from_expr ());
push (Rust::Token::make (DOT_DOT_EQ, expr.get_locus ()));
visit (expr.get_to_expr ());
void
TokenCollector::visit (RangeToInclExpr &expr)
{
- internal_comment (std::string ("RangeToInclExpr"), [this, &expr] () {
+ describe_node (std::string ("RangeToInclExpr"), [this, &expr] () {
push (Rust::Token::make (DOT_DOT_EQ, expr.get_locus ()));
visit (expr.get_to_expr ());
});
void
TokenCollector::visit (BoxExpr &expr)
{
- internal_comment (std::string ("BoxExpr"), [this, &expr] () {
+ describe_node (std::string ("BoxExpr"), [this, &expr] () {
push (Rust::Token::make (BOX, expr.get_locus ()));
visit (expr.get_boxed_expr ());
});
void
TokenCollector::visit (ReturnExpr &expr)
{
- internal_comment (std::string ("ReturnExpr"), [this, &expr] () {
+ describe_node (std::string ("ReturnExpr"), [this, &expr] () {
push (Rust::Token::make (RETURN_KW, expr.get_locus ()));
if (expr.has_returned_expr ())
visit (expr.get_returned_expr ());
void
TokenCollector::visit (UnsafeBlockExpr &expr)
{
- internal_comment (std::string ("UnsafeBlockExpr"), [this, &expr] () {
+ describe_node (std::string ("UnsafeBlockExpr"), [this, &expr] () {
push (Rust::Token::make (UNSAFE, expr.get_locus ()));
visit (expr.get_block_expr ());
});
void
TokenCollector::visit (LoopLabel &label)
{
- internal_comment (std::string ("LoopLabel"), [this, &label] () {
+ describe_node (std::string ("LoopLabel"), [this, &label] () {
visit (label.get_lifetime ());
push (Rust::Token::make (COLON, label.get_locus ()));
});
void
TokenCollector::visit_loop_common (BaseLoopExpr &expr)
{
- internal_comment (std::string ("BaseLoopExpr"), [this, &expr] () {
+ describe_node (std::string ("BaseLoopExpr"), [this, &expr] () {
if (expr.has_loop_label ())
visit (expr.get_loop_label ());
});
void
TokenCollector::visit (LoopExpr &expr)
{
- internal_comment (std::string ("LoopExpr"), [this, &expr] () {
+ describe_node (std::string ("LoopExpr"), [this, &expr] () {
visit_loop_common (expr);
push (Rust::Token::make (LOOP, expr.get_locus ()));
visit (expr.get_loop_block ());
void
TokenCollector::visit (WhileLoopExpr &expr)
{
- internal_comment (std::string ("WhileLoopExpr"), [this, &expr] () {
+ describe_node (std::string ("WhileLoopExpr"), [this, &expr] () {
visit_loop_common (expr);
push (Rust::Token::make (WHILE, expr.get_locus ()));
visit (expr.get_predicate_expr ());
void
TokenCollector::visit (WhileLetLoopExpr &expr)
{
- internal_comment (std::string ("WhileLetLoopExpr"), [this, &expr] () {
+ describe_node (std::string ("WhileLetLoopExpr"), [this, &expr] () {
visit_loop_common (expr);
push (Rust::Token::make (WHILE, expr.get_locus ()));
push (Rust::Token::make (LET, UNDEF_LOCATION));
void
TokenCollector::visit (ForLoopExpr &expr)
{
- internal_comment (std::string ("ForLoopExpr"), [this, &expr] () {
+ describe_node (std::string ("ForLoopExpr"), [this, &expr] () {
visit_loop_common (expr);
push (Rust::Token::make (FOR, expr.get_locus ()));
visit (expr.get_pattern ());
void
TokenCollector::visit (IfExpr &expr)
{
- internal_comment (std::string ("IfExpr"), [this, &expr] () {
+ describe_node (std::string ("IfExpr"), [this, &expr] () {
push (Rust::Token::make (IF, expr.get_locus ()));
visit (expr.get_condition_expr ());
void
TokenCollector::visit (IfExprConseqElse &expr)
{
- internal_comment (std::string ("IfExprConseqElse"), [this, &expr] () {
+ describe_node (std::string ("IfExprConseqElse"), [this, &expr] () {
visit (static_cast<IfExpr &> (expr));
indentation ();
push (Rust::Token::make (ELSE, expr.get_locus ()));
void
TokenCollector::visit (IfLetExpr &expr)
{
- internal_comment (std::string ("IfLetExpr"), [this, &expr] () {
+ describe_node (std::string ("IfLetExpr"), [this, &expr] () {
push (Rust::Token::make (IF, expr.get_locus ()));
push (Rust::Token::make (LET, UNDEF_LOCATION));
for (auto &pattern : expr.get_patterns ())
void
TokenCollector::visit (IfLetExprConseqElse &expr)
{
- internal_comment (std::string ("IfLetExprConseqElse"), [this, &expr] () {
+ describe_node (std::string ("IfLetExprConseqElse"), [this, &expr] () {
visit (static_cast<IfLetExpr &> (expr));
indentation ();
push (Rust::Token::make (ELSE, expr.get_locus ()));
void
TokenCollector::visit (MatchArm &arm)
{
- internal_comment (std::string ("MatchArm"), [this, &arm] () {
+ describe_node (std::string ("MatchArm"), [this, &arm] () {
visit_items_as_lines (arm.get_outer_attrs ());
for (auto &pattern : arm.get_patterns ())
{
void
TokenCollector::visit (MatchCase &match_case)
{
- internal_comment (std::string ("MatchCase"), [this, &match_case] () {
+ describe_node (std::string ("MatchCase"), [this, &match_case] () {
indentation ();
visit (match_case.get_arm ());
push (Rust::Token::make (MATCH_ARROW, UNDEF_LOCATION));
void
TokenCollector::visit (MatchExpr &expr)
{
- internal_comment (std::string ("MatchExpr"), [this, &expr] () {
+ describe_node (std::string ("MatchExpr"), [this, &expr] () {
push (Rust::Token::make (MATCH_KW, expr.get_locus ()));
visit (expr.get_scrutinee_expr ());
push (Rust::Token::make (LEFT_CURLY, UNDEF_LOCATION));
void
TokenCollector::visit (AwaitExpr &expr)
{
- internal_comment (std::string ("AwaitExpr"), [this, &expr] () {
+ describe_node (std::string ("AwaitExpr"), [this, &expr] () {
visit (expr.get_awaited_expr ());
push (Rust::Token::make (DOT, expr.get_locus ()));
// TODO: Check status of await keyword (Context dependant ?)
void
TokenCollector::visit (AsyncBlockExpr &expr)
{
- internal_comment (std::string ("AsyncBlockExpr"), [this, &expr] () {
+ describe_node (std::string ("AsyncBlockExpr"), [this, &expr] () {
push (Rust::Token::make (ASYNC, expr.get_locus ()));
if (expr.get_has_move ())
push (Rust::Token::make (MOVE, UNDEF_LOCATION));
// IDENTIFIER( : TypeParamBounds? )? ( = Type )?
// TypeParamBounds :
// TypeParamBound ( + TypeParamBound )* +?
- internal_comment (std::string ("TypeParam"), [this, ¶m] () {
+ describe_node (std::string ("TypeParam"), [this, ¶m] () {
visit_items_as_lines (param.get_outer_attrs ());
auto id = param.get_type_representation ().as_string ();
push (Rust::Token::make_identifier (param.get_locus (), std::move (id)));
// WhereClauseItem :
// LifetimeWhereClauseItem
// | TypeBoundWhereClauseItem
- internal_comment (std::string ("WhereClause"), [this, &rule] () {
+ describe_node (std::string ("WhereClause"), [this, &rule] () {
push (Rust::Token::make (WHERE, UNDEF_LOCATION));
newline ();
increment_indentation ();
// LifetimeBounds :
// ( Lifetime + )* Lifetime?
- internal_comment (std::string ("LifetimeWhereClauseItem"), [this, &item] () {
+ describe_node (std::string ("LifetimeWhereClauseItem"), [this, &item] () {
visit (item.get_lifetime ());
push (Rust::Token::make (COLON, UNDEF_LOCATION));
visit_items_joined_by_separator (item.get_lifetime_bounds (), PLUS);
// TypeParamBound :
// Lifetime | TraitBound
- internal_comment (std::string ("TypeBoundWhereClauseItem"), [this, &item] () {
+ describe_node (std::string ("TypeBoundWhereClauseItem"), [this, &item] () {
if (item.has_for_lifetimes ())
visit (item.get_for_lifetimes ());
// InnerAttribute*
// Item*
// }
- internal_comment (std::string ("Module"), [this, &module] () {
+ describe_node (std::string ("Module"), [this, &module] () {
visit_items_as_lines (module.get_outer_attrs ());
visit (module.get_visibility ());
auto name = module.get_name ().as_string ();
void
TokenCollector::visit (ExternCrate &crate)
{
- internal_comment (std::string ("ExternCrate"), [this, &crate] () {
+ describe_node (std::string ("ExternCrate"), [this, &crate] () {
visit_items_as_lines (crate.get_outer_attrs ());
push (Rust::Token::make (EXTERN_KW, crate.get_locus ()));
push (Rust::Token::make (CRATE, UNDEF_LOCATION));
void
TokenCollector::visit (UseTreeGlob &use_tree)
{
- internal_comment (std::string ("UseTreeGlob"), [this, &use_tree] () {
+ describe_node (std::string ("UseTreeGlob"), [this, &use_tree] () {
switch (use_tree.get_glob_type ())
{
case UseTreeGlob::PathType::PATH_PREFIXED:
void
TokenCollector::visit (UseTreeList &use_tree)
{
- internal_comment (std::string ("UseTreeList"), [this, &use_tree] () {
+ describe_node (std::string ("UseTreeList"), [this, &use_tree] () {
switch (use_tree.get_path_type ())
{
case UseTreeList::PathType::PATH_PREFIXED:
void
TokenCollector::visit (UseTreeRebind &use_tree)
{
- internal_comment (std::string ("UseTreeRebind"), [this, &use_tree] () {
+ describe_node (std::string ("UseTreeRebind"), [this, &use_tree] () {
auto path = use_tree.get_path ();
visit (path);
switch (use_tree.get_new_bind_type ())
void
TokenCollector::visit (UseDeclaration &decl)
{
- internal_comment (std::string ("UseDeclaration"), [this, &decl] () {
+ describe_node (std::string ("UseDeclaration"), [this, &decl] () {
visit_items_as_lines (decl.get_outer_attrs ());
push (Rust::Token::make (USE, decl.get_locus ()));
visit (*decl.get_tree ());
// ( FunctionParameters? )
// FunctionReturnType? WhereClause?
// ( BlockExpression | ; )
- internal_comment (std::string ("Function"), [this, &function] () {
+ describe_node (std::string ("Function"), [this, &function] () {
visit_items_as_lines (function.get_outer_attrs ());
visit (function.get_visibility ());
// Visibility? type IDENTIFIER GenericParams? WhereClause? = Type;
// Note: Associated types are handled by `AST::TraitItemType`.
- internal_comment (std::string ("TypeAlias"), [this, &type_alias] () {
+ describe_node (std::string ("TypeAlias"), [this, &type_alias] () {
visit_items_as_lines (type_alias.get_outer_attrs ());
if (type_alias.has_visibility ())
visit (type_alias.get_visibility ());
void
TokenCollector::visit (StructStruct &struct_item)
{
- internal_comment (std::string ("StructStruct"), [this, &struct_item] () {
+ describe_node (std::string ("StructStruct"), [this, &struct_item] () {
visit_items_as_lines (struct_item.get_outer_attrs ());
if (struct_item.has_visibility ())
visit (struct_item.get_visibility ());
void
TokenCollector::visit (TupleStruct &tuple_struct)
{
- internal_comment (std::string ("TupleStruct"), [this, &tuple_struct] () {
+ describe_node (std::string ("TupleStruct"), [this, &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_KW, tuple_struct.get_locus ()));
void
TokenCollector::visit (EnumItem &item)
{
- internal_comment (std::string ("EnumItem"), [this, &item] () {
+ describe_node (std::string ("EnumItem"), [this, &item] () {
visit_items_as_lines (item.get_outer_attrs ());
auto id = item.get_identifier ().as_string ();
push (Rust::Token::make_identifier (item.get_locus (), std::move (id)));
void
TokenCollector::visit (EnumItemTuple &item)
{
- internal_comment (std::string ("EnumItemTuple"), [this, &item] () {
+ describe_node (std::string ("EnumItemTuple"), [this, &item] () {
auto id = item.get_identifier ().as_string ();
push (Rust::Token::make_identifier (item.get_locus (), std::move (id)));
push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));
void
TokenCollector::visit (EnumItemStruct &item)
{
- internal_comment (std::string ("EnumItemStruct"), [this, &item] () {
+ describe_node (std::string ("EnumItemStruct"), [this, &item] () {
auto id = item.get_identifier ().as_string ();
push (Rust::Token::make_identifier (item.get_locus (), std::move (id)));
visit_items_as_block (item.get_struct_fields (),
void
TokenCollector::visit (EnumItemDiscriminant &item)
{
- internal_comment (std::string ("EnumItemDiscriminant"), [this, &item] () {
+ describe_node (std::string ("EnumItemDiscriminant"), [this, &item] () {
auto id = item.get_identifier ().as_string ();
push (Rust::Token::make_identifier (item.get_locus (), std::move (id)));
push (Rust::Token::make (EQUAL, UNDEF_LOCATION));
void
TokenCollector::visit (Enum &enumeration)
{
- internal_comment (std::string ("Enum"), [this, &enumeration] () {
+ describe_node (std::string ("Enum"), [this, &enumeration] () {
visit_items_as_lines (enumeration.get_outer_attrs ());
if (enumeration.has_visibility ())
visit (enumeration.get_visibility ());
void
TokenCollector::visit (Union &union_item)
{
- internal_comment (std::string ("Union"), [this, &union_item] () {
+ describe_node (std::string ("Union"), [this, &union_item] () {
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 (),
void
TokenCollector::visit (ConstantItem &item)
{
- internal_comment (std::string ("ConstantItem"), [this, &item] () {
+ describe_node (std::string ("ConstantItem"), [this, &item] () {
visit_items_as_lines (item.get_outer_attrs ());
push (Rust::Token::make (CONST, item.get_locus ()));
if (item.is_unnamed ())
void
TokenCollector::visit (StaticItem &item)
{
- internal_comment (std::string ("StaticItem"), [this, &item] () {
+ describe_node (std::string ("StaticItem"), [this, &item] () {
visit_items_as_lines (item.get_outer_attrs ());
push (Rust::Token::make (STATIC_KW, item.get_locus ()));
if (item.is_mutable ())
void
TokenCollector::visit (SelfParam ¶m)
{
- internal_comment (std::string ("SelfParam"), [this, ¶m] () {
+ describe_node (std::string ("SelfParam"), [this, ¶m] () {
if (param.get_has_ref ())
{
push (Rust::Token::make (AMP, UNDEF_LOCATION));
void
TokenCollector::visit (TraitItemType &item)
{
- internal_comment (std::string ("TraitItemType"), [this, &item] () {
+ describe_node (std::string ("TraitItemType"), [this, &item] () {
visit_items_as_lines (item.get_outer_attrs ());
auto id = item.get_identifier ().as_string ();
indentation ();
void
TokenCollector::visit (Trait &trait)
{
- internal_comment (std::string ("Trait"), [this, &trait] () {
+ describe_node (std::string ("Trait"), [this, &trait] () {
for (auto &attr : trait.get_outer_attrs ())
{
visit (attr);
void
TokenCollector::visit (InherentImpl &impl)
{
- internal_comment (std::string ("InherentImpl"), [this, &impl] () {
+ describe_node (std::string ("InherentImpl"), [this, &impl] () {
visit_items_as_lines (impl.get_outer_attrs ());
push (Rust::Token::make (IMPL, impl.get_locus ()));
visit (impl.get_generic_params ());
void
TokenCollector::visit (TraitImpl &impl)
{
- internal_comment (std::string ("TraitImpl"), [this, &impl] () {
+ describe_node (std::string ("TraitImpl"), [this, &impl] () {
visit_items_as_lines (impl.get_outer_attrs ());
push (Rust::Token::make (IMPL, impl.get_locus ()));
visit (impl.get_generic_params ());
void
TokenCollector::visit (ExternalTypeItem &type)
{
- internal_comment (std::string ("ExternalTypeItem"), [this, &type] () {
+ describe_node (std::string ("ExternalTypeItem"), [this, &type] () {
visit (type.get_visibility ());
auto id = type.get_identifier ().as_string ();
void
TokenCollector::visit (ExternalStaticItem &item)
{
- internal_comment (std::string ("ExternalStaticItem"), [this, &item] () {
+ describe_node (std::string ("ExternalStaticItem"), [this, &item] () {
auto id = item.get_identifier ().as_string ();
visit_items_as_lines (item.get_outer_attrs ());
if (item.has_visibility ())
void
TokenCollector::visit (ExternBlock &block)
{
- internal_comment (std::string ("ExternBlock"), [this, &block] () {
+ describe_node (std::string ("ExternBlock"), [this, &block] () {
visit_items_as_lines (block.get_outer_attrs ());
push (Rust::Token::make (EXTERN_KW, block.get_locus ()));
void
TokenCollector::visit (MacroMatchFragment &match)
{
- internal_comment (std::string ("MacroMatchFragment"), [this, &match] () {
+ describe_node (std::string ("MacroMatchFragment"), [this, &match] () {
auto id = match.get_ident ().as_string ();
auto frag_spec = match.get_frag_spec ().as_string ();
push (Rust::Token::make (DOLLAR_SIGN, UNDEF_LOCATION));
void
TokenCollector::visit (MacroMatchRepetition &repetition)
{
- internal_comment (std::string ("MacroMatchRepetition"), [this,
- &repetition] () {
+ describe_node (std::string ("MacroMatchRepetition"), [this, &repetition] () {
push (Rust::Token::make (DOLLAR_SIGN, UNDEF_LOCATION));
push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));
void
TokenCollector::visit (MacroMatcher &matcher)
{
- internal_comment (std::string ("MacroMatcher"), [this, &matcher] () {
+ describe_node (std::string ("MacroMatcher"), [this, &matcher] () {
auto delimiters = get_delimiters (matcher.get_delim_type ());
push (Rust::Token::make (delimiters.first, UNDEF_LOCATION));
void
TokenCollector::visit (MacroRule &rule)
{
- internal_comment (std::string ("MacroRule"), [this, &rule] () {
+ describe_node (std::string ("MacroRule"), [this, &rule] () {
visit (rule.get_matcher ());
push (Rust::Token::make (MATCH_ARROW, rule.get_locus ()));
visit (rule.get_transcriber ().get_token_tree ());
void
TokenCollector::visit (MacroRulesDefinition &rules_def)
{
- internal_comment (std::string ("MacroRulesDefinition"), [this,
- &rules_def] () {
+ describe_node (std::string ("MacroRulesDefinition"), [this, &rules_def] () {
for (auto &outer_attr : rules_def.get_outer_attrs ())
visit (outer_attr);
void
TokenCollector::visit (MacroInvocation &invocation)
{
- internal_comment (std::string ("MacroInvocation"), [this, &invocation] () {
+ describe_node (std::string ("MacroInvocation"), [this, &invocation] () {
auto data = invocation.get_invoc_data ();
visit (data.get_path ());
push (Rust::Token::make (EXCLAM, UNDEF_LOCATION));
void
TokenCollector::visit (MetaItemPath &item)
{
- internal_comment (std::string ("MetaItemPath"), [this, &item] () {
+ describe_node (std::string ("MetaItemPath"), [this, &item] () {
auto path = item.to_path_item ();
visit (path);
});
void
TokenCollector::visit (MetaItemSeq &item)
{
- internal_comment (std::string ("MetaItemSeq"), [this, &item] () {
+ describe_node (std::string ("MetaItemSeq"), [this, &item] () {
visit (item.get_path ());
// TODO: Double check this, there is probably a mistake.
push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));
void
TokenCollector::visit (MetaWord &word)
{
- internal_comment (std::string ("MetaWord"), [this, &word] () {
+ describe_node (std::string ("MetaWord"), [this, &word] () {
auto id = word.get_ident ().as_string ();
push (Rust::Token::make_identifier (word.get_locus (), std::move (id)));
void
TokenCollector::visit (MetaNameValueStr &name)
{
- internal_comment (std::string ("MetaNameValueStr"), [this, &name] () {
+ describe_node (std::string ("MetaNameValueStr"), [this, &name] () {
auto pair = name.get_name_value_pair ();
auto id = std::get<0> (pair).as_string ();
auto value = std::get<1> (pair);
void
TokenCollector::visit (MetaListPaths &list)
{
- internal_comment (std::string ("MetaListPath"), [this, &list] () {
+ describe_node (std::string ("MetaListPath"), [this, &list] () {
auto id = list.get_ident ().as_string ();
push (Rust::Token::make_identifier (list.get_locus (), std::move (id)));
void
TokenCollector::visit (MetaListNameValueStr &list)
{
- internal_comment (std::string ("MetaListNameValueStr"), [this, &list] () {
+ describe_node (std::string ("MetaListNameValueStr"), [this, &list] () {
auto id = list.get_ident ().as_string ();
push (Rust::Token::make_identifier (list.get_locus (), std::move (id)));
void
TokenCollector::visit (LiteralPattern &pattern)
{
- internal_comment (std::string ("LiteralPattern"), [this, &pattern] () {
+ describe_node (std::string ("LiteralPattern"), [this, &pattern] () {
visit (pattern.get_literal (), pattern.get_locus ());
});
}
void
TokenCollector::visit (IdentifierPattern &pattern)
{
- internal_comment (std::string ("IdentifierPattern"), [this, &pattern] () {
+ describe_node (std::string ("IdentifierPattern"), [this, &pattern] () {
if (pattern.get_is_ref ())
{
push (Rust::Token::make (REF, pattern.get_locus ()));
void
TokenCollector::visit (WildcardPattern &pattern)
{
- internal_comment (std::string ("WildcardPattern"), [this, &pattern] () {
+ describe_node (std::string ("WildcardPattern"), [this, &pattern] () {
push (Rust::Token::make (UNDERSCORE, pattern.get_locus ()));
});
}
void
TokenCollector::visit (RestPattern &pattern)
{
- internal_comment (std::string ("RestPattern"), [this, &pattern] () {
+ describe_node (std::string ("RestPattern"), [this, &pattern] () {
push (Rust::Token::make (DOT_DOT, pattern.get_locus ()));
});
}
void
TokenCollector::visit (RangePatternBoundLiteral &pattern)
{
- internal_comment (std::string ("RangePatternBoundLiteral"), [this,
- &pattern] () {
+ describe_node (std::string ("RangePatternBoundLiteral"), [this, &pattern] () {
if (pattern.get_has_minus ())
{
push (Rust::Token::make (MINUS, pattern.get_locus ()));
void
TokenCollector::visit (RangePatternBoundPath &pattern)
{
- internal_comment (std::string ("RangePatternBoundPath"),
- [this, &pattern] () { visit (pattern.get_path ()); });
+ describe_node (std::string ("RangePatternBoundPath"),
+ [this, &pattern] () { visit (pattern.get_path ()); });
}
void
TokenCollector::visit (RangePatternBoundQualPath &pattern)
{
- internal_comment (std::string ("RangePatternBoundQualPath"),
- [this, &pattern] () {
- visit (pattern.get_qualified_path ());
- });
+ describe_node (std::string ("RangePatternBoundQualPath"),
+ [this, &pattern] () {
+ visit (pattern.get_qualified_path ());
+ });
}
void
TokenCollector::visit (RangePattern &pattern)
{
- internal_comment (std::string ("RangePattern"), [this, &pattern] () {
+ describe_node (std::string ("RangePattern"), [this, &pattern] () {
if (pattern.get_has_lower_bound () && pattern.get_has_upper_bound ())
{
visit (pattern.get_lower_bound ());
TokenCollector::visit (ReferencePattern &pattern)
{
- internal_comment (std::string ("ReferencePattern"), [this, &pattern] () {
+ describe_node (std::string ("ReferencePattern"), [this, &pattern] () {
if (pattern.is_double_reference ())
{
push (Rust::Token::make (LOGICAL_AND, pattern.get_locus ()));
void
TokenCollector::visit (StructPatternFieldTuplePat &pattern)
{
- internal_comment (std::string ("StructPatternFieldTuplePat"), [this,
- &pattern] () {
+ describe_node (std::string ("StructPatternFieldTuplePat"), [this,
+ &pattern] () {
visit_items_as_lines (pattern.get_outer_attrs ());
push (Rust::Token::make_int (pattern.get_locus (),
std::to_string (pattern.get_index ())));
void
TokenCollector::visit (StructPatternFieldIdentPat &pattern)
{
- internal_comment (std::string ("StructPatternFieldIdentPat"), [this,
- &pattern] () {
+ describe_node (std::string ("StructPatternFieldIdentPat"), [this,
+ &pattern] () {
visit_items_as_lines (pattern.get_outer_attrs ());
auto id = pattern.get_identifier ().as_string ();
void
TokenCollector::visit (StructPatternFieldIdent &pattern)
{
- internal_comment (std::string ("StructPatternFieldIdent"), [this,
- &pattern] () {
+ describe_node (std::string ("StructPatternFieldIdent"), [this, &pattern] () {
visit_items_as_lines (pattern.get_outer_attrs ());
if (pattern.is_ref ())
push (Rust::Token::make (REF, UNDEF_LOCATION));
void
TokenCollector::visit (StructPattern &pattern)
{
- internal_comment (std::string ("StructPattern"), [this, &pattern] () {
+ describe_node (std::string ("StructPattern"), [this, &pattern] () {
visit (pattern.get_path ());
push (Rust::Token::make (LEFT_CURLY, pattern.get_locus ()));
auto elems = pattern.get_struct_pattern_elems ();
void
TokenCollector::visit (TupleStructItemsNoRest &pattern)
{
- internal_comment (std::string ("TupleStructItemsNoRange"),
- [this, &pattern] () {
- visit_items_joined_by_separator (pattern.get_patterns ());
- });
+ describe_node (std::string ("TupleStructItemsNoRange"), [this, &pattern] () {
+ visit_items_joined_by_separator (pattern.get_patterns ());
+ });
}
void
TokenCollector::visit (TupleStructItemsHasRest &pattern)
{
- internal_comment (std::string ("TupleStructItemsRange"), [this, &pattern] () {
+ describe_node (std::string ("TupleStructItemsRange"), [this, &pattern] () {
for (auto &lower : pattern.get_lower_patterns ())
{
visit (lower);
void
TokenCollector::visit (TupleStructPattern &pattern)
{
- internal_comment (std::string ("TupleStructPattern"), [this, &pattern] () {
+ describe_node (std::string ("TupleStructPattern"), [this, &pattern] () {
visit (pattern.get_path ());
push (Rust::Token::make (LEFT_PAREN, pattern.get_locus ()));
visit (pattern.get_items ());
void
TokenCollector::visit (TuplePatternItemsNoRest &pattern)
{
- internal_comment (std::string ("TuplePatternItemsMultiple"), [this,
- &pattern] () {
+ describe_node (std::string ("TuplePatternItemsMultiple"), [this,
+ &pattern] () {
visit_items_joined_by_separator (pattern.get_patterns (), COMMA);
});
}
void
TokenCollector::visit (TuplePatternItemsHasRest &pattern)
{
- internal_comment (std::string ("TuplePatternItemsRanged"),
- [this, &pattern] () {
- for (auto &lower : pattern.get_lower_patterns ())
- {
- visit (lower);
- }
- push (Rust::Token::make (DOT_DOT, UNDEF_LOCATION));
- for (auto &upper : pattern.get_lower_patterns ())
- {
- visit (upper);
- }
- });
+ describe_node (std::string ("TuplePatternItemsRanged"), [this, &pattern] () {
+ for (auto &lower : pattern.get_lower_patterns ())
+ {
+ visit (lower);
+ }
+ push (Rust::Token::make (DOT_DOT, UNDEF_LOCATION));
+ for (auto &upper : pattern.get_lower_patterns ())
+ {
+ visit (upper);
+ }
+ });
}
void
TokenCollector::visit (TuplePattern &pattern)
{
- internal_comment (std::string ("TuplePattern"), [this, &pattern] () {
+ describe_node (std::string ("TuplePattern"), [this, &pattern] () {
push (Rust::Token::make (LEFT_PAREN, pattern.get_locus ()));
visit (pattern.get_items ());
push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
void
TokenCollector::visit (GroupedPattern &pattern)
{
- internal_comment (std::string ("GroupedPattern"), [this, &pattern] () {
+ describe_node (std::string ("GroupedPattern"), [this, &pattern] () {
push (Rust::Token::make (LEFT_PAREN, pattern.get_locus ()));
visit (pattern.get_pattern_in_parens ());
push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
void
TokenCollector::visit (SlicePattern &pattern)
{
- internal_comment (std::string ("SlicePattern"), [this, &pattern] () {
+ describe_node (std::string ("SlicePattern"), [this, &pattern] () {
push (Rust::Token::make (LEFT_SQUARE, pattern.get_locus ()));
visit (pattern.get_items ());
push (Rust::Token::make (RIGHT_SQUARE, UNDEF_LOCATION));
void
TokenCollector::visit (AltPattern &pattern)
{
- internal_comment (std::string ("AltPattern"), [this, &pattern] () {
+ describe_node (std::string ("AltPattern"), [this, &pattern] () {
visit_items_joined_by_separator (pattern.get_alts (), PIPE);
});
}
void
TokenCollector::visit (LetStmt &stmt)
{
- internal_comment (std::string ("LetStmt"), [this, &stmt] () {
+ describe_node (std::string ("LetStmt"), [this, &stmt] () {
push (Rust::Token::make (LET, stmt.get_locus ()));
auto &pattern = stmt.get_pattern ();
visit (pattern);
void
TokenCollector::visit (ExprStmt &stmt)
{
- internal_comment (std::string ("ExprStmt"), [this, &stmt] () {
+ describe_node (std::string ("ExprStmt"), [this, &stmt] () {
visit (stmt.get_expr ());
if (stmt.is_semicolon_followed ())
// Syntax:
// ?? ForLifetimes? TypePath
// | ( ?? ForLifetimes? TypePath )
- internal_comment (std::string ("TraitBound"), [this, &bound] () {
+ describe_node (std::string ("TraitBound"), [this, &bound] () {
if (bound.has_opening_question_mark ())
push (Rust::Token::make (QUESTION_MARK, bound.get_locus ()));
// impl TypeParamBounds
// TypeParamBounds :
// TypeParamBound ( + TypeParamBound )* +?
- internal_comment (std::string ("ImplTraitType"), [this, &type] () {
+ describe_node (std::string ("ImplTraitType"), [this, &type] () {
push (Rust::Token::make (IMPL, type.get_locus ()));
visit_items_joined_by_separator (type.get_type_param_bounds (), PLUS);
});
// dyn? TypeParamBounds
// TypeParamBounds :
// TypeParamBound ( + TypeParamBound )* +?
- internal_comment (std::string ("TraiObjectType"), [this, &type] () {
+ describe_node (std::string ("TraiObjectType"), [this, &type] () {
if (type.is_dyn ())
push (Rust::Token::make (DYN, type.get_locus ()));
visit_items_joined_by_separator (type.get_type_param_bounds (), PLUS);
{
// Syntax:
// ( Type )
- internal_comment (std::string ("ParenthesisedType"), [this, &type] () {
+ describe_node (std::string ("ParenthesisedType"), [this, &type] () {
push (Rust::Token::make (LEFT_PAREN, type.get_locus ()));
visit (type.get_type_in_parens ());
push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
// Syntax:
// impl TraitBound
- internal_comment (std::string ("ImplTraitTypeOneBound"), [this, &type] () {
+ describe_node (std::string ("ImplTraitTypeOneBound"), [this, &type] () {
push (Rust::Token::make (IMPL, type.get_locus ()));
visit (type.get_trait_bound ());
});
{
// Syntax:
// dyn? TraitBound
- internal_comment (std::string ("TraitObjectTypeOneBound"), [this, &type] () {
+ describe_node (std::string ("TraitObjectTypeOneBound"), [this, &type] () {
if (type.is_dyn ())
push (Rust::Token::make (DYN, type.get_locus ()));
visit (type.get_trait_bound ());
// ( )
// | ( ( Type , )+ Type? )
- internal_comment (std::string ("TupleType"), [this, &type] () {
+ describe_node (std::string ("TupleType"), [this, &type] () {
push (Rust::Token::make (LEFT_PAREN, type.get_locus ()));
visit_items_joined_by_separator (type.get_elems (), COMMA);
push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
// Syntax:
// !
- internal_comment (std::string ("NeverType"), [this, &type] () {
+ describe_node (std::string ("NeverType"), [this, &type] () {
push (Rust::Token::make (EXCLAM, type.get_locus ()));
});
}
{
// Syntax:
// * ( mut | const ) TypeNoBounds
- internal_comment (std::string ("RawPointerType"), [this, &type] () {
+ describe_node (std::string ("RawPointerType"), [this, &type] () {
push (Rust::Token::make (ASTERISK, type.get_locus ()));
if (type.get_pointer_type () == RawPointerType::MUT)
push (Rust::Token::make (MUT, UNDEF_LOCATION));
{
// Syntax:
// & Lifetime? mut? TypeNoBounds
- internal_comment (std::string ("ReferenceType"), [this, &type] () {
+ describe_node (std::string ("ReferenceType"), [this, &type] () {
push (Rust::Token::make (AMP, type.get_locus ()));
if (type.has_lifetime ())
{
// Syntax:
// [type Type ; Expression ]
- internal_comment (std::string ("ArrayType"), [this, &type] () {
+ describe_node (std::string ("ArrayType"), [this, &type] () {
push (Rust::Token::make (LEFT_SQUARE, type.get_locus ()));
visit (type.get_elem_type ());
push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION));
// Syntax:
// [type Type ]
- internal_comment (std::string ("SliceType"), [this, &type] () {
+ describe_node (std::string ("SliceType"), [this, &type] () {
push (Rust::Token::make (LEFT_SQUARE, type.get_locus ()));
visit (type.get_elem_type ());
push (Rust::Token::make (RIGHT_SQUARE, UNDEF_LOCATION));
{
// Syntax:
// _
- internal_comment (std::string ("InferredType"), [this, &type] () {
+ describe_node (std::string ("InferredType"), [this, &type] () {
push (Rust::Token::make (UNDERSCORE, type.get_locus ()));
});
}
//
// MaybeNamedFunctionParametersVariadic :
// ( MaybeNamedParam , )* MaybeNamedParam , OuterAttribute* ...
- internal_comment (std::string ("BareFunctionType"), [this, &type] () {
+ describe_node (std::string ("BareFunctionType"), [this, &type] () {
if (type.has_for_lifetimes ())
visit (type.get_for_lifetimes ());