LCOV - code coverage report
Current view: top level - gcc/rust/ast - rust-ast-collector.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 59.7 % 1667 996
Test Date: 2025-06-21 16:26:05 Functions: 64.9 % 194 126
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : // Copyright (C) 2020-2025 Free Software Foundation, Inc.
       2                 :             : 
       3                 :             : // This file is part of GCC.
       4                 :             : 
       5                 :             : // GCC is free software; you can redistribute it and/or modify it under
       6                 :             : // the terms of the GNU General Public License as published by the Free
       7                 :             : // Software Foundation; either version 3, or (at your option) any later
       8                 :             : // version.
       9                 :             : 
      10                 :             : // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      11                 :             : // WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12                 :             : // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      13                 :             : // for more details.
      14                 :             : 
      15                 :             : // You should have received a copy of the GNU General Public License
      16                 :             : // along with GCC; see the file COPYING3.  If not see
      17                 :             : // <http://www.gnu.org/licenses/>.
      18                 :             : 
      19                 :             : #include "rust-ast-collector.h"
      20                 :             : #include "rust-ast.h"
      21                 :             : #include "rust-diagnostics.h"
      22                 :             : #include "rust-expr.h"
      23                 :             : #include "rust-item.h"
      24                 :             : #include "rust-keyword-values.h"
      25                 :             : #include "rust-location.h"
      26                 :             : #include "rust-path.h"
      27                 :             : #include "rust-system.h"
      28                 :             : #include "rust-token.h"
      29                 :             : 
      30                 :             : namespace Rust {
      31                 :             : namespace AST {
      32                 :             : 
      33                 :             : std::vector<TokenPtr>
      34                 :           0 : TokenCollector::collect_tokens () const
      35                 :             : {
      36                 :           0 :   std::vector<TokenPtr> result;
      37                 :           0 :   for (auto item : tokens)
      38                 :             :     {
      39                 :           0 :       if (item.get_kind () == CollectItem::Kind::Token)
      40                 :             :         {
      41                 :           0 :           result.emplace_back (item.get_token ());
      42                 :             :         }
      43                 :           0 :     }
      44                 :           0 :   return result;
      45                 :             : }
      46                 :             : 
      47                 :             : std::vector<CollectItem>
      48                 :        2811 : TokenCollector::collect () const
      49                 :             : {
      50                 :        2811 :   return tokens;
      51                 :             : }
      52                 :             : 
      53                 :             : void
      54                 :           0 : TokenCollector::visit (AST::Crate &crate)
      55                 :             : {
      56                 :           0 :   visit_items_as_lines (crate.inner_attrs);
      57                 :           0 :   visit_items_as_lines (crate.items);
      58                 :           0 : }
      59                 :             : 
      60                 :             : void
      61                 :        2811 : TokenCollector::visit (AST::Item &item)
      62                 :             : {
      63                 :        2811 :   item.accept_vis (*this);
      64                 :        2811 : }
      65                 :             : 
      66                 :             : void
      67                 :         386 : TokenCollector::trailing_comma ()
      68                 :             : {
      69                 :         386 :   if (output_trailing_commas)
      70                 :             :     {
      71                 :           0 :       push (Rust::Token::make (COMMA, UNDEF_LOCATION));
      72                 :             :     }
      73                 :         386 : }
      74                 :             : 
      75                 :             : void
      76                 :       17579 : TokenCollector::newline ()
      77                 :             : {
      78                 :       17579 :   tokens.push_back ({CollectItem::Kind::Newline});
      79                 :       17579 : }
      80                 :             : 
      81                 :             : void
      82                 :       11663 : TokenCollector::indentation ()
      83                 :             : {
      84                 :       11663 :   tokens.push_back ({indent_level});
      85                 :       11663 : }
      86                 :             : 
      87                 :             : void
      88                 :        3117 : TokenCollector::increment_indentation ()
      89                 :             : {
      90                 :        3117 :   indent_level++;
      91                 :        3117 : }
      92                 :             : 
      93                 :             : void
      94                 :        3117 : TokenCollector::decrement_indentation ()
      95                 :             : {
      96                 :        3117 :   rust_assert (indent_level != 0);
      97                 :        3117 :   indent_level--;
      98                 :        3117 : }
      99                 :             : 
     100                 :             : void
     101                 :         969 : TokenCollector::comment (std::string comment)
     102                 :             : {
     103                 :        1938 :   tokens.push_back ({comment});
     104                 :         969 : }
     105                 :             : 
     106                 :             : void
     107                 :           0 : TokenCollector::visit (Visitable &v)
     108                 :             : {
     109                 :           0 :   v.accept_vis (*this);
     110                 :           0 : }
     111                 :             : 
     112                 :             : void
     113                 :         608 : TokenCollector::visit (FunctionParam &param)
     114                 :             : {
     115                 :         608 :   visit_items_as_lines (param.get_outer_attrs ());
     116                 :         608 :   if (!param.is_variadic ())
     117                 :             :     {
     118                 :         608 :       visit (param.get_pattern ());
     119                 :         608 :       push (Rust::Token::make (COLON, UNDEF_LOCATION));
     120                 :         608 :       visit (param.get_type ());
     121                 :             :     }
     122                 :             :   else
     123                 :             :     {
     124                 :           0 :       if (param.has_name ())
     125                 :             :         {
     126                 :           0 :           visit (param.get_pattern ());
     127                 :           0 :           push (Rust::Token::make (COLON, UNDEF_LOCATION));
     128                 :             :         }
     129                 :           0 :       push (Rust::Token::make (ELLIPSIS, UNDEF_LOCATION));
     130                 :             :     }
     131                 :         608 : }
     132                 :             : 
     133                 :             : void
     134                 :           0 : TokenCollector::visit (VariadicParam &param)
     135                 :             : {
     136                 :           0 :   if (param.has_pattern ())
     137                 :             :     {
     138                 :           0 :       visit (param.get_pattern ());
     139                 :           0 :       push (Rust::Token::make (COLON, UNDEF_LOCATION));
     140                 :             :     }
     141                 :           0 :   push (Rust::Token::make (ELLIPSIS, UNDEF_LOCATION));
     142                 :           0 : }
     143                 :             : 
     144                 :             : void
     145                 :        2222 : TokenCollector::visit (Attribute &attrib)
     146                 :             : {
     147                 :        2222 :   push (Rust::Token::make (HASH, attrib.get_locus ()));
     148                 :        2222 :   if (attrib.is_inner_attribute ())
     149                 :           0 :     push (Rust::Token::make (EXCLAM, UNDEF_LOCATION));
     150                 :        2222 :   push (Rust::Token::make (LEFT_SQUARE, UNDEF_LOCATION));
     151                 :        2222 :   visit (attrib.get_path ());
     152                 :             : 
     153                 :        2222 :   if (attrib.has_attr_input ())
     154                 :             :     {
     155                 :        2177 :       switch (attrib.get_attr_input ().get_attr_input_type ())
     156                 :             :         {
     157                 :        2068 :           case AST::AttrInput::AttrInputType::LITERAL: {
     158                 :        2068 :             visit (static_cast<AttrInputLiteral &> (attrib.get_attr_input ()));
     159                 :        2068 :             break;
     160                 :             :           }
     161                 :           0 :           case AST::AttrInput::AttrInputType::MACRO: {
     162                 :           0 :             visit (static_cast<AttrInputMacro &> (attrib.get_attr_input ()));
     163                 :           0 :             break;
     164                 :             :           }
     165                 :           4 :           case AST::AttrInput::AttrInputType::META_ITEM: {
     166                 :           4 :             visit (static_cast<AttrInputMetaItemContainer &> (
     167                 :           4 :               attrib.get_attr_input ()));
     168                 :           4 :             break;
     169                 :             :           }
     170                 :         105 :           case AST::AttrInput::AttrInputType::TOKEN_TREE: {
     171                 :         105 :             visit (static_cast<DelimTokenTree &> (attrib.get_attr_input ()));
     172                 :         105 :             break;
     173                 :             :           }
     174                 :           0 :         default:
     175                 :           0 :           rust_unreachable ();
     176                 :             :         }
     177                 :             :     }
     178                 :        2222 :   push (Rust::Token::make (RIGHT_SQUARE, UNDEF_LOCATION));
     179                 :        2222 : }
     180                 :             : 
     181                 :             : void
     182                 :        2226 : TokenCollector::visit (SimplePath &path)
     183                 :             : {
     184                 :        2226 :   if (path.has_opening_scope_resolution ())
     185                 :             :     {
     186                 :           0 :       push (Rust::Token::make (SCOPE_RESOLUTION, path.get_locus ()));
     187                 :             :     }
     188                 :        2226 :   visit_items_joined_by_separator (path.get_segments (), SCOPE_RESOLUTION);
     189                 :        2226 : }
     190                 :             : 
     191                 :             : void
     192                 :        2226 : TokenCollector::visit (SimplePathSegment &segment)
     193                 :             : {
     194                 :        2226 :   auto name = segment.get_segment_name ();
     195                 :        2226 :   if (segment.is_crate_path_seg ())
     196                 :             :     {
     197                 :           0 :       push (Rust::Token::make (CRATE, segment.get_locus ()));
     198                 :             :     }
     199                 :        2226 :   else if (segment.is_super_path_seg ())
     200                 :             :     {
     201                 :           0 :       push (Rust::Token::make (SUPER, segment.get_locus ()));
     202                 :             :     }
     203                 :        2226 :   else if (segment.is_lower_self_seg ())
     204                 :             :     {
     205                 :           0 :       push (Rust::Token::make (SELF, segment.get_locus ()));
     206                 :             :     }
     207                 :        2226 :   else if (segment.is_big_self ())
     208                 :             :     {
     209                 :           0 :       push (Rust::Token::make (SELF_ALIAS, segment.get_locus ()));
     210                 :             :     }
     211                 :             :   else
     212                 :             :     {
     213                 :        2226 :       push (
     214                 :        4452 :         Rust::Token::make_identifier (segment.get_locus (), std::move (name)));
     215                 :             :     }
     216                 :        2226 : }
     217                 :             : 
     218                 :             : void
     219                 :        3765 : TokenCollector::visit (Visibility &vis)
     220                 :             : {
     221                 :        3765 :   switch (vis.get_vis_type ())
     222                 :             :     {
     223                 :        2811 :     case Visibility::PUB:
     224                 :        2811 :       push (Rust::Token::make (PUB, vis.get_locus ()));
     225                 :        2811 :       break;
     226                 :           0 :     case Visibility::PUB_CRATE:
     227                 :           0 :       push (Rust::Token::make (PUB, vis.get_locus ()));
     228                 :           0 :       push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));
     229                 :           0 :       push (Rust::Token::make (CRATE, UNDEF_LOCATION));
     230                 :           0 :       push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
     231                 :           0 :       break;
     232                 :           0 :     case Visibility::PUB_SELF:
     233                 :           0 :       push (Rust::Token::make (PUB, vis.get_locus ()));
     234                 :           0 :       push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));
     235                 :           0 :       push (Rust::Token::make (SELF, UNDEF_LOCATION));
     236                 :           0 :       push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
     237                 :           0 :       break;
     238                 :           0 :     case Visibility::PUB_SUPER:
     239                 :           0 :       push (Rust::Token::make (PUB, vis.get_locus ()));
     240                 :           0 :       push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));
     241                 :           0 :       push (Rust::Token::make (SUPER, UNDEF_LOCATION));
     242                 :           0 :       push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
     243                 :           0 :       break;
     244                 :           0 :     case Visibility::PUB_IN_PATH:
     245                 :           0 :       push (Rust::Token::make (PUB, vis.get_locus ()));
     246                 :           0 :       push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));
     247                 :           0 :       push (Rust::Token::make (IN, UNDEF_LOCATION));
     248                 :           0 :       visit (vis.get_path ());
     249                 :           0 :       push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
     250                 :           0 :       break;
     251                 :             :     case Visibility::PRIV:
     252                 :             :       break;
     253                 :             :     }
     254                 :        3765 : }
     255                 :             : 
     256                 :             : void
     257                 :        2119 : TokenCollector::visit (std::vector<std::unique_ptr<GenericParam>> &params)
     258                 :             : {
     259                 :        2119 :   push (Rust::Token::make (LEFT_ANGLE, UNDEF_LOCATION));
     260                 :        2119 :   visit_items_joined_by_separator (params, COMMA);
     261                 :        2119 :   push (Rust::Token::make (RIGHT_ANGLE, UNDEF_LOCATION));
     262                 :        2119 : }
     263                 :             : 
     264                 :             : void
     265                 :         118 : TokenCollector::visit (TupleField &field)
     266                 :             : {
     267                 :         118 :   for (auto attr : field.get_outer_attrs ())
     268                 :             :     {
     269                 :           0 :       visit (attr);
     270                 :           0 :     }
     271                 :         118 :   visit (field.get_visibility ());
     272                 :         118 :   visit (field.get_field_type ());
     273                 :         118 : }
     274                 :             : 
     275                 :             : void
     276                 :          16 : TokenCollector::visit (StructField &field)
     277                 :             : {
     278                 :          16 :   for (auto attr : field.get_outer_attrs ())
     279                 :             :     {
     280                 :           0 :       visit (attr);
     281                 :           0 :     }
     282                 :          16 :   visit (field.get_visibility ());
     283                 :          32 :   auto name = field.get_field_name ().as_string ();
     284                 :          16 :   push (Rust::Token::make_identifier (field.get_locus (), std::move (name)));
     285                 :          16 :   push (Rust::Token::make (COLON, UNDEF_LOCATION));
     286                 :          16 :   visit (field.get_field_type ());
     287                 :          16 : }
     288                 :             : 
     289                 :             : void
     290                 :           0 : TokenCollector::visit (std::vector<LifetimeParam> &for_lifetimes)
     291                 :             : {
     292                 :           0 :   push (Rust::Token::make (FOR, UNDEF_LOCATION));
     293                 :           0 :   push (Rust::Token::make (LEFT_ANGLE, UNDEF_LOCATION));
     294                 :           0 :   visit_items_joined_by_separator (for_lifetimes, COMMA);
     295                 :           0 :   push (Rust::Token::make (RIGHT_ANGLE, UNDEF_LOCATION));
     296                 :           0 : }
     297                 :             : 
     298                 :             : void
     299                 :        1599 : TokenCollector::visit (FunctionQualifiers &qualifiers)
     300                 :             : {
     301                 :             :   // Syntax:
     302                 :             :   //    `const`? `async`? `unsafe`? (`extern` Abi?)?
     303                 :             :   //    unsafe? (extern Abi?)?
     304                 :             : 
     305                 :        1599 :   if (qualifiers.is_async ())
     306                 :           4 :     push (Rust::Token::make (ASYNC, qualifiers.get_locus ()));
     307                 :        1599 :   if (qualifiers.is_const ())
     308                 :           4 :     push (Rust::Token::make (CONST, qualifiers.get_locus ()));
     309                 :        1599 :   if (qualifiers.is_unsafe ())
     310                 :          88 :     push (Rust::Token::make (UNSAFE, qualifiers.get_locus ()));
     311                 :        1599 :   if (qualifiers.is_extern ())
     312                 :             :     {
     313                 :          57 :       push (Rust::Token::make (EXTERN_KW, qualifiers.get_locus ()));
     314                 :          57 :       if (qualifiers.has_abi ())
     315                 :             :         {
     316                 :         171 :           push (Rust::Token::make_string (UNDEF_LOCATION,
     317                 :         114 :                                           qualifiers.get_extern_abi ()));
     318                 :             :         }
     319                 :             :     }
     320                 :        1599 : }
     321                 :             : 
     322                 :             : void
     323                 :           0 : TokenCollector::visit (MaybeNamedParam &param)
     324                 :             : {
     325                 :             :   // Syntax:
     326                 :             :   //     OuterAttribute* ( ( IDENTIFIER | _ ) : )? Type
     327                 :             : 
     328                 :           0 :   for (auto attr : param.get_outer_attrs ())
     329                 :             :     {
     330                 :           0 :       visit (attr);
     331                 :           0 :     }
     332                 :           0 :   auto param_name = param.get_name ().as_string ();
     333                 :           0 :   switch (param.get_param_kind ())
     334                 :             :     {
     335                 :             :     case MaybeNamedParam::UNNAMED:
     336                 :             :       break;
     337                 :           0 :     case MaybeNamedParam::IDENTIFIER:
     338                 :           0 :       push (
     339                 :           0 :         Rust::Token::make_identifier (UNDEF_LOCATION, std::move (param_name)));
     340                 :           0 :       push (Rust::Token::make (COLON, UNDEF_LOCATION));
     341                 :           0 :       break;
     342                 :           0 :     case MaybeNamedParam::WILDCARD:
     343                 :           0 :       push (Rust::Token::make (UNDERSCORE, UNDEF_LOCATION));
     344                 :           0 :       push (Rust::Token::make (COLON, UNDEF_LOCATION));
     345                 :           0 :       break;
     346                 :             :     }
     347                 :           0 :   visit (param.get_type ());
     348                 :           0 : }
     349                 :             : 
     350                 :             : void
     351                 :         937 : TokenCollector::visit (Token &tok)
     352                 :             : {
     353                 :        2698 :   std::string data = tok.get_tok_ptr ()->has_str () ? tok.get_str () : "";
     354                 :         937 :   switch (tok.get_id ())
     355                 :             :     {
     356                 :         208 :     case IDENTIFIER:
     357                 :         208 :       push (Rust::Token::make_identifier (tok.get_locus (), std::move (data)));
     358                 :         208 :       break;
     359                 :           2 :     case INT_LITERAL:
     360                 :           2 :       push (Rust::Token::make_int (tok.get_locus (), std::move (data),
     361                 :             :                                    tok.get_type_hint ()));
     362                 :           2 :       break;
     363                 :           0 :     case FLOAT_LITERAL:
     364                 :           0 :       push (Rust::Token::make_float (tok.get_locus (), std::move (data),
     365                 :             :                                      tok.get_type_hint ()));
     366                 :           0 :       break;
     367                 :         202 :     case STRING_LITERAL:
     368                 :         202 :       push (Rust::Token::make_string (tok.get_locus (), std::move (data)));
     369                 :         202 :       break;
     370                 :           0 :     case CHAR_LITERAL:
     371                 :           0 :       push (Rust::Token::make_char (
     372                 :             :         tok.get_locus (),
     373                 :             :         // FIXME: This need to be fixed to properly support UTF-8
     374                 :           0 :         static_cast<uint32_t> (data[0])));
     375                 :           0 :       break;
     376                 :           0 :     case BYTE_CHAR_LITERAL:
     377                 :           0 :       push (Rust::Token::make_byte_char (tok.get_locus (), data[0]));
     378                 :           0 :       break;
     379                 :           0 :     case BYTE_STRING_LITERAL:
     380                 :           0 :       push (Rust::Token::make_byte_string (tok.get_locus (), std::move (data)));
     381                 :           0 :       break;
     382                 :           0 :     case RAW_STRING_LITERAL:
     383                 :           0 :       push (Rust::Token::make_raw_string (tok.get_locus (), std::move (data)));
     384                 :           0 :       break;
     385                 :           0 :     case INNER_DOC_COMMENT:
     386                 :           0 :       push (Rust::Token::make_inner_doc_comment (tok.get_locus (),
     387                 :             :                                                  std::move (data)));
     388                 :           0 :       break;
     389                 :           0 :     case OUTER_DOC_COMMENT:
     390                 :           0 :       push (Rust::Token::make_outer_doc_comment (tok.get_locus (),
     391                 :             :                                                  std::move (data)));
     392                 :           0 :       break;
     393                 :           0 :     case LIFETIME:
     394                 :           0 :       push (Rust::Token::make_lifetime (tok.get_locus (), std::move (data)));
     395                 :           0 :       break;
     396                 :         525 :     default:
     397                 :        1050 :       push (Rust::Token::make (tok.get_id (), tok.get_locus ()));
     398                 :             :     }
     399                 :         937 : }
     400                 :             : 
     401                 :             : void
     402                 :         109 : TokenCollector::visit (DelimTokenTree &delim_tok_tree)
     403                 :             : {
     404                 :        1044 :   for (auto &token : delim_tok_tree.to_token_stream ())
     405                 :             :     {
     406                 :         935 :       visit (token);
     407                 :         109 :     }
     408                 :         109 : }
     409                 :             : 
     410                 :             : void
     411                 :           4 : TokenCollector::visit (AttrInputMetaItemContainer &container)
     412                 :             : {
     413                 :           8 :   for (auto &item : container.get_items ())
     414                 :             :     {
     415                 :           4 :       visit (item);
     416                 :             :     }
     417                 :           4 : }
     418                 :             : 
     419                 :             : void
     420                 :        2057 : TokenCollector::visit (IdentifierExpr &ident_expr)
     421                 :             : {
     422                 :        4114 :   auto ident = ident_expr.get_ident ().as_string ();
     423                 :        2057 :   push (
     424                 :        4114 :     Rust::Token::make_identifier (ident_expr.get_locus (), std::move (ident)));
     425                 :        2057 : }
     426                 :             : 
     427                 :             : void
     428                 :         921 : TokenCollector::visit (Lifetime &lifetime)
     429                 :             : {
     430                 :             :   // Syntax:
     431                 :             :   // Lifetime :
     432                 :             :   //    LIFETIME_OR_LABEL
     433                 :             :   //    | 'static
     434                 :             :   //    | '_
     435                 :             : 
     436                 :         921 :   auto name = lifetime.get_lifetime_name ();
     437                 :         921 :   switch (lifetime.get_lifetime_type ())
     438                 :             :     {
     439                 :          44 :     case Lifetime::LifetimeType::NAMED:
     440                 :          44 :       push (
     441                 :          44 :         Rust::Token::make_lifetime (lifetime.get_locus (), std::move (name)));
     442                 :          44 :       break;
     443                 :           2 :     case Lifetime::LifetimeType::STATIC:
     444                 :           4 :       push (Rust::Token::make_lifetime (lifetime.get_locus (),
     445                 :           2 :                                         Values::Keywords::STATIC_KW));
     446                 :           2 :       break;
     447                 :         875 :     case Lifetime::LifetimeType::WILDCARD:
     448                 :        1750 :       push (Rust::Token::make_lifetime (lifetime.get_locus (),
     449                 :         875 :                                         Values::Keywords::UNDERSCORE));
     450                 :         875 :       break;
     451                 :             :     }
     452                 :         921 : }
     453                 :             : 
     454                 :             : void
     455                 :          28 : TokenCollector::visit (LifetimeParam &lifetime_param)
     456                 :             : {
     457                 :             :   // Syntax:
     458                 :             :   //   LIFETIME_OR_LABEL ( : LifetimeBounds )?
     459                 :             :   // LifetimeBounds :
     460                 :             :   //   ( Lifetime + )* Lifetime?
     461                 :             : 
     462                 :             :   // TODO what to do with outer attr? They are not mentioned in the reference.
     463                 :             : 
     464                 :          28 :   visit_items_as_lines (lifetime_param.get_outer_attrs ());
     465                 :          28 :   auto lifetime = lifetime_param.get_lifetime ();
     466                 :          28 :   visit (lifetime);
     467                 :             : 
     468                 :          28 :   if (lifetime_param.has_lifetime_bounds ())
     469                 :             :     {
     470                 :           0 :       push (Rust::Token::make (COLON, UNDEF_LOCATION));
     471                 :           0 :       for (auto &bound : lifetime_param.get_lifetime_bounds ())
     472                 :             :         {
     473                 :           0 :           visit (bound);
     474                 :             :         }
     475                 :             :     }
     476                 :          28 : }
     477                 :             : 
     478                 :             : void
     479                 :           0 : TokenCollector::visit (ConstGenericParam &param)
     480                 :             : {
     481                 :             :   // Syntax:
     482                 :             :   // const IDENTIFIER : Type ( = Block | IDENTIFIER | -?LITERAL )?
     483                 :             : 
     484                 :           0 :   visit_items_as_lines (param.get_outer_attrs ());
     485                 :           0 :   push (Rust::Token::make (CONST, param.get_locus ()));
     486                 :           0 :   auto id = param.get_name ().as_string ();
     487                 :           0 :   push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id)));
     488                 :           0 :   push (Rust::Token::make (COLON, UNDEF_LOCATION));
     489                 :           0 :   if (param.has_type ())
     490                 :           0 :     visit (param.get_type ());
     491                 :           0 :   if (param.has_default_value ())
     492                 :             :     {
     493                 :           0 :       push (Rust::Token::make (EQUAL, UNDEF_LOCATION));
     494                 :           0 :       visit (param.get_default_value_unchecked ());
     495                 :             :     }
     496                 :           0 : }
     497                 :             : 
     498                 :             : void
     499                 :        1724 : TokenCollector::visit (PathExprSegment &segment)
     500                 :             : {
     501                 :        1724 :   visit (segment.get_ident_segment ());
     502                 :        1724 :   if (segment.has_generic_args ())
     503                 :             :     {
     504                 :          77 :       auto generics = segment.get_generic_args ();
     505                 :          77 :       push (Rust::Token::make (SCOPE_RESOLUTION, segment.get_locus ()));
     506                 :          77 :       push (Rust::Token::make (LEFT_ANGLE, generics.get_locus ()));
     507                 :             : 
     508                 :          77 :       auto &lifetime_args = generics.get_lifetime_args ();
     509                 :          77 :       auto &generic_args = generics.get_generic_args ();
     510                 :          77 :       auto &binding_args = generics.get_binding_args ();
     511                 :             : 
     512                 :          77 :       visit_items_joined_by_separator (generic_args, COMMA);
     513                 :             : 
     514                 :          77 :       if (!lifetime_args.empty ()
     515                 :          77 :           && (!generic_args.empty () || !binding_args.empty ()))
     516                 :             :         {
     517                 :           0 :           push (Rust::Token::make (COMMA, UNDEF_LOCATION));
     518                 :             :         }
     519                 :             : 
     520                 :          77 :       visit_items_joined_by_separator (binding_args, COMMA);
     521                 :             : 
     522                 :          77 :       if (!generic_args.empty () && !binding_args.empty ())
     523                 :             :         {
     524                 :           0 :           push (Rust::Token::make (COMMA, UNDEF_LOCATION));
     525                 :             :         }
     526                 :             : 
     527                 :          77 :       visit_items_joined_by_separator (lifetime_args, COMMA);
     528                 :             : 
     529                 :          77 :       push (Rust::Token::make (RIGHT_ANGLE, UNDEF_LOCATION));
     530                 :          77 :     }
     531                 :        1724 : }
     532                 :             : 
     533                 :             : void
     534                 :        1298 : TokenCollector::visit (PathInExpression &path)
     535                 :             : {
     536                 :        1298 :   if (path.is_lang_item ())
     537                 :             :     {
     538                 :          72 :       push (Rust::Token::make (TokenId::HASH, path.get_locus ()));
     539                 :          72 :       push (Rust::Token::make (TokenId::LEFT_SQUARE, path.get_locus ()));
     540                 :         144 :       push (Rust::Token::make_identifier (path.get_locus (), "lang"));
     541                 :          72 :       push (Rust::Token::make (TokenId::EQUAL, path.get_locus ()));
     542                 :          72 :       push (
     543                 :         144 :         Rust::Token::make_string (path.get_locus (),
     544                 :          72 :                                   LangItem::ToString (path.get_lang_item ())));
     545                 :          72 :       push (Rust::Token::make (TokenId::RIGHT_SQUARE, path.get_locus ()));
     546                 :             : 
     547                 :          72 :       return;
     548                 :             :     }
     549                 :             : 
     550                 :        1226 :   if (path.opening_scope_resolution ())
     551                 :           0 :     push (Rust::Token::make (SCOPE_RESOLUTION, path.get_locus ()));
     552                 :             : 
     553                 :        1226 :   visit_items_joined_by_separator (path.get_segments (), SCOPE_RESOLUTION);
     554                 :             : }
     555                 :             : 
     556                 :             : void
     557                 :        3373 : TokenCollector::visit (TypePathSegment &segment)
     558                 :             : {
     559                 :             :   // Syntax:
     560                 :             :   //    PathIdentSegment
     561                 :             : 
     562                 :        3373 :   auto locus = segment.is_lang_item ()
     563                 :        3373 :                  ? segment.get_locus ()
     564                 :        3373 :                  : segment.get_ident_segment ().get_locus ();
     565                 :        3373 :   auto segment_string = segment.is_lang_item ()
     566                 :        3373 :                           ? LangItem::PrettyString (segment.get_lang_item ())
     567                 :        3373 :                           : segment.get_ident_segment ().as_string ();
     568                 :        6746 :   push (Rust::Token::make_identifier (locus, std::move (segment_string)));
     569                 :        3373 : }
     570                 :             : 
     571                 :             : void
     572                 :         257 : TokenCollector::visit (TypePathSegmentGeneric &segment)
     573                 :             : {
     574                 :             :   // Syntax:
     575                 :             :   //    PathIdentSegment `::`? (GenericArgs)?
     576                 :             :   // GenericArgs :
     577                 :             :   //    `<` `>`
     578                 :             :   //    | `<` ( GenericArg `,` )* GenericArg `,`? `>`
     579                 :             : 
     580                 :         257 :   auto locus = segment.is_lang_item ()
     581                 :         257 :                  ? segment.get_locus ()
     582                 :         257 :                  : segment.get_ident_segment ().get_locus ();
     583                 :         257 :   auto segment_string = segment.is_lang_item ()
     584                 :         257 :                           ? LangItem::PrettyString (segment.get_lang_item ())
     585                 :         257 :                           : segment.get_ident_segment ().as_string ();
     586                 :         257 :   push (Rust::Token::make_identifier (locus, std::move (segment_string)));
     587                 :             : 
     588                 :         257 :   if (segment.get_separating_scope_resolution ())
     589                 :           0 :     push (Rust::Token::make (SCOPE_RESOLUTION, UNDEF_LOCATION));
     590                 :             : 
     591                 :         257 :   push (Rust::Token::make (LEFT_ANGLE, UNDEF_LOCATION));
     592                 :             : 
     593                 :         257 :   {
     594                 :         257 :     auto &lifetime_args = segment.get_generic_args ().get_lifetime_args ();
     595                 :         257 :     auto &generic_args = segment.get_generic_args ().get_generic_args ();
     596                 :         257 :     auto &binding_args = segment.get_generic_args ().get_binding_args ();
     597                 :             : 
     598                 :         257 :     visit_items_joined_by_separator (lifetime_args, COMMA);
     599                 :         257 :     if (!lifetime_args.empty ()
     600                 :         257 :         && (!generic_args.empty () || !binding_args.empty ()))
     601                 :           4 :       push (Rust::Token::make (COMMA, UNDEF_LOCATION));
     602                 :         257 :     visit_items_joined_by_separator (generic_args, COMMA);
     603                 :         257 :     if (!generic_args.empty () && !binding_args.empty ())
     604                 :           0 :       push (Rust::Token::make (COMMA, UNDEF_LOCATION));
     605                 :         257 :     visit_items_joined_by_separator (binding_args, COMMA);
     606                 :             :   }
     607                 :             : 
     608                 :         514 :   push (Rust::Token::make (RIGHT_ANGLE, UNDEF_LOCATION));
     609                 :         257 : }
     610                 :             : 
     611                 :             : void
     612                 :          14 : TokenCollector::visit (GenericArgsBinding &binding)
     613                 :             : {
     614                 :             :   // Syntax:
     615                 :             :   //    IDENTIFIER `=` Type
     616                 :          28 :   auto identifier = binding.get_identifier ().as_string ();
     617                 :          14 :   push (Rust::Token::make_identifier (binding.get_locus (),
     618                 :             :                                       std::move (identifier)));
     619                 :             : 
     620                 :          14 :   push (Rust::Token::make (EQUAL, UNDEF_LOCATION));
     621                 :          14 :   visit (binding.get_type ());
     622                 :          14 : }
     623                 :             : 
     624                 :             : void
     625                 :         376 : TokenCollector::visit (GenericArg &arg)
     626                 :             : {
     627                 :             :   // `GenericArg` implements `accept_vis` but it is not useful for this case as
     628                 :             :   // it ignores unresolved cases (`Kind::Either`).
     629                 :         376 :   switch (arg.get_kind ())
     630                 :             :     {
     631                 :           0 :     case GenericArg::Kind::Const:
     632                 :           0 :       visit (arg.get_expression ());
     633                 :           0 :       break;
     634                 :         376 :     case GenericArg::Kind::Type:
     635                 :         376 :       visit (arg.get_type ());
     636                 :         376 :       break;
     637                 :           0 :       case GenericArg::Kind::Either: {
     638                 :           0 :         auto path = arg.get_path ();
     639                 :           0 :         push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (path)));
     640                 :           0 :       }
     641                 :           0 :       break;
     642                 :             :     }
     643                 :         376 : }
     644                 :             : 
     645                 :             : void
     646                 :          10 : TokenCollector::visit (TypePathSegmentFunction &segment)
     647                 :             : {
     648                 :             :   // Syntax:
     649                 :             :   //   PathIdentSegment `::`? (TypePathFn)?
     650                 :             : 
     651                 :          10 :   auto ident_segment = segment.get_ident_segment ();
     652                 :          10 :   auto id = ident_segment.as_string ();
     653                 :          10 :   push (
     654                 :          10 :     Rust::Token::make_identifier (ident_segment.get_locus (), std::move (id)));
     655                 :             : 
     656                 :          10 :   if (segment.get_separating_scope_resolution ())
     657                 :           0 :     push (Rust::Token::make (SCOPE_RESOLUTION, UNDEF_LOCATION));
     658                 :             : 
     659                 :          10 :   if (!segment.is_ident_only ())
     660                 :          10 :     visit (segment.get_type_path_function ());
     661                 :          10 : }
     662                 :             : 
     663                 :             : void
     664                 :          10 : TokenCollector::visit (TypePathFunction &type_path_fn)
     665                 :             : {
     666                 :             :   // Syntax:
     667                 :             :   //   `(` TypePathFnInputs? `)` (`->` Type)?
     668                 :             :   // TypePathFnInputs :
     669                 :             :   //   Type (`,` Type)* `,`?
     670                 :             : 
     671                 :          10 :   push (Rust::Token::make (LEFT_PAREN, type_path_fn.get_locus ()));
     672                 :          10 :   if (type_path_fn.has_inputs ())
     673                 :          10 :     visit_items_joined_by_separator (type_path_fn.get_params (), COMMA);
     674                 :          10 :   push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
     675                 :             : 
     676                 :          10 :   if (type_path_fn.has_return_type ())
     677                 :             :     {
     678                 :          10 :       push (Rust::Token::make (RETURN_TYPE, UNDEF_LOCATION));
     679                 :          10 :       visit (type_path_fn.get_return_type ());
     680                 :             :     }
     681                 :          10 : }
     682                 :             : 
     683                 :             : void
     684                 :        3032 : TokenCollector::visit (TypePath &path)
     685                 :             : {
     686                 :             :   // Syntax:
     687                 :             :   //    `::`? TypePathSegment (`::` TypePathSegment)*
     688                 :             : 
     689                 :        3032 :   if (path.has_opening_scope_resolution_op ())
     690                 :           0 :     push (Rust::Token::make (SCOPE_RESOLUTION, path.get_locus ()));
     691                 :             : 
     692                 :        3032 :   visit_items_joined_by_separator (path.get_segments (), SCOPE_RESOLUTION);
     693                 :        3032 : }
     694                 :             : 
     695                 :             : void
     696                 :        1724 : TokenCollector::visit (PathIdentSegment &segment)
     697                 :             : {
     698                 :        1724 :   if (segment.is_super_path_seg ())
     699                 :             :     {
     700                 :           0 :       push (Rust::Token::make (SUPER, segment.get_locus ()));
     701                 :             :     }
     702                 :        1724 :   else if (segment.is_crate_path_seg ())
     703                 :             :     {
     704                 :          16 :       push (Rust::Token::make (CRATE, segment.get_locus ()));
     705                 :             :     }
     706                 :        1716 :   else if (segment.is_lower_self_seg ())
     707                 :             :     {
     708                 :         172 :       push (Rust::Token::make (SELF, segment.get_locus ()));
     709                 :             :     }
     710                 :        1630 :   else if (segment.is_big_self_seg ())
     711                 :             :     {
     712                 :           0 :       push (Rust::Token::make (SELF_ALIAS, segment.get_locus ()));
     713                 :             :     }
     714                 :             :   else
     715                 :             :     {
     716                 :        1630 :       auto id = segment.as_string ();
     717                 :        1630 :       push (
     718                 :        3260 :         Rust::Token::make_identifier (segment.get_locus (), std::move (id)));
     719                 :        1630 :     }
     720                 :        1724 : }
     721                 :             : 
     722                 :             : void
     723                 :          27 : TokenCollector::visit (QualifiedPathInExpression &path)
     724                 :             : {
     725                 :          27 :   visit (path.get_qualified_path_type ());
     726                 :          54 :   for (auto &segment : path.get_segments ())
     727                 :             :     {
     728                 :          27 :       push (Rust::Token::make (SCOPE_RESOLUTION, UNDEF_LOCATION));
     729                 :          27 :       visit (segment);
     730                 :             :     }
     731                 :          27 : }
     732                 :             : 
     733                 :             : void
     734                 :          71 : TokenCollector::visit (QualifiedPathType &path)
     735                 :             : {
     736                 :          71 :   push (Rust::Token::make (LEFT_ANGLE, path.get_locus ()));
     737                 :          71 :   visit (path.get_type ());
     738                 :          71 :   if (path.has_as_clause ())
     739                 :             :     {
     740                 :          62 :       push (Rust::Token::make (AS, UNDEF_LOCATION));
     741                 :          62 :       visit (path.get_as_type_path ());
     742                 :             :     }
     743                 :          71 :   push (Rust::Token::make (RIGHT_ANGLE, UNDEF_LOCATION));
     744                 :          71 : }
     745                 :             : 
     746                 :             : void
     747                 :          44 : TokenCollector::visit (QualifiedPathInType &path)
     748                 :             : {
     749                 :          44 :   visit (path.get_qualified_path_type ());
     750                 :             : 
     751                 :          44 :   push (Rust::Token::make (SCOPE_RESOLUTION, UNDEF_LOCATION));
     752                 :          44 :   visit (path.get_associated_segment ());
     753                 :          44 :   for (auto &segment : path.get_segments ())
     754                 :             :     {
     755                 :           0 :       push (Rust::Token::make (SCOPE_RESOLUTION, UNDEF_LOCATION));
     756                 :           0 :       visit (segment);
     757                 :             :     }
     758                 :          44 : }
     759                 :             : 
     760                 :             : void
     761                 :        3991 : TokenCollector::visit (Literal &lit, location_t locus)
     762                 :             : {
     763                 :        3991 :   auto value = lit.as_string ();
     764                 :        3991 :   switch (lit.get_lit_type ())
     765                 :             :     {
     766                 :          56 :     case Literal::LitType::CHAR:
     767                 :          56 :       push (
     768                 :          56 :         Rust::Token::make_char (locus,
     769                 :             :                                 // TODO: Change this to support utf-8 properly
     770                 :          56 :                                 Codepoint (static_cast<uint32_t> (value[0]))));
     771                 :          56 :       break;
     772                 :        2152 :     case Literal::LitType::STRING:
     773                 :        2152 :       push (Rust::Token::make_string (locus, std::move (value)));
     774                 :        2152 :       break;
     775                 :          29 :     case Literal::LitType::BYTE:
     776                 :          29 :       push (Rust::Token::make_byte_char (locus, value[0]));
     777                 :          29 :       break;
     778                 :          16 :     case Literal::LitType::BYTE_STRING:
     779                 :          16 :       push (Rust::Token::make_byte_string (locus, std::move (value)));
     780                 :          16 :       break;
     781                 :           0 :     case Literal::LitType::RAW_STRING:
     782                 :           0 :       push (Rust::Token::make_raw_string (locus, std::move (value)));
     783                 :           0 :       break;
     784                 :        1552 :     case Literal::LitType::INT:
     785                 :        1552 :       push (
     786                 :        1552 :         Rust::Token::make_int (locus, std::move (value), lit.get_type_hint ()));
     787                 :        1552 :       break;
     788                 :          16 :     case Literal::LitType::FLOAT:
     789                 :          16 :       push (Rust::Token::make_float (locus, std::move (value),
     790                 :             :                                      lit.get_type_hint ()));
     791                 :          16 :       break;
     792                 :         170 :       case Literal::LitType::BOOL: {
     793                 :         170 :         if (value == Values::Keywords::FALSE_LITERAL)
     794                 :         160 :           push (Rust::Token::make (FALSE_LITERAL, locus));
     795                 :          90 :         else if (value == Values::Keywords::TRUE_LITERAL)
     796                 :         180 :           push (Rust::Token::make (TRUE_LITERAL, locus));
     797                 :             :         else
     798                 :           0 :           rust_unreachable (); // Not a boolean
     799                 :             :         break;
     800                 :             :       }
     801                 :           0 :     case Literal::LitType::ERROR:
     802                 :           0 :       rust_unreachable ();
     803                 :        3991 :       break;
     804                 :             :     }
     805                 :        3991 : }
     806                 :             : 
     807                 :             : void
     808                 :        3965 : TokenCollector::visit (LiteralExpr &expr)
     809                 :             : {
     810                 :        3965 :   auto lit = expr.get_literal ();
     811                 :        3965 :   visit (lit, expr.get_locus ());
     812                 :        3965 : }
     813                 :             : 
     814                 :             : void
     815                 :        2068 : TokenCollector::visit (AttrInputLiteral &literal)
     816                 :             : {
     817                 :        2068 :   push (Rust::Token::make (EQUAL, UNDEF_LOCATION));
     818                 :        2068 :   visit (literal.get_literal ());
     819                 :        2068 : }
     820                 :             : 
     821                 :             : void
     822                 :           0 : TokenCollector::visit (AttrInputMacro &macro)
     823                 :             : {
     824                 :           0 :   push (Rust::Token::make (EQUAL, UNDEF_LOCATION));
     825                 :           0 :   visit (macro.get_macro ());
     826                 :           0 : }
     827                 :             : 
     828                 :             : void
     829                 :           0 : TokenCollector::visit (MetaItemLitExpr &item)
     830                 :             : {
     831                 :           0 :   auto lit = item.get_literal ();
     832                 :           0 :   visit (lit);
     833                 :           0 : }
     834                 :             : 
     835                 :             : void
     836                 :           0 : TokenCollector::visit (MetaItemPathLit &item)
     837                 :             : {
     838                 :           0 :   auto path = item.get_path ();
     839                 :           0 :   auto lit = item.get_literal ();
     840                 :           0 :   visit (path);
     841                 :           0 :   push (Rust::Token::make (COLON, item.get_locus ()));
     842                 :           0 :   visit (lit);
     843                 :           0 : }
     844                 :             : 
     845                 :             : void
     846                 :         271 : TokenCollector::visit (BorrowExpr &expr)
     847                 :             : {
     848                 :         271 :   push (Rust::Token::make (AMP, expr.get_locus ()));
     849                 :         271 :   if (expr.get_is_double_borrow ())
     850                 :          40 :     push (Rust::Token::make (AMP, UNDEF_LOCATION));
     851                 :             : 
     852                 :         271 :   if (expr.is_raw_borrow ())
     853                 :             :     {
     854                 :           0 :       push (Rust::Token::make_identifier (expr.get_locus (),
     855                 :           0 :                                           Values::WeakKeywords::RAW));
     856                 :           0 :       if (expr.get_is_mut ())
     857                 :           0 :         push (Rust::Token::make (MUT, UNDEF_LOCATION));
     858                 :             :       else
     859                 :           0 :         push (Rust::Token::make (CONST, UNDEF_LOCATION));
     860                 :             :     }
     861                 :             :   else
     862                 :             :     {
     863                 :         271 :       if (expr.get_is_mut ())
     864                 :         150 :         push (Rust::Token::make (MUT, UNDEF_LOCATION));
     865                 :             :     }
     866                 :             : 
     867                 :         271 :   visit (expr.get_borrowed_expr ());
     868                 :         271 : }
     869                 :             : 
     870                 :             : void
     871                 :          93 : TokenCollector::visit (DereferenceExpr &expr)
     872                 :             : {
     873                 :          93 :   push (Rust::Token::make (ASTERISK, expr.get_locus ()));
     874                 :          93 :   visit (expr.get_dereferenced_expr ());
     875                 :          93 : }
     876                 :             : 
     877                 :             : void
     878                 :           0 : TokenCollector::visit (ErrorPropagationExpr &expr)
     879                 :             : {
     880                 :           0 :   visit (expr.get_propagating_expr ());
     881                 :           0 :   push (Rust::Token::make (QUESTION_MARK, expr.get_locus ()));
     882                 :           0 : }
     883                 :             : 
     884                 :             : void
     885                 :         179 : TokenCollector::visit (NegationExpr &expr)
     886                 :             : {
     887                 :         179 :   switch (expr.get_expr_type ())
     888                 :             :     {
     889                 :         120 :     case NegationOperator::NEGATE:
     890                 :         120 :       push (Rust::Token::make (MINUS, expr.get_locus ()));
     891                 :         120 :       break;
     892                 :          59 :     case NegationOperator::NOT:
     893                 :          59 :       push (Rust::Token::make (EXCLAM, expr.get_locus ()));
     894                 :          59 :       break;
     895                 :             :     }
     896                 :         179 :   visit (expr.get_negated_expr ());
     897                 :         179 : }
     898                 :             : 
     899                 :             : void
     900                 :         361 : TokenCollector::visit (ArithmeticOrLogicalExpr &expr)
     901                 :             : {
     902                 :         361 :   visit (expr.get_left_expr ());
     903                 :         361 :   switch (expr.get_expr_type ())
     904                 :             :     {
     905                 :         211 :     case ArithmeticOrLogicalOperator::ADD:
     906                 :         211 :       push (Rust::Token::make (PLUS, expr.get_locus ()));
     907                 :         211 :       break;
     908                 :             : 
     909                 :          83 :     case ArithmeticOrLogicalOperator::SUBTRACT:
     910                 :          83 :       push (Rust::Token::make (MINUS, expr.get_locus ()));
     911                 :          83 :       break;
     912                 :             : 
     913                 :          25 :     case ArithmeticOrLogicalOperator::MULTIPLY:
     914                 :          25 :       push (Rust::Token::make (ASTERISK, expr.get_locus ()));
     915                 :          25 :       break;
     916                 :             : 
     917                 :           9 :     case ArithmeticOrLogicalOperator::DIVIDE:
     918                 :           9 :       push (Rust::Token::make (DIV, expr.get_locus ()));
     919                 :           9 :       break;
     920                 :             : 
     921                 :           7 :     case ArithmeticOrLogicalOperator::MODULUS:
     922                 :           7 :       push (Rust::Token::make (PERCENT, expr.get_locus ()));
     923                 :           7 :       break;
     924                 :             : 
     925                 :           8 :     case ArithmeticOrLogicalOperator::BITWISE_AND:
     926                 :           8 :       push (Rust::Token::make (AMP, expr.get_locus ()));
     927                 :           8 :       break;
     928                 :             : 
     929                 :           6 :     case ArithmeticOrLogicalOperator::BITWISE_OR:
     930                 :           6 :       push (Rust::Token::make (PIPE, expr.get_locus ()));
     931                 :           6 :       break;
     932                 :             : 
     933                 :           0 :     case ArithmeticOrLogicalOperator::BITWISE_XOR:
     934                 :           0 :       push (Rust::Token::make (CARET, expr.get_locus ()));
     935                 :           0 :       break;
     936                 :             : 
     937                 :           8 :     case ArithmeticOrLogicalOperator::LEFT_SHIFT:
     938                 :           8 :       push (Rust::Token::make (LEFT_SHIFT, expr.get_locus ()));
     939                 :           8 :       break;
     940                 :             : 
     941                 :           4 :     case ArithmeticOrLogicalOperator::RIGHT_SHIFT:
     942                 :           4 :       push (Rust::Token::make (RIGHT_SHIFT, expr.get_locus ()));
     943                 :           4 :       break;
     944                 :             :     }
     945                 :             : 
     946                 :         361 :   visit (expr.get_right_expr ());
     947                 :         361 : }
     948                 :             : 
     949                 :             : void
     950                 :         232 : TokenCollector::visit (ComparisonExpr &expr)
     951                 :             : {
     952                 :         232 :   visit (expr.get_left_expr ());
     953                 :             : 
     954                 :         232 :   switch (expr.get_expr_type ())
     955                 :             :     {
     956                 :          21 :     case ComparisonOperator::EQUAL:
     957                 :          21 :       push (Rust::Token::make (EQUAL_EQUAL, expr.get_locus ()));
     958                 :          21 :       break;
     959                 :         113 :     case ComparisonOperator::NOT_EQUAL:
     960                 :         113 :       push (Rust::Token::make (NOT_EQUAL, expr.get_locus ()));
     961                 :         113 :       break;
     962                 :          52 :     case ComparisonOperator::GREATER_THAN:
     963                 :          52 :       push (Rust::Token::make (RIGHT_ANGLE, expr.get_locus ()));
     964                 :          52 :       break;
     965                 :           2 :     case ComparisonOperator::LESS_THAN:
     966                 :           2 :       push (Rust::Token::make (LEFT_ANGLE, expr.get_locus ()));
     967                 :           2 :       break;
     968                 :           4 :     case ComparisonOperator::GREATER_OR_EQUAL:
     969                 :           4 :       push (Rust::Token::make (GREATER_OR_EQUAL, expr.get_locus ()));
     970                 :           4 :       break;
     971                 :             : 
     972                 :          40 :     case ComparisonOperator::LESS_OR_EQUAL:
     973                 :          40 :       push (Rust::Token::make (LESS_OR_EQUAL, expr.get_locus ()));
     974                 :          40 :       break;
     975                 :             :     }
     976                 :         232 :   visit (expr.get_right_expr ());
     977                 :         232 : }
     978                 :             : 
     979                 :             : void
     980                 :          40 : TokenCollector::visit (LazyBooleanExpr &expr)
     981                 :             : {
     982                 :          40 :   visit (expr.get_left_expr ());
     983                 :             : 
     984                 :          40 :   switch (expr.get_expr_type ())
     985                 :             :     {
     986                 :           8 :     case LazyBooleanOperator::LOGICAL_AND:
     987                 :           8 :       push (Rust::Token::make (LOGICAL_AND, expr.get_locus ()));
     988                 :           8 :       break;
     989                 :          32 :     case LazyBooleanOperator::LOGICAL_OR:
     990                 :          32 :       push (Rust::Token::make (OR, expr.get_locus ()));
     991                 :          32 :       break;
     992                 :             :     }
     993                 :             : 
     994                 :          40 :   visit (expr.get_right_expr ());
     995                 :          40 : }
     996                 :             : 
     997                 :             : void
     998                 :         245 : TokenCollector::visit (TypeCastExpr &expr)
     999                 :             : {
    1000                 :         245 :   visit (expr.get_casted_expr ());
    1001                 :         245 :   push (Rust::Token::make (AS, expr.get_locus ()));
    1002                 :         245 :   visit (expr.get_type_to_cast_to ());
    1003                 :         245 : }
    1004                 :             : 
    1005                 :             : void
    1006                 :         242 : TokenCollector::visit (AssignmentExpr &expr)
    1007                 :             : {
    1008                 :         242 :   expr.visit_lhs (*this);
    1009                 :         242 :   push (Rust::Token::make (EQUAL, expr.get_locus ()));
    1010                 :         242 :   expr.visit_rhs (*this);
    1011                 :         242 : }
    1012                 :             : 
    1013                 :             : void
    1014                 :           0 : TokenCollector::visit (CompoundAssignmentExpr &expr)
    1015                 :             : {
    1016                 :           0 :   visit (expr.get_left_expr ());
    1017                 :             : 
    1018                 :           0 :   switch (expr.get_expr_type ())
    1019                 :             :     {
    1020                 :           0 :     case CompoundAssignmentOperator::ADD:
    1021                 :           0 :       push (Rust::Token::make (PLUS_EQ, expr.get_locus ()));
    1022                 :           0 :       break;
    1023                 :           0 :     case CompoundAssignmentOperator::SUBTRACT:
    1024                 :           0 :       push (Rust::Token::make (MINUS_EQ, expr.get_locus ()));
    1025                 :           0 :       break;
    1026                 :           0 :     case CompoundAssignmentOperator::MULTIPLY:
    1027                 :           0 :       push (Rust::Token::make (ASTERISK_EQ, expr.get_locus ()));
    1028                 :           0 :       break;
    1029                 :           0 :     case CompoundAssignmentOperator::DIVIDE:
    1030                 :           0 :       push (Rust::Token::make (DIV_EQ, expr.get_locus ()));
    1031                 :           0 :       break;
    1032                 :           0 :     case CompoundAssignmentOperator::MODULUS:
    1033                 :           0 :       push (Rust::Token::make (PERCENT_EQ, expr.get_locus ()));
    1034                 :           0 :       break;
    1035                 :           0 :     case CompoundAssignmentOperator::BITWISE_AND:
    1036                 :           0 :       push (Rust::Token::make (AMP_EQ, expr.get_locus ()));
    1037                 :           0 :       break;
    1038                 :           0 :     case CompoundAssignmentOperator::BITWISE_OR:
    1039                 :           0 :       push (Rust::Token::make (PIPE_EQ, expr.get_locus ()));
    1040                 :           0 :       break;
    1041                 :           0 :     case CompoundAssignmentOperator::BITWISE_XOR:
    1042                 :           0 :       push (Rust::Token::make (CARET_EQ, expr.get_locus ()));
    1043                 :           0 :       break;
    1044                 :           0 :     case CompoundAssignmentOperator::LEFT_SHIFT:
    1045                 :           0 :       push (Rust::Token::make (LEFT_SHIFT_EQ, expr.get_locus ()));
    1046                 :           0 :       break;
    1047                 :           0 :     case CompoundAssignmentOperator::RIGHT_SHIFT:
    1048                 :           0 :       push (Rust::Token::make (RIGHT_SHIFT_EQ, expr.get_locus ()));
    1049                 :           0 :       break;
    1050                 :             :     }
    1051                 :           0 :   visit (expr.get_right_expr ());
    1052                 :           0 : }
    1053                 :             : 
    1054                 :             : void
    1055                 :          67 : TokenCollector::visit (GroupedExpr &expr)
    1056                 :             : {
    1057                 :          67 :   push (Rust::Token::make (LEFT_PAREN, expr.get_locus ()));
    1058                 :          67 :   visit (expr.get_expr_in_parens ());
    1059                 :          67 :   push (Rust::Token::make (RIGHT_PAREN, expr.get_locus ()));
    1060                 :          67 : }
    1061                 :             : 
    1062                 :             : void
    1063                 :          10 : TokenCollector::visit (ArrayElemsValues &elems)
    1064                 :             : {
    1065                 :          10 :   visit_items_joined_by_separator (elems.get_values (), COMMA);
    1066                 :          10 : }
    1067                 :             : 
    1068                 :             : void
    1069                 :           2 : TokenCollector::visit (ArrayElemsCopied &elems)
    1070                 :             : {
    1071                 :           2 :   visit (elems.get_elem_to_copy ());
    1072                 :           2 :   push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION));
    1073                 :           2 :   visit (elems.get_num_copies ());
    1074                 :           2 : }
    1075                 :             : 
    1076                 :             : void
    1077                 :          12 : TokenCollector::visit (ArrayExpr &expr)
    1078                 :             : {
    1079                 :          12 :   push (Rust::Token::make (LEFT_SQUARE, expr.get_locus ()));
    1080                 :          12 :   visit (expr.get_array_elems ());
    1081                 :          12 :   push (Rust::Token::make (RIGHT_SQUARE, UNDEF_LOCATION));
    1082                 :          12 : }
    1083                 :             : 
    1084                 :             : void
    1085                 :           6 : TokenCollector::visit (ArrayIndexExpr &expr)
    1086                 :             : {
    1087                 :           6 :   visit (expr.get_array_expr ());
    1088                 :           6 :   push (Rust::Token::make (LEFT_SQUARE, expr.get_locus ()));
    1089                 :           6 :   visit (expr.get_index_expr ());
    1090                 :           6 :   push (Rust::Token::make (RIGHT_SQUARE, UNDEF_LOCATION));
    1091                 :           6 : }
    1092                 :             : 
    1093                 :             : void
    1094                 :          66 : TokenCollector::visit (TupleExpr &expr)
    1095                 :             : {
    1096                 :          66 :   visit_items_as_lines (expr.get_outer_attrs ());
    1097                 :          66 :   push (Rust::Token::make (LEFT_PAREN, expr.get_locus ()));
    1098                 :          66 :   visit_items_joined_by_separator (expr.get_tuple_elems (), COMMA);
    1099                 :          66 :   push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
    1100                 :          66 : }
    1101                 :             : 
    1102                 :             : void
    1103                 :          78 : TokenCollector::visit (TupleIndexExpr &expr)
    1104                 :             : {
    1105                 :          78 :   visit (expr.get_tuple_expr ());
    1106                 :          78 :   push (Rust::Token::make (DOT, expr.get_locus ()));
    1107                 :         156 :   push (Rust::Token::make_int (UNDEF_LOCATION,
    1108                 :          78 :                                std::to_string (expr.get_tuple_index ())));
    1109                 :          78 : }
    1110                 :             : 
    1111                 :             : void
    1112                 :           7 : TokenCollector::visit (StructExprStruct &expr)
    1113                 :             : {
    1114                 :           7 :   visit (expr.get_struct_name ());
    1115                 :           7 : }
    1116                 :             : 
    1117                 :             : void
    1118                 :           2 : TokenCollector::visit (StructExprFieldIdentifier &expr)
    1119                 :             : {
    1120                 :           2 :   visit_items_as_lines (expr.get_outer_attrs ());
    1121                 :           4 :   auto id = expr.get_field_name ().as_string ();
    1122                 :           4 :   push (Rust::Token::make_identifier (expr.get_locus (), std::move (id)));
    1123                 :           2 : }
    1124                 :             : 
    1125                 :             : void
    1126                 :         370 : TokenCollector::visit (StructExprFieldIdentifierValue &expr)
    1127                 :             : {
    1128                 :         370 :   visit_items_as_lines (expr.get_outer_attrs ());
    1129                 :         370 :   auto id = expr.get_field_name ();
    1130                 :         370 :   push (Rust::Token::make_identifier (expr.get_locus (), std::move (id)));
    1131                 :         370 :   push (Rust::Token::make (COLON, UNDEF_LOCATION));
    1132                 :         370 :   visit (expr.get_value ());
    1133                 :         370 : }
    1134                 :             : 
    1135                 :             : void
    1136                 :           0 : TokenCollector::visit (StructExprFieldIndexValue &expr)
    1137                 :             : {
    1138                 :           0 :   visit_items_as_lines (expr.get_outer_attrs ());
    1139                 :           0 :   push (Rust::Token::make_int (expr.get_locus (),
    1140                 :           0 :                                std::to_string (expr.get_index ())));
    1141                 :           0 :   push (Rust::Token::make (COLON, UNDEF_LOCATION));
    1142                 :           0 :   visit (expr.get_value ());
    1143                 :           0 : }
    1144                 :             : 
    1145                 :             : void
    1146                 :          24 : TokenCollector::visit (StructBase &base)
    1147                 :             : {
    1148                 :          24 :   push (Rust::Token::make (DOT_DOT, UNDEF_LOCATION));
    1149                 :          24 :   visit (base.get_base_struct ());
    1150                 :          24 : }
    1151                 :             : 
    1152                 :             : void
    1153                 :         140 : TokenCollector::visit (StructExprStructFields &expr)
    1154                 :             : {
    1155                 :         140 :   visit (expr.get_struct_name ());
    1156                 :         140 :   push (Rust::Token::make (LEFT_CURLY, expr.get_locus ()));
    1157                 :         140 :   visit_items_joined_by_separator (expr.get_fields (), COMMA);
    1158                 :         140 :   if (expr.has_struct_base ())
    1159                 :             :     {
    1160                 :          24 :       push (Rust::Token::make (COMMA, UNDEF_LOCATION));
    1161                 :          24 :       visit (expr.get_struct_base ());
    1162                 :             :     }
    1163                 :             :   else
    1164                 :             :     {
    1165                 :         116 :       trailing_comma ();
    1166                 :             :     }
    1167                 :         140 :   push (Rust::Token::make (RIGHT_CURLY, expr.get_locus ()));
    1168                 :         140 : }
    1169                 :             : 
    1170                 :             : void
    1171                 :           0 : TokenCollector::visit (StructExprStructBase &)
    1172                 :             : {
    1173                 :             :   // FIXME: Implement this node
    1174                 :           0 :   rust_unreachable ();
    1175                 :             : }
    1176                 :             : 
    1177                 :             : void
    1178                 :         799 : TokenCollector::visit (CallExpr &expr)
    1179                 :             : {
    1180                 :         799 :   visit (expr.get_function_expr ());
    1181                 :             : 
    1182                 :         799 :   push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));
    1183                 :             : 
    1184                 :         799 :   visit_items_joined_by_separator (expr.get_params (), COMMA);
    1185                 :             : 
    1186                 :         799 :   push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
    1187                 :         799 : }
    1188                 :             : 
    1189                 :             : void
    1190                 :         270 : TokenCollector::visit (MethodCallExpr &expr)
    1191                 :             : {
    1192                 :         270 :   visit (expr.get_receiver_expr ());
    1193                 :         270 :   push (Rust::Token::make (DOT, expr.get_locus ()));
    1194                 :         270 :   visit (expr.get_method_name ());
    1195                 :         270 :   push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));
    1196                 :         270 :   visit_items_joined_by_separator (expr.get_params (), COMMA);
    1197                 :         270 :   trailing_comma ();
    1198                 :         270 :   push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
    1199                 :         270 : }
    1200                 :             : 
    1201                 :             : void
    1202                 :         140 : TokenCollector::visit (FieldAccessExpr &expr)
    1203                 :             : {
    1204                 :         140 :   visit (expr.get_receiver_expr ());
    1205                 :         140 :   push (Rust::Token::make (DOT, expr.get_locus ()));
    1206                 :         280 :   auto field_name = expr.get_field_name ().as_string ();
    1207                 :         280 :   push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (field_name)));
    1208                 :         140 : }
    1209                 :             : 
    1210                 :             : void
    1211                 :          16 : TokenCollector::visit (ClosureParam &param)
    1212                 :             : {
    1213                 :          16 :   visit_items_as_lines (param.get_outer_attrs ());
    1214                 :          16 :   visit (param.get_pattern ());
    1215                 :          16 :   if (param.has_type_given ())
    1216                 :             :     {
    1217                 :          16 :       push (Rust::Token::make (COLON, param.get_locus ()));
    1218                 :          16 :       visit (param.get_type ());
    1219                 :             :     }
    1220                 :          16 : }
    1221                 :             : 
    1222                 :             : void
    1223                 :          23 : TokenCollector::visit_closure_common (ClosureExpr &expr)
    1224                 :             : {
    1225                 :          23 :   if (expr.get_has_move ())
    1226                 :             :     {
    1227                 :           0 :       push (Rust::Token::make (MOVE, expr.get_locus ()));
    1228                 :             :     }
    1229                 :          23 :   push (Rust::Token::make (PIPE, UNDEF_LOCATION));
    1230                 :          23 :   visit_items_joined_by_separator (expr.get_params (), COMMA);
    1231                 :          23 :   push (Rust::Token::make (PIPE, UNDEF_LOCATION));
    1232                 :          23 : }
    1233                 :             : 
    1234                 :             : void
    1235                 :          21 : TokenCollector::visit (ClosureExprInner &expr)
    1236                 :             : {
    1237                 :          21 :   visit_closure_common (expr);
    1238                 :          21 :   visit (expr.get_definition_expr ());
    1239                 :          21 : }
    1240                 :             : 
    1241                 :             : void
    1242                 :        1690 : TokenCollector::visit (BlockExpr &expr)
    1243                 :             : {
    1244                 :        1690 :   visit_items_as_lines (expr.get_outer_attrs ());
    1245                 :        1690 :   push (Rust::Token::make (LEFT_CURLY, expr.get_locus ()));
    1246                 :        1690 :   newline ();
    1247                 :        1690 :   increment_indentation ();
    1248                 :        1690 :   visit_items_as_lines (expr.get_inner_attrs ());
    1249                 :             : 
    1250                 :        1690 :   visit_items_as_lines (expr.get_statements (), {});
    1251                 :             : 
    1252                 :        1690 :   if (expr.has_tail_expr ())
    1253                 :             :     {
    1254                 :         969 :       indentation ();
    1255                 :         969 :       visit (expr.get_tail_expr ());
    1256                 :         969 :       comment ("tail expr");
    1257                 :         969 :       newline ();
    1258                 :             :     }
    1259                 :             : 
    1260                 :        1690 :   decrement_indentation ();
    1261                 :        1690 :   indentation ();
    1262                 :        1690 :   push (Rust::Token::make (RIGHT_CURLY, expr.get_locus ()));
    1263                 :        1690 :   newline ();
    1264                 :        1690 : }
    1265                 :             : 
    1266                 :             : void
    1267                 :           2 : TokenCollector::visit (ClosureExprInnerTyped &expr)
    1268                 :             : {
    1269                 :           2 :   visit_closure_common (expr);
    1270                 :           2 :   push (Rust::Token::make (RETURN_TYPE, expr.get_locus ()));
    1271                 :           2 :   visit (expr.get_return_type ());
    1272                 :           2 :   visit (expr.get_definition_block ());
    1273                 :           2 : }
    1274                 :             : 
    1275                 :             : void
    1276                 :           0 : TokenCollector::visit (ContinueExpr &expr)
    1277                 :             : {
    1278                 :           0 :   push (Rust::Token::make (CONTINUE, expr.get_locus ()));
    1279                 :           0 :   if (expr.has_label ())
    1280                 :           0 :     visit (expr.get_label_unchecked ());
    1281                 :           0 : }
    1282                 :             : 
    1283                 :             : void
    1284                 :          27 : TokenCollector::visit (BreakExpr &expr)
    1285                 :             : {
    1286                 :          27 :   push (Rust::Token::make (BREAK, expr.get_locus ()));
    1287                 :          27 :   if (expr.has_label ())
    1288                 :           0 :     visit (expr.get_label_unchecked ());
    1289                 :          27 :   if (expr.has_break_expr ())
    1290                 :           0 :     visit (expr.get_break_expr ());
    1291                 :          27 : }
    1292                 :             : 
    1293                 :             : void
    1294                 :          27 : TokenCollector::visit (RangeFromToExpr &expr)
    1295                 :             : {
    1296                 :          27 :   visit (expr.get_from_expr ());
    1297                 :          27 :   push (Rust::Token::make (DOT_DOT, expr.get_locus ()));
    1298                 :          27 :   visit (expr.get_to_expr ());
    1299                 :          27 : }
    1300                 :             : 
    1301                 :             : void
    1302                 :           0 : TokenCollector::visit (RangeFromExpr &expr)
    1303                 :             : {
    1304                 :           0 :   visit (expr.get_from_expr ());
    1305                 :           0 :   push (Rust::Token::make (DOT_DOT, expr.get_locus ()));
    1306                 :           0 : }
    1307                 :             : 
    1308                 :             : void
    1309                 :           0 : TokenCollector::visit (RangeToExpr &expr)
    1310                 :             : {
    1311                 :           0 :   push (Rust::Token::make (DOT_DOT, expr.get_locus ()));
    1312                 :           0 :   visit (expr.get_to_expr ());
    1313                 :           0 : }
    1314                 :             : 
    1315                 :             : void
    1316                 :           0 : TokenCollector::visit (RangeFullExpr &expr)
    1317                 :             : {
    1318                 :           0 :   push (Rust::Token::make (DOT_DOT, expr.get_locus ()));
    1319                 :           0 : }
    1320                 :             : 
    1321                 :             : void
    1322                 :           0 : TokenCollector::visit (RangeFromToInclExpr &expr)
    1323                 :             : {
    1324                 :           0 :   visit (expr.get_from_expr ());
    1325                 :           0 :   push (Rust::Token::make (DOT_DOT_EQ, expr.get_locus ()));
    1326                 :           0 :   visit (expr.get_to_expr ());
    1327                 :           0 : }
    1328                 :             : 
    1329                 :             : void
    1330                 :           0 : TokenCollector::visit (RangeToInclExpr &expr)
    1331                 :             : {
    1332                 :           0 :   push (Rust::Token::make (DOT_DOT_EQ, expr.get_locus ()));
    1333                 :           0 :   visit (expr.get_to_expr ());
    1334                 :           0 : }
    1335                 :             : 
    1336                 :             : void
    1337                 :           0 : TokenCollector::visit (BoxExpr &expr)
    1338                 :             : {
    1339                 :           0 :   push (Rust::Token::make (BOX, expr.get_locus ()));
    1340                 :           0 :   visit (expr.get_boxed_expr ());
    1341                 :           0 : }
    1342                 :             : 
    1343                 :             : void
    1344                 :           0 : TokenCollector::visit (ReturnExpr &expr)
    1345                 :             : {
    1346                 :           0 :   push (Rust::Token::make (RETURN_KW, expr.get_locus ()));
    1347                 :           0 :   if (expr.has_returned_expr ())
    1348                 :           0 :     visit (expr.get_returned_expr ());
    1349                 :           0 : }
    1350                 :             : 
    1351                 :             : void
    1352                 :         414 : TokenCollector::visit (UnsafeBlockExpr &expr)
    1353                 :             : {
    1354                 :         414 :   push (Rust::Token::make (UNSAFE, expr.get_locus ()));
    1355                 :         414 :   visit (expr.get_block_expr ());
    1356                 :         414 : }
    1357                 :             : 
    1358                 :             : void
    1359                 :           0 : TokenCollector::visit (LoopLabel &label)
    1360                 :             : {
    1361                 :           0 :   visit (label.get_lifetime ());
    1362                 :           0 :   push (Rust::Token::make (COLON, label.get_locus ()));
    1363                 :           0 : }
    1364                 :             : 
    1365                 :             : void
    1366                 :          34 : TokenCollector::visit_loop_common (BaseLoopExpr &expr)
    1367                 :             : {
    1368                 :          34 :   if (expr.has_loop_label ())
    1369                 :           0 :     visit (expr.get_loop_label ());
    1370                 :          34 : }
    1371                 :             : 
    1372                 :             : void
    1373                 :          27 : TokenCollector::visit (LoopExpr &expr)
    1374                 :             : {
    1375                 :          27 :   visit_loop_common (expr);
    1376                 :          27 :   push (Rust::Token::make (LOOP, expr.get_locus ()));
    1377                 :          27 :   visit (expr.get_loop_block ());
    1378                 :          27 : }
    1379                 :             : 
    1380                 :             : void
    1381                 :           7 : TokenCollector::visit (WhileLoopExpr &expr)
    1382                 :             : {
    1383                 :           7 :   visit_loop_common (expr);
    1384                 :           7 :   push (Rust::Token::make (WHILE, expr.get_locus ()));
    1385                 :           7 :   visit (expr.get_predicate_expr ());
    1386                 :           7 :   visit (expr.get_loop_block ());
    1387                 :           7 : }
    1388                 :             : 
    1389                 :             : void
    1390                 :           0 : TokenCollector::visit (WhileLetLoopExpr &expr)
    1391                 :             : {
    1392                 :           0 :   visit_loop_common (expr);
    1393                 :           0 :   push (Rust::Token::make (WHILE, expr.get_locus ()));
    1394                 :           0 :   push (Rust::Token::make (LET, UNDEF_LOCATION));
    1395                 :             :   // TODO: The reference mention only one Pattern
    1396                 :           0 :   for (auto &item : expr.get_patterns ())
    1397                 :             :     {
    1398                 :           0 :       visit (item);
    1399                 :             :     }
    1400                 :           0 :   push (Rust::Token::make (EQUAL, UNDEF_LOCATION));
    1401                 :           0 :   visit (expr.get_scrutinee_expr ());
    1402                 :           0 :   visit (expr.get_loop_block ());
    1403                 :           0 : }
    1404                 :             : 
    1405                 :             : void
    1406                 :           0 : TokenCollector::visit (ForLoopExpr &expr)
    1407                 :             : {
    1408                 :           0 :   visit_loop_common (expr);
    1409                 :           0 :   push (Rust::Token::make (FOR, expr.get_locus ()));
    1410                 :           0 :   visit (expr.get_pattern ());
    1411                 :           0 :   push (Rust::Token::make (IN, UNDEF_LOCATION));
    1412                 :           0 :   visit (expr.get_iterator_expr ());
    1413                 :           0 :   visit (expr.get_loop_block ());
    1414                 :           0 : }
    1415                 :             : 
    1416                 :             : void
    1417                 :         237 : TokenCollector::visit (IfExpr &expr)
    1418                 :             : {
    1419                 :         237 :   push (Rust::Token::make (IF, expr.get_locus ()));
    1420                 :         237 :   visit (expr.get_condition_expr ());
    1421                 :         237 :   visit (expr.get_if_block ());
    1422                 :         237 : }
    1423                 :             : 
    1424                 :             : void
    1425                 :          35 : TokenCollector::visit (IfExprConseqElse &expr)
    1426                 :             : {
    1427                 :          35 :   visit (static_cast<IfExpr &> (expr));
    1428                 :          35 :   indentation ();
    1429                 :          35 :   push (Rust::Token::make (ELSE, expr.get_locus ()));
    1430                 :          35 :   visit (expr.get_else_block ());
    1431                 :          35 : }
    1432                 :             : 
    1433                 :             : void
    1434                 :           6 : TokenCollector::visit (IfLetExpr &expr)
    1435                 :             : {
    1436                 :           6 :   push (Rust::Token::make (IF, expr.get_locus ()));
    1437                 :           6 :   push (Rust::Token::make (LET, UNDEF_LOCATION));
    1438                 :          12 :   for (auto &pattern : expr.get_patterns ())
    1439                 :             :     {
    1440                 :           6 :       visit (pattern);
    1441                 :             :     }
    1442                 :           6 :   push (Rust::Token::make (EQUAL, UNDEF_LOCATION));
    1443                 :           6 :   visit (expr.get_value_expr ());
    1444                 :           6 :   visit (expr.get_if_block ());
    1445                 :           6 : }
    1446                 :             : 
    1447                 :             : void
    1448                 :           4 : TokenCollector::visit (IfLetExprConseqElse &expr)
    1449                 :             : {
    1450                 :           4 :   visit (static_cast<IfLetExpr &> (expr));
    1451                 :           4 :   indentation ();
    1452                 :           4 :   push (Rust::Token::make (ELSE, expr.get_locus ()));
    1453                 :           4 :   visit (expr.get_else_block ());
    1454                 :           4 : }
    1455                 :             : 
    1456                 :             : void
    1457                 :         126 : TokenCollector::visit (MatchArm &arm)
    1458                 :             : {
    1459                 :         126 :   visit_items_as_lines (arm.get_outer_attrs ());
    1460                 :         252 :   for (auto &pattern : arm.get_patterns ())
    1461                 :             :     {
    1462                 :         126 :       visit (pattern);
    1463                 :             :     }
    1464                 :         126 :   if (arm.has_match_arm_guard ())
    1465                 :             :     {
    1466                 :           2 :       push (Rust::Token::make (IF, UNDEF_LOCATION));
    1467                 :           2 :       visit (arm.get_guard_expr ());
    1468                 :             :     }
    1469                 :         126 : }
    1470                 :             : 
    1471                 :             : void
    1472                 :         126 : TokenCollector::visit (MatchCase &match_case)
    1473                 :             : {
    1474                 :         126 :   indentation ();
    1475                 :         126 :   visit (match_case.get_arm ());
    1476                 :         126 :   push (Rust::Token::make (MATCH_ARROW, UNDEF_LOCATION));
    1477                 :         126 :   visit (match_case.get_expr ());
    1478                 :         126 :   indentation ();
    1479                 :         126 :   push (Rust::Token::make (COMMA, UNDEF_LOCATION));
    1480                 :         126 :   newline ();
    1481                 :         126 : }
    1482                 :             : 
    1483                 :             : void
    1484                 :          75 : TokenCollector::visit (MatchExpr &expr)
    1485                 :             : {
    1486                 :          75 :   push (Rust::Token::make (MATCH_KW, expr.get_locus ()));
    1487                 :          75 :   visit (expr.get_scrutinee_expr ());
    1488                 :          75 :   push (Rust::Token::make (LEFT_CURLY, UNDEF_LOCATION));
    1489                 :          75 :   newline ();
    1490                 :          75 :   increment_indentation ();
    1491                 :          75 :   visit_items_as_lines (expr.get_inner_attrs ());
    1492                 :         201 :   for (auto &arm : expr.get_match_cases ())
    1493                 :             :     {
    1494                 :         126 :       visit (arm);
    1495                 :             :     }
    1496                 :          75 :   decrement_indentation ();
    1497                 :          75 :   indentation ();
    1498                 :          75 :   push (Rust::Token::make (RIGHT_CURLY, UNDEF_LOCATION));
    1499                 :          75 : }
    1500                 :             : 
    1501                 :             : void
    1502                 :           0 : TokenCollector::visit (AwaitExpr &expr)
    1503                 :             : {
    1504                 :           0 :   visit (expr.get_awaited_expr ());
    1505                 :           0 :   push (Rust::Token::make (DOT, expr.get_locus ()));
    1506                 :             :   // TODO: Check status of await keyword (Context dependant ?)
    1507                 :           0 :   push (Rust::Token::make_identifier (UNDEF_LOCATION, Values::Keywords::AWAIT));
    1508                 :           0 : }
    1509                 :             : 
    1510                 :             : void
    1511                 :           0 : TokenCollector::visit (AsyncBlockExpr &expr)
    1512                 :             : {
    1513                 :           0 :   push (Rust::Token::make (ASYNC, expr.get_locus ()));
    1514                 :           0 :   if (expr.get_has_move ())
    1515                 :           0 :     push (Rust::Token::make (MOVE, UNDEF_LOCATION));
    1516                 :           0 :   visit (expr.get_block_expr ());
    1517                 :           0 : }
    1518                 :             : 
    1519                 :             : void
    1520                 :           0 : TokenCollector::visit (InlineAsm &expr)
    1521                 :           0 : {}
    1522                 :             : 
    1523                 :             : void
    1524                 :           2 : TokenCollector::visit (LlvmInlineAsm &expr)
    1525                 :             : {
    1526                 :           4 :   push (Rust::Token::make_identifier (expr.get_locus (), "llvm_asm"));
    1527                 :           2 :   push (Rust::Token::make (EXCLAM, expr.get_locus ()));
    1528                 :           2 :   push (Rust::Token::make (LEFT_PAREN, expr.get_locus ()));
    1529                 :           4 :   for (auto &template_str : expr.get_templates ())
    1530                 :           4 :     push (Rust::Token::make_string (template_str.get_locus (),
    1531                 :           2 :                                     std::move (template_str.symbol)));
    1532                 :             : 
    1533                 :           2 :   push (Rust::Token::make (COLON, expr.get_locus ()));
    1534                 :           2 :   for (auto output : expr.get_outputs ())
    1535                 :             :     {
    1536                 :           0 :       push (Rust::Token::make_string (expr.get_locus (),
    1537                 :             :                                       std::move (output.constraint)));
    1538                 :           0 :       visit (output.expr);
    1539                 :           0 :       push (Rust::Token::make (COMMA, expr.get_locus ()));
    1540                 :           0 :     }
    1541                 :             : 
    1542                 :           2 :   push (Rust::Token::make (COLON, expr.get_locus ()));
    1543                 :           4 :   for (auto input : expr.get_inputs ())
    1544                 :             :     {
    1545                 :           2 :       push (Rust::Token::make_string (expr.get_locus (),
    1546                 :             :                                       std::move (input.constraint)));
    1547                 :           2 :       visit (input.expr);
    1548                 :           4 :       push (Rust::Token::make (COMMA, expr.get_locus ()));
    1549                 :           2 :     }
    1550                 :             : 
    1551                 :           2 :   push (Rust::Token::make (COLON, expr.get_locus ()));
    1552                 :           4 :   for (auto &clobber : expr.get_clobbers ())
    1553                 :             :     {
    1554                 :           2 :       push (Rust::Token::make_string (expr.get_locus (),
    1555                 :           2 :                                       std::move (clobber.symbol)));
    1556                 :           4 :       push (Rust::Token::make (COMMA, expr.get_locus ()));
    1557                 :             :     }
    1558                 :           2 :   push (Rust::Token::make (COLON, expr.get_locus ()));
    1559                 :             :   // Dump options
    1560                 :             : 
    1561                 :           2 :   push (Rust::Token::make (RIGHT_PAREN, expr.get_locus ()));
    1562                 :           2 : }
    1563                 :             : 
    1564                 :             : // rust-item.h
    1565                 :             : 
    1566                 :             : void
    1567                 :         352 : TokenCollector::visit (TypeParam &param)
    1568                 :             : {
    1569                 :             :   // Syntax:
    1570                 :             :   //    IDENTIFIER( : TypeParamBounds? )? ( = Type )?
    1571                 :             :   // TypeParamBounds :
    1572                 :             :   //    TypeParamBound ( + TypeParamBound )* +?
    1573                 :             : 
    1574                 :         352 :   visit_items_as_lines (param.get_outer_attrs ());
    1575                 :         704 :   auto id = param.get_type_representation ().as_string ();
    1576                 :         352 :   push (Rust::Token::make_identifier (param.get_locus (), std::move (id)));
    1577                 :         352 :   if (param.has_type_param_bounds ())
    1578                 :             :     {
    1579                 :          35 :       push (Rust::Token::make (COLON, UNDEF_LOCATION));
    1580                 :          35 :       visit_items_joined_by_separator (param.get_type_param_bounds (), PLUS);
    1581                 :             :     }
    1582                 :         352 :   if (param.has_type ())
    1583                 :             :     {
    1584                 :         118 :       push (Rust::Token::make (EQUAL, UNDEF_LOCATION));
    1585                 :         118 :       visit (param.get_type ());
    1586                 :             :     }
    1587                 :         352 : }
    1588                 :             : 
    1589                 :             : void
    1590                 :           4 : TokenCollector::visit (WhereClause &rule)
    1591                 :             : {
    1592                 :             :   // Syntax:
    1593                 :             :   //    where ( WhereClauseItem , )* WhereClauseItem ?
    1594                 :             :   // WhereClauseItem :
    1595                 :             :   //    LifetimeWhereClauseItem
    1596                 :             :   //    | TypeBoundWhereClauseItem
    1597                 :             : 
    1598                 :           4 :   push (Rust::Token::make (WHERE, UNDEF_LOCATION));
    1599                 :           4 :   newline ();
    1600                 :           4 :   increment_indentation ();
    1601                 :           4 :   visit_items_joined_by_separator (rule.get_items (), COMMA);
    1602                 :           4 :   decrement_indentation ();
    1603                 :           4 : }
    1604                 :             : 
    1605                 :             : void
    1606                 :           0 : TokenCollector::visit (LifetimeWhereClauseItem &item)
    1607                 :             : {
    1608                 :             :   // Syntax:
    1609                 :             :   //    Lifetime : LifetimeBounds
    1610                 :             :   // LifetimeBounds :
    1611                 :             :   //   ( Lifetime + )* Lifetime?
    1612                 :             : 
    1613                 :           0 :   visit (item.get_lifetime ());
    1614                 :           0 :   push (Rust::Token::make (COLON, UNDEF_LOCATION));
    1615                 :           0 :   visit_items_joined_by_separator (item.get_lifetime_bounds (), PLUS);
    1616                 :           0 : }
    1617                 :             : 
    1618                 :             : void
    1619                 :           4 : TokenCollector::visit (TypeBoundWhereClauseItem &item)
    1620                 :             : {
    1621                 :             :   // Syntax:
    1622                 :             :   //    ForLifetimes? Type : TypeParamBounds?
    1623                 :             :   // TypeParamBounds :
    1624                 :             :   //    TypeParamBound ( + TypeParamBound )* +?
    1625                 :             :   // TypeParamBound :
    1626                 :             :   //    Lifetime | TraitBound
    1627                 :             : 
    1628                 :           4 :   if (item.has_for_lifetimes ())
    1629                 :           0 :     visit (item.get_for_lifetimes ());
    1630                 :             : 
    1631                 :           4 :   visit (item.get_type ());
    1632                 :             : 
    1633                 :           4 :   push (Rust::Token::make (COLON, UNDEF_LOCATION));
    1634                 :           4 :   visit_items_joined_by_separator (item.get_type_param_bounds (), PLUS);
    1635                 :           4 : }
    1636                 :             : 
    1637                 :             : void
    1638                 :           0 : TokenCollector::visit (Module &module)
    1639                 :             : {
    1640                 :             :   //  Syntax:
    1641                 :             :   //    mod IDENTIFIER ;
    1642                 :             :   //     | mod IDENTIFIER {
    1643                 :             :   //      InnerAttribute*
    1644                 :             :   //      Item*
    1645                 :             :   //    }
    1646                 :             : 
    1647                 :           0 :   visit_items_as_lines (module.get_outer_attrs ());
    1648                 :           0 :   visit (module.get_visibility ());
    1649                 :           0 :   auto name = module.get_name ().as_string ();
    1650                 :           0 :   push (Rust::Token::make (MOD, module.get_locus ()));
    1651                 :           0 :   push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (name)));
    1652                 :             : 
    1653                 :           0 :   if (module.get_kind () == Module::UNLOADED)
    1654                 :             :     {
    1655                 :           0 :       push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION));
    1656                 :           0 :       newline ();
    1657                 :             :     }
    1658                 :             :   else /* Module::LOADED */
    1659                 :             :     {
    1660                 :           0 :       push (Rust::Token::make (LEFT_CURLY, UNDEF_LOCATION));
    1661                 :           0 :       newline ();
    1662                 :           0 :       increment_indentation ();
    1663                 :             : 
    1664                 :           0 :       visit_items_as_lines (module.get_inner_attrs ());
    1665                 :           0 :       visit_items_as_lines (module.get_items ());
    1666                 :             : 
    1667                 :           0 :       decrement_indentation ();
    1668                 :             : 
    1669                 :           0 :       push (Rust::Token::make (RIGHT_CURLY, UNDEF_LOCATION));
    1670                 :           0 :       newline ();
    1671                 :             :     }
    1672                 :           0 : }
    1673                 :             : 
    1674                 :             : void
    1675                 :           0 : TokenCollector::visit (ExternCrate &crate)
    1676                 :             : {
    1677                 :           0 :   visit_items_as_lines (crate.get_outer_attrs ());
    1678                 :           0 :   push (Rust::Token::make (EXTERN_KW, crate.get_locus ()));
    1679                 :           0 :   push (Rust::Token::make (CRATE, UNDEF_LOCATION));
    1680                 :           0 :   auto ref = crate.get_referenced_crate ();
    1681                 :           0 :   push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (ref)));
    1682                 :           0 :   if (crate.has_as_clause ())
    1683                 :             :     {
    1684                 :           0 :       auto as_clause = crate.get_as_clause ();
    1685                 :           0 :       push (Rust::Token::make (AS, UNDEF_LOCATION));
    1686                 :           0 :       push (
    1687                 :           0 :         Rust::Token::make_identifier (UNDEF_LOCATION, std::move (as_clause)));
    1688                 :           0 :     }
    1689                 :           0 :   push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION));
    1690                 :           0 :   newline ();
    1691                 :           0 : }
    1692                 :             : 
    1693                 :             : void
    1694                 :           0 : TokenCollector::visit (UseTreeGlob &use_tree)
    1695                 :             : {
    1696                 :           0 :   switch (use_tree.get_glob_type ())
    1697                 :             :     {
    1698                 :           0 :       case UseTreeGlob::PathType::PATH_PREFIXED: {
    1699                 :           0 :         auto path = use_tree.get_path ();
    1700                 :           0 :         visit (path);
    1701                 :           0 :         push (Rust::Token::make (SCOPE_RESOLUTION, UNDEF_LOCATION));
    1702                 :           0 :       }
    1703                 :           0 :       break;
    1704                 :           0 :     case UseTreeGlob::PathType::NO_PATH:
    1705                 :           0 :       push (Rust::Token::make (SCOPE_RESOLUTION, UNDEF_LOCATION));
    1706                 :           0 :       break;
    1707                 :             :     case UseTreeGlob::PathType::GLOBAL:
    1708                 :             :       break;
    1709                 :             :     }
    1710                 :           0 :   push (Rust::Token::make (ASTERISK, UNDEF_LOCATION));
    1711                 :           0 : }
    1712                 :             : 
    1713                 :             : void
    1714                 :           0 : TokenCollector::visit (UseTreeList &use_tree)
    1715                 :             : {
    1716                 :           0 :   switch (use_tree.get_path_type ())
    1717                 :             :     {
    1718                 :           0 :       case UseTreeList::PathType::PATH_PREFIXED: {
    1719                 :           0 :         auto path = use_tree.get_path ();
    1720                 :           0 :         visit (path);
    1721                 :           0 :         push (Rust::Token::make (SCOPE_RESOLUTION, UNDEF_LOCATION));
    1722                 :           0 :       }
    1723                 :           0 :       break;
    1724                 :           0 :     case UseTreeList::PathType::NO_PATH:
    1725                 :           0 :       push (Rust::Token::make (SCOPE_RESOLUTION, UNDEF_LOCATION));
    1726                 :           0 :       break;
    1727                 :             :     case UseTreeList::PathType::GLOBAL:
    1728                 :             :       break;
    1729                 :             :     }
    1730                 :             : 
    1731                 :           0 :   push (Rust::Token::make (LEFT_CURLY, UNDEF_LOCATION));
    1732                 :           0 :   if (use_tree.has_trees ())
    1733                 :             :     {
    1734                 :           0 :       visit_items_joined_by_separator (use_tree.get_trees (), COMMA);
    1735                 :             :     }
    1736                 :           0 :   push (Rust::Token::make (RIGHT_CURLY, UNDEF_LOCATION));
    1737                 :           0 : }
    1738                 :             : 
    1739                 :             : void
    1740                 :           0 : TokenCollector::visit (UseTreeRebind &use_tree)
    1741                 :             : {
    1742                 :           0 :   auto path = use_tree.get_path ();
    1743                 :           0 :   visit (path);
    1744                 :           0 :   switch (use_tree.get_new_bind_type ())
    1745                 :             :     {
    1746                 :           0 :       case UseTreeRebind::NewBindType::IDENTIFIER: {
    1747                 :           0 :         push (Rust::Token::make (AS, UNDEF_LOCATION));
    1748                 :           0 :         auto id = use_tree.get_identifier ().as_string ();
    1749                 :           0 :         push (
    1750                 :           0 :           Rust::Token::make_identifier (use_tree.get_locus (), std::move (id)));
    1751                 :           0 :       }
    1752                 :           0 :       break;
    1753                 :           0 :     case UseTreeRebind::NewBindType::WILDCARD:
    1754                 :           0 :       push (Rust::Token::make (AS, UNDEF_LOCATION));
    1755                 :           0 :       push (Rust::Token::make (UNDERSCORE, use_tree.get_locus ()));
    1756                 :           0 :       break;
    1757                 :             :     case UseTreeRebind::NewBindType::NONE:
    1758                 :             :       break;
    1759                 :             :     }
    1760                 :           0 : }
    1761                 :             : 
    1762                 :             : void
    1763                 :           0 : TokenCollector::visit (UseDeclaration &decl)
    1764                 :             : {
    1765                 :           0 :   visit_items_as_lines (decl.get_outer_attrs ());
    1766                 :           0 :   push (Rust::Token::make (USE, decl.get_locus ()));
    1767                 :           0 :   visit (*decl.get_tree ());
    1768                 :           0 :   push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION));
    1769                 :           0 :   newline ();
    1770                 :           0 : }
    1771                 :             : 
    1772                 :             : void
    1773                 :        1595 : TokenCollector::visit (Function &function)
    1774                 :             : {
    1775                 :             :   // Syntax:
    1776                 :             :   //   FunctionQualifiers fn IDENTIFIER GenericParams?
    1777                 :             :   //      ( FunctionParameters? )
    1778                 :             :   //      FunctionReturnType? WhereClause?
    1779                 :             :   //      ( BlockExpression | ; )
    1780                 :        1595 :   visit_items_as_lines (function.get_outer_attrs ());
    1781                 :             : 
    1782                 :        1595 :   visit (function.get_visibility ());
    1783                 :        1595 :   auto qualifiers = function.get_qualifiers ();
    1784                 :        1595 :   visit (qualifiers);
    1785                 :             : 
    1786                 :        1595 :   push (Rust::Token::make (FN_KW, function.get_locus ()));
    1787                 :        3190 :   auto name = function.get_function_name ().as_string ();
    1788                 :        1595 :   push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (name)));
    1789                 :        1595 :   if (function.has_generics ())
    1790                 :          79 :     visit (function.get_generic_params ());
    1791                 :             : 
    1792                 :        1595 :   push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));
    1793                 :             : 
    1794                 :        1595 :   visit_items_joined_by_separator (function.get_function_params ());
    1795                 :        1595 :   push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
    1796                 :             : 
    1797                 :        1595 :   if (function.has_return_type ())
    1798                 :             :     {
    1799                 :        1068 :       push (Rust::Token::make (RETURN_TYPE, UNDEF_LOCATION));
    1800                 :        1068 :       visit (function.get_return_type ());
    1801                 :             :     }
    1802                 :             : 
    1803                 :        1595 :   if (function.has_where_clause ())
    1804                 :           4 :     visit (function.get_where_clause ());
    1805                 :             : 
    1806                 :        1595 :   if (function.has_body ())
    1807                 :         887 :     visit (*function.get_definition ());
    1808                 :             :   else
    1809                 :        1416 :     push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION));
    1810                 :        1595 :   newline ();
    1811                 :        1595 : }
    1812                 :             : 
    1813                 :             : void
    1814                 :           0 : TokenCollector::visit (TypeAlias &type_alias)
    1815                 :             : {
    1816                 :             :   // Syntax:
    1817                 :             :   // Visibility? type IDENTIFIER GenericParams? WhereClause? = Type;
    1818                 :             : 
    1819                 :             :   // Note: Associated types are handled by `AST::TraitItemType`.
    1820                 :             : 
    1821                 :           0 :   visit_items_as_lines (type_alias.get_outer_attrs ());
    1822                 :           0 :   if (type_alias.has_visibility ())
    1823                 :           0 :     visit (type_alias.get_visibility ());
    1824                 :           0 :   auto alias_name = type_alias.get_new_type_name ().as_string ();
    1825                 :           0 :   push (Rust::Token::make (TYPE, type_alias.get_locus ()));
    1826                 :           0 :   push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (alias_name)));
    1827                 :             : 
    1828                 :           0 :   if (type_alias.has_generics ())
    1829                 :           0 :     visit (type_alias.get_generic_params ());
    1830                 :             : 
    1831                 :           0 :   if (type_alias.has_where_clause ())
    1832                 :           0 :     visit (type_alias.get_where_clause ());
    1833                 :             : 
    1834                 :           0 :   push (Rust::Token::make (EQUAL, UNDEF_LOCATION));
    1835                 :           0 :   visit (type_alias.get_type_aliased ());
    1836                 :           0 :   push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION));
    1837                 :           0 : }
    1838                 :             : 
    1839                 :             : void
    1840                 :           8 : TokenCollector::visit (StructStruct &struct_item)
    1841                 :             : {
    1842                 :           8 :   visit_items_as_lines (struct_item.get_outer_attrs ());
    1843                 :           8 :   if (struct_item.has_visibility ())
    1844                 :           0 :     visit (struct_item.get_visibility ());
    1845                 :          16 :   auto struct_name = struct_item.get_identifier ().as_string ();
    1846                 :           8 :   push (Rust::Token::make (STRUCT_KW, struct_item.get_locus ()));
    1847                 :           8 :   push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (struct_name)));
    1848                 :             : 
    1849                 :           8 :   if (struct_item.has_generics ())
    1850                 :           0 :     visit (struct_item.get_generic_params ());
    1851                 :           8 :   if (struct_item.has_where_clause ())
    1852                 :           0 :     visit (struct_item.get_where_clause ());
    1853                 :           8 :   if (struct_item.is_unit_struct ())
    1854                 :             :     {
    1855                 :           0 :       push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION));
    1856                 :           0 :       newline ();
    1857                 :             :     }
    1858                 :             :   else
    1859                 :          16 :     visit_items_as_block (struct_item.get_fields (),
    1860                 :             :                           {Rust::Token::make (COMMA, UNDEF_LOCATION)});
    1861                 :           8 : }
    1862                 :             : 
    1863                 :             : void
    1864                 :          26 : TokenCollector::visit (TupleStruct &tuple_struct)
    1865                 :             : {
    1866                 :          26 :   visit_items_as_lines (tuple_struct.get_outer_attrs ());
    1867                 :          52 :   auto struct_name = tuple_struct.get_identifier ().as_string ();
    1868                 :          26 :   push (Rust::Token::make (STRUCT_KW, tuple_struct.get_locus ()));
    1869                 :          26 :   push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (struct_name)));
    1870                 :          26 :   if (tuple_struct.has_generics ())
    1871                 :           0 :     visit (tuple_struct.get_generic_params ());
    1872                 :          26 :   if (tuple_struct.has_where_clause ())
    1873                 :           0 :     visit (tuple_struct.get_where_clause ());
    1874                 :             : 
    1875                 :          26 :   push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));
    1876                 :          26 :   visit_items_joined_by_separator (tuple_struct.get_fields (), COMMA);
    1877                 :          26 :   push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
    1878                 :          26 :   push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION));
    1879                 :          26 :   newline ();
    1880                 :          26 : }
    1881                 :             : 
    1882                 :             : void
    1883                 :           2 : TokenCollector::visit (EnumItem &item)
    1884                 :             : {
    1885                 :           2 :   visit_items_as_lines (item.get_outer_attrs ());
    1886                 :           4 :   auto id = item.get_identifier ().as_string ();
    1887                 :           4 :   push (Rust::Token::make_identifier (item.get_locus (), std::move (id)));
    1888                 :           2 : }
    1889                 :             : 
    1890                 :             : void
    1891                 :           4 : TokenCollector::visit (EnumItemTuple &item)
    1892                 :             : {
    1893                 :           8 :   auto id = item.get_identifier ().as_string ();
    1894                 :           4 :   push (Rust::Token::make_identifier (item.get_locus (), std::move (id)));
    1895                 :           4 :   push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));
    1896                 :           4 :   visit_items_joined_by_separator (item.get_tuple_fields (), COMMA);
    1897                 :           8 :   push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
    1898                 :           4 : }
    1899                 :             : 
    1900                 :             : void
    1901                 :           0 : TokenCollector::visit (EnumItemStruct &item)
    1902                 :             : {
    1903                 :           0 :   auto id = item.get_identifier ().as_string ();
    1904                 :           0 :   push (Rust::Token::make_identifier (item.get_locus (), std::move (id)));
    1905                 :           0 :   visit_items_as_block (item.get_struct_fields (),
    1906                 :             :                         {Rust::Token::make (COMMA, UNDEF_LOCATION)});
    1907                 :           0 : }
    1908                 :             : 
    1909                 :             : void
    1910                 :           0 : TokenCollector::visit (EnumItemDiscriminant &item)
    1911                 :             : {
    1912                 :           0 :   auto id = item.get_identifier ().as_string ();
    1913                 :           0 :   push (Rust::Token::make_identifier (item.get_locus (), std::move (id)));
    1914                 :           0 :   push (Rust::Token::make (EQUAL, UNDEF_LOCATION));
    1915                 :           0 :   visit (item.get_expr ());
    1916                 :           0 : }
    1917                 :             : 
    1918                 :             : void
    1919                 :           4 : TokenCollector::visit (Enum &enumeration)
    1920                 :             : {
    1921                 :           4 :   visit_items_as_lines (enumeration.get_outer_attrs ());
    1922                 :           4 :   if (enumeration.has_visibility ())
    1923                 :           0 :     visit (enumeration.get_visibility ());
    1924                 :           4 :   push (Rust::Token::make (ENUM_KW, enumeration.get_locus ()));
    1925                 :           8 :   auto id = enumeration.get_identifier ().as_string ();
    1926                 :           4 :   push (
    1927                 :           4 :     Rust::Token::make_identifier (enumeration.get_locus (), std::move (id)));
    1928                 :           4 :   if (enumeration.has_generics ())
    1929                 :           0 :     visit (enumeration.get_generic_params ());
    1930                 :           4 :   if (enumeration.has_where_clause ())
    1931                 :           0 :     visit (enumeration.get_where_clause ());
    1932                 :             : 
    1933                 :           8 :   visit_items_as_block (enumeration.get_variants (),
    1934                 :             :                         {Rust::Token::make (COMMA, UNDEF_LOCATION)});
    1935                 :           4 : }
    1936                 :             : 
    1937                 :             : void
    1938                 :           0 : TokenCollector::visit (Union &union_item)
    1939                 :             : {
    1940                 :           0 :   visit_items_as_lines (union_item.get_outer_attrs ());
    1941                 :           0 :   auto id = union_item.get_identifier ().as_string ();
    1942                 :           0 :   push (Rust::Token::make_identifier (union_item.get_locus (),
    1943                 :           0 :                                       Values::WeakKeywords::UNION));
    1944                 :           0 :   push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id)));
    1945                 :             : 
    1946                 :           0 :   if (union_item.has_generics ())
    1947                 :           0 :     visit (union_item.get_generic_params ());
    1948                 :             : 
    1949                 :           0 :   if (union_item.has_where_clause ())
    1950                 :           0 :     visit (union_item.get_where_clause ());
    1951                 :             : 
    1952                 :           0 :   visit_items_as_block (union_item.get_variants (),
    1953                 :             :                         {Rust::Token::make (COMMA, UNDEF_LOCATION)});
    1954                 :           0 : }
    1955                 :             : 
    1956                 :             : void
    1957                 :           0 : TokenCollector::visit (ConstantItem &item)
    1958                 :             : {
    1959                 :           0 :   visit_items_as_lines (item.get_outer_attrs ());
    1960                 :           0 :   push (Rust::Token::make (CONST, item.get_locus ()));
    1961                 :           0 :   if (item.is_unnamed ())
    1962                 :             :     {
    1963                 :           0 :       push (Rust::Token::make (UNDERSCORE, UNDEF_LOCATION));
    1964                 :             :     }
    1965                 :             :   else
    1966                 :             :     {
    1967                 :           0 :       auto id = item.get_identifier ();
    1968                 :           0 :       push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id)));
    1969                 :           0 :     }
    1970                 :           0 :   push (Rust::Token::make (COLON, UNDEF_LOCATION));
    1971                 :           0 :   visit (item.get_type ());
    1972                 :           0 :   if (item.has_expr ())
    1973                 :             :     {
    1974                 :           0 :       push (Rust::Token::make (EQUAL, UNDEF_LOCATION));
    1975                 :           0 :       visit (item.get_expr ());
    1976                 :             :     }
    1977                 :           0 :   push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION));
    1978                 :           0 : }
    1979                 :             : 
    1980                 :             : void
    1981                 :           2 : TokenCollector::visit (StaticItem &item)
    1982                 :             : {
    1983                 :           2 :   visit_items_as_lines (item.get_outer_attrs ());
    1984                 :           2 :   push (Rust::Token::make (STATIC_KW, item.get_locus ()));
    1985                 :           2 :   if (item.is_mutable ())
    1986                 :           0 :     push (Rust::Token::make (MUT, UNDEF_LOCATION));
    1987                 :             : 
    1988                 :           4 :   auto id = item.get_identifier ().as_string ();
    1989                 :           2 :   push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id)));
    1990                 :           2 :   push (Rust::Token::make (COLON, UNDEF_LOCATION));
    1991                 :             : 
    1992                 :           2 :   visit (item.get_type ());
    1993                 :             : 
    1994                 :           2 :   if (item.has_expr ())
    1995                 :             :     {
    1996                 :           2 :       push (Rust::Token::make (EQUAL, UNDEF_LOCATION));
    1997                 :           2 :       visit (item.get_expr ());
    1998                 :             :     }
    1999                 :           4 :   push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION));
    2000                 :           2 : }
    2001                 :             : 
    2002                 :             : void
    2003                 :           0 : TokenCollector::visit_function_common (std::unique_ptr<Type> &return_type,
    2004                 :             :                                        std::unique_ptr<BlockExpr> &block)
    2005                 :             : {
    2006                 :             :   // FIXME: This should format the `<vis> fn <name> ( [args] )` as well
    2007                 :           0 :   if (return_type)
    2008                 :             :     {
    2009                 :           0 :       push (Rust::Token::make (RETURN_TYPE, UNDEF_LOCATION));
    2010                 :           0 :       visit (return_type);
    2011                 :             :     }
    2012                 :             : 
    2013                 :           0 :   if (block)
    2014                 :             :     {
    2015                 :           0 :       visit (block);
    2016                 :             :     }
    2017                 :             :   else
    2018                 :             :     {
    2019                 :           0 :       push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION));
    2020                 :           0 :       newline ();
    2021                 :             :     }
    2022                 :           0 : }
    2023                 :             : 
    2024                 :             : void
    2025                 :         703 : TokenCollector::visit (SelfParam &param)
    2026                 :             : {
    2027                 :         703 :   if (param.get_has_ref ())
    2028                 :             :     {
    2029                 :         366 :       push (Rust::Token::make (AMP, UNDEF_LOCATION));
    2030                 :         366 :       if (param.has_lifetime ())
    2031                 :             :         {
    2032                 :         366 :           auto lifetime = param.get_lifetime ();
    2033                 :         366 :           visit (lifetime);
    2034                 :         366 :         }
    2035                 :         366 :       if (param.get_is_mut ())
    2036                 :         292 :         push (Rust::Token::make (MUT, UNDEF_LOCATION));
    2037                 :             :     }
    2038                 :         703 :   push (Rust::Token::make (SELF, UNDEF_LOCATION));
    2039                 :         703 :   if (param.has_type ())
    2040                 :             :     {
    2041                 :           0 :       push (Rust::Token::make (COLON, UNDEF_LOCATION));
    2042                 :           0 :       visit (param.get_type ());
    2043                 :             :     }
    2044                 :         703 : }
    2045                 :             : 
    2046                 :             : void
    2047                 :           2 : TokenCollector::visit (TraitItemConst &item)
    2048                 :             : {
    2049                 :           4 :   auto id = item.get_identifier ().as_string ();
    2050                 :           2 :   indentation ();
    2051                 :           2 :   push (Rust::Token::make (CONST, item.get_locus ()));
    2052                 :           2 :   push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id)));
    2053                 :           2 :   push (Rust::Token::make (COLON, UNDEF_LOCATION));
    2054                 :           2 :   visit (item.get_type ());
    2055                 :           2 :   push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION));
    2056                 :           2 :   newline ();
    2057                 :           2 : }
    2058                 :             : 
    2059                 :             : void
    2060                 :         455 : TokenCollector::visit (TraitItemType &item)
    2061                 :             : {
    2062                 :         455 :   visit_items_as_lines (item.get_outer_attrs ());
    2063                 :         910 :   auto id = item.get_identifier ().as_string ();
    2064                 :         455 :   indentation ();
    2065                 :             : 
    2066                 :         455 :   push (Rust::Token::make (TYPE, item.get_locus ()));
    2067                 :         455 :   push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id)));
    2068                 :         455 :   push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION));
    2069                 :         455 :   newline ();
    2070                 :         455 : }
    2071                 :             : 
    2072                 :             : void
    2073                 :        2036 : TokenCollector::visit (Trait &trait)
    2074                 :             : {
    2075                 :        3814 :   for (auto &attr : trait.get_outer_attrs ())
    2076                 :             :     {
    2077                 :        1778 :       visit (attr);
    2078                 :        1778 :       newline ();
    2079                 :        1778 :       indentation ();
    2080                 :             :     }
    2081                 :             : 
    2082                 :        2036 :   visit (trait.get_visibility ());
    2083                 :             : 
    2084                 :        4072 :   auto id = trait.get_identifier ().as_string ();
    2085                 :        2036 :   push (Rust::Token::make (TRAIT, trait.get_locus ()));
    2086                 :        2036 :   push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id)));
    2087                 :             : 
    2088                 :        2036 :   visit (trait.get_generic_params ());
    2089                 :             : 
    2090                 :        2036 :   visit_items_as_block (trait.get_trait_items (), {});
    2091                 :        2036 : }
    2092                 :             : 
    2093                 :             : void
    2094                 :           0 : TokenCollector::visit (InherentImpl &impl)
    2095                 :             : {
    2096                 :           0 :   visit_items_as_lines (impl.get_outer_attrs ());
    2097                 :           0 :   push (Rust::Token::make (IMPL, impl.get_locus ()));
    2098                 :           0 :   visit (impl.get_generic_params ());
    2099                 :             : 
    2100                 :           0 :   visit (impl.get_type ());
    2101                 :             : 
    2102                 :           0 :   if (impl.has_where_clause ())
    2103                 :           0 :     visit (impl.get_where_clause ());
    2104                 :             : 
    2105                 :             :   // FIXME: Handle inner attributes
    2106                 :             : 
    2107                 :           0 :   visit_items_as_block (impl.get_impl_items (), {});
    2108                 :           0 : }
    2109                 :             : 
    2110                 :             : void
    2111                 :           4 : TokenCollector::visit (TraitImpl &impl)
    2112                 :             : {
    2113                 :           4 :   visit_items_as_lines (impl.get_outer_attrs ());
    2114                 :           4 :   push (Rust::Token::make (IMPL, impl.get_locus ()));
    2115                 :           4 :   visit (impl.get_generic_params ());
    2116                 :           4 :   if (impl.is_exclam ())
    2117                 :           0 :     push (Rust::Token::make (EXCLAM, UNDEF_LOCATION));
    2118                 :           4 :   visit (impl.get_trait_path ());
    2119                 :           4 :   push (Rust::Token::make (FOR, UNDEF_LOCATION));
    2120                 :           4 :   visit (impl.get_type ());
    2121                 :             : 
    2122                 :           4 :   if (impl.has_where_clause ())
    2123                 :           0 :     visit (impl.get_where_clause ());
    2124                 :             : 
    2125                 :           4 :   visit_items_as_block (impl.get_impl_items ());
    2126                 :           4 : }
    2127                 :             : 
    2128                 :             : void
    2129                 :           0 : TokenCollector::visit (ExternalTypeItem &type)
    2130                 :             : {
    2131                 :           0 :   visit (type.get_visibility ());
    2132                 :             : 
    2133                 :           0 :   auto id = type.get_identifier ().as_string ();
    2134                 :             : 
    2135                 :           0 :   push (Rust::Token::make (TYPE, UNDEF_LOCATION));
    2136                 :           0 :   push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id)));
    2137                 :           0 :   push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION));
    2138                 :           0 : }
    2139                 :             : 
    2140                 :             : void
    2141                 :           0 : TokenCollector::visit (ExternalStaticItem &item)
    2142                 :             : {
    2143                 :           0 :   auto id = item.get_identifier ().as_string ();
    2144                 :           0 :   visit_items_as_lines (item.get_outer_attrs ());
    2145                 :           0 :   if (item.has_visibility ())
    2146                 :           0 :     visit (item.get_visibility ());
    2147                 :           0 :   push (Rust::Token::make (STATIC_KW, item.get_locus ()));
    2148                 :           0 :   if (item.is_mut ())
    2149                 :           0 :     push (Rust::Token::make (MUT, UNDEF_LOCATION));
    2150                 :           0 :   push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id)));
    2151                 :           0 :   push (Rust::Token::make (COLON, UNDEF_LOCATION));
    2152                 :           0 :   visit (item.get_type ());
    2153                 :             :   // TODO: No expr ? The "(= Expression)?" part from the reference seems missing
    2154                 :             :   // in the ast.
    2155                 :           0 :   push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION));
    2156                 :           0 : }
    2157                 :             : 
    2158                 :             : void
    2159                 :         710 : TokenCollector::visit (ExternBlock &block)
    2160                 :             : {
    2161                 :         710 :   visit_items_as_lines (block.get_outer_attrs ());
    2162                 :         710 :   push (Rust::Token::make (EXTERN_KW, block.get_locus ()));
    2163                 :             : 
    2164                 :         710 :   if (block.has_abi ())
    2165                 :             :     {
    2166                 :         710 :       auto abi = block.get_abi ();
    2167                 :        1420 :       push (Rust::Token::make_string (UNDEF_LOCATION, std::move (abi)));
    2168                 :         710 :     }
    2169                 :             : 
    2170                 :         710 :   visit_items_as_block (block.get_extern_items (), {});
    2171                 :         710 : }
    2172                 :             : 
    2173                 :             : static std::pair<TokenId, TokenId>
    2174                 :           4 : get_delimiters (DelimType delim)
    2175                 :             : {
    2176                 :           4 :   switch (delim)
    2177                 :             :     {
    2178                 :           4 :     case PARENS:
    2179                 :           4 :       return {LEFT_PAREN, RIGHT_PAREN};
    2180                 :           0 :     case SQUARE:
    2181                 :           0 :       return {LEFT_SQUARE, RIGHT_SQUARE};
    2182                 :           0 :     case CURLY:
    2183                 :           0 :       return {LEFT_CURLY, RIGHT_CURLY};
    2184                 :           0 :     default:
    2185                 :           0 :       rust_unreachable ();
    2186                 :             :     }
    2187                 :             : }
    2188                 :             : 
    2189                 :             : void
    2190                 :           0 : TokenCollector::visit (MacroMatchFragment &match)
    2191                 :             : {
    2192                 :           0 :   auto id = match.get_ident ().as_string ();
    2193                 :           0 :   auto frag_spec = match.get_frag_spec ().as_string ();
    2194                 :           0 :   push (Rust::Token::make (DOLLAR_SIGN, UNDEF_LOCATION));
    2195                 :           0 :   push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id)));
    2196                 :           0 :   push (Rust::Token::make (COLON, UNDEF_LOCATION));
    2197                 :           0 :   push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (frag_spec)));
    2198                 :           0 : }
    2199                 :             : 
    2200                 :             : void
    2201                 :           0 : TokenCollector::visit (MacroMatchRepetition &repetition)
    2202                 :             : {
    2203                 :           0 :   push (Rust::Token::make (DOLLAR_SIGN, UNDEF_LOCATION));
    2204                 :           0 :   push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));
    2205                 :             : 
    2206                 :           0 :   for (auto &match : repetition.get_matches ())
    2207                 :             :     {
    2208                 :           0 :       visit (match);
    2209                 :             :     }
    2210                 :             : 
    2211                 :           0 :   push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
    2212                 :             : 
    2213                 :           0 :   if (repetition.has_sep ())
    2214                 :             :     {
    2215                 :           0 :       push (Rust::Token::make (repetition.get_sep ()->get_id (),
    2216                 :           0 :                                repetition.get_sep ()->get_locus ()));
    2217                 :             :     }
    2218                 :           0 :   switch (repetition.get_op ())
    2219                 :             :     {
    2220                 :           0 :     case MacroMatchRepetition::ANY:
    2221                 :           0 :       push (Rust::Token::make (ASTERISK, UNDEF_LOCATION));
    2222                 :           0 :       break;
    2223                 :           0 :     case MacroMatchRepetition::ONE_OR_MORE:
    2224                 :           0 :       push (Rust::Token::make (PLUS, UNDEF_LOCATION));
    2225                 :           0 :       break;
    2226                 :           0 :     case MacroMatchRepetition::ZERO_OR_ONE:
    2227                 :           0 :       push (Rust::Token::make (QUESTION_MARK, UNDEF_LOCATION));
    2228                 :           0 :       break;
    2229                 :             :     case MacroMatchRepetition::NONE:
    2230                 :             :       break;
    2231                 :             :     }
    2232                 :           0 : }
    2233                 :             : 
    2234                 :             : void
    2235                 :           4 : TokenCollector::visit (MacroMatcher &matcher)
    2236                 :             : {
    2237                 :           4 :   auto delimiters = get_delimiters (matcher.get_delim_type ());
    2238                 :             : 
    2239                 :           4 :   push (Rust::Token::make (delimiters.first, UNDEF_LOCATION));
    2240                 :             : 
    2241                 :           6 :   for (auto &item : matcher.get_matches ())
    2242                 :             :     {
    2243                 :           2 :       visit (item);
    2244                 :             :     }
    2245                 :             : 
    2246                 :           4 :   push (Rust::Token::make (delimiters.second, UNDEF_LOCATION));
    2247                 :           4 : }
    2248                 :             : 
    2249                 :             : void
    2250                 :           4 : TokenCollector::visit (MacroRule &rule)
    2251                 :             : {
    2252                 :           4 :   visit (rule.get_matcher ());
    2253                 :           4 :   push (Rust::Token::make (MATCH_ARROW, rule.get_locus ()));
    2254                 :           4 :   visit (rule.get_transcriber ().get_token_tree ());
    2255                 :           4 : }
    2256                 :             : 
    2257                 :             : void
    2258                 :           4 : TokenCollector::visit (MacroRulesDefinition &rules_def)
    2259                 :             : {
    2260                 :           6 :   for (auto &outer_attr : rules_def.get_outer_attrs ())
    2261                 :           2 :     visit (outer_attr);
    2262                 :             : 
    2263                 :           8 :   auto rule_name = rules_def.get_rule_name ().as_string ();
    2264                 :             : 
    2265                 :           8 :   push (Rust::Token::make_identifier (rules_def.get_locus (),
    2266                 :           4 :                                       Values::WeakKeywords::MACRO_RULES));
    2267                 :           4 :   push (Rust::Token::make (EXCLAM, UNDEF_LOCATION));
    2268                 :             : 
    2269                 :           4 :   push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (rule_name)));
    2270                 :             : 
    2271                 :           8 :   visit_items_as_block (rules_def.get_rules (),
    2272                 :             :                         {Rust::Token::make (SEMICOLON, UNDEF_LOCATION)});
    2273                 :           4 : }
    2274                 :             : 
    2275                 :             : void
    2276                 :           0 : TokenCollector::visit (MacroInvocation &invocation)
    2277                 :             : {
    2278                 :           0 :   auto data = invocation.get_invoc_data ();
    2279                 :           0 :   visit (data.get_path ());
    2280                 :           0 :   push (Rust::Token::make (EXCLAM, UNDEF_LOCATION));
    2281                 :           0 :   visit (data.get_delim_tok_tree ());
    2282                 :           0 :   if (invocation.has_semicolon ())
    2283                 :           0 :     push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION));
    2284                 :           0 : }
    2285                 :             : 
    2286                 :             : void
    2287                 :           0 : TokenCollector::visit (MetaItemPath &item)
    2288                 :             : {
    2289                 :           0 :   auto path = item.to_path_item ();
    2290                 :           0 :   visit (path);
    2291                 :           0 : }
    2292                 :             : 
    2293                 :             : void
    2294                 :           4 : TokenCollector::visit (MetaItemSeq &item)
    2295                 :             : {
    2296                 :           4 :   visit (item.get_path ());
    2297                 :             :   // TODO: Double check this, there is probably a mistake.
    2298                 :           4 :   push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));
    2299                 :           4 :   visit_items_joined_by_separator (item.get_seq (), COMMA);
    2300                 :           4 :   push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
    2301                 :           4 : }
    2302                 :             : 
    2303                 :             : void
    2304                 :           0 : TokenCollector::visit (MetaWord &word)
    2305                 :             : {
    2306                 :           0 :   auto id = word.get_ident ().as_string ();
    2307                 :             : 
    2308                 :           0 :   push (Rust::Token::make_identifier (word.get_locus (), std::move (id)));
    2309                 :           0 : }
    2310                 :             : 
    2311                 :             : void
    2312                 :          10 : TokenCollector::visit (MetaNameValueStr &name)
    2313                 :             : {
    2314                 :          10 :   auto pair = name.get_name_value_pair ();
    2315                 :          10 :   auto id = std::get<0> (pair).as_string ();
    2316                 :          10 :   auto value = std::get<1> (pair);
    2317                 :             : 
    2318                 :          10 :   push (Rust::Token::make_identifier (name.get_locus (), std::move (id)));
    2319                 :          10 :   push (Rust::Token::make (EQUAL, name.get_locus ()));
    2320                 :          10 :   push (Rust::Token::make (DOUBLE_QUOTE, UNDEF_LOCATION));
    2321                 :          10 :   push (Rust::Token::make_identifier (name.get_locus (), std::move (value)));
    2322                 :          20 :   push (Rust::Token::make (DOUBLE_QUOTE, UNDEF_LOCATION));
    2323                 :          10 : }
    2324                 :             : 
    2325                 :             : void
    2326                 :           0 : TokenCollector::visit (MetaListPaths &list)
    2327                 :             : {
    2328                 :           0 :   auto id = list.get_ident ().as_string ();
    2329                 :             : 
    2330                 :           0 :   push (Rust::Token::make_identifier (list.get_locus (), std::move (id)));
    2331                 :           0 :   push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));
    2332                 :             : 
    2333                 :           0 :   visit_items_joined_by_separator (list.get_paths (), COMMA);
    2334                 :             : 
    2335                 :           0 :   push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
    2336                 :           0 : }
    2337                 :             : 
    2338                 :             : void
    2339                 :           0 : TokenCollector::visit (MetaListNameValueStr &list)
    2340                 :             : {
    2341                 :           0 :   auto id = list.get_ident ().as_string ();
    2342                 :             : 
    2343                 :           0 :   push (Rust::Token::make_identifier (list.get_locus (), std::move (id)));
    2344                 :           0 :   push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));
    2345                 :             : 
    2346                 :           0 :   visit_items_joined_by_separator (list.get_values (), COMMA);
    2347                 :             : 
    2348                 :           0 :   push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
    2349                 :           0 : }
    2350                 :             : 
    2351                 :             : // rust-pattern.h
    2352                 :             : void
    2353                 :          26 : TokenCollector::visit (LiteralPattern &pattern)
    2354                 :             : {
    2355                 :          26 :   visit (pattern.get_literal (), pattern.get_locus ());
    2356                 :          26 : }
    2357                 :             : 
    2358                 :             : void
    2359                 :        2152 : TokenCollector::visit (IdentifierPattern &pattern)
    2360                 :             : {
    2361                 :        2152 :   if (pattern.get_is_ref ())
    2362                 :             :     {
    2363                 :           0 :       push (Rust::Token::make (REF, pattern.get_locus ()));
    2364                 :             :     }
    2365                 :        2152 :   if (pattern.get_is_mut ())
    2366                 :             :     {
    2367                 :         266 :       push (Rust::Token::make (MUT, UNDEF_LOCATION));
    2368                 :             :     }
    2369                 :             : 
    2370                 :        4304 :   auto id = pattern.get_ident ().as_string ();
    2371                 :        2152 :   push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id)));
    2372                 :             : 
    2373                 :        2152 :   if (pattern.has_pattern_to_bind ())
    2374                 :             :     {
    2375                 :           0 :       push (Rust::Token::make (PATTERN_BIND, UNDEF_LOCATION));
    2376                 :           0 :       visit (pattern.get_pattern_to_bind ());
    2377                 :             :     }
    2378                 :        2152 : }
    2379                 :             : 
    2380                 :             : void
    2381                 :         142 : TokenCollector::visit (WildcardPattern &pattern)
    2382                 :             : {
    2383                 :         142 :   push (Rust::Token::make (UNDERSCORE, pattern.get_locus ()));
    2384                 :         142 : }
    2385                 :             : 
    2386                 :             : void
    2387                 :           0 : TokenCollector::visit (RestPattern &pattern)
    2388                 :             : {
    2389                 :           0 :   push (Rust::Token::make (DOT_DOT, pattern.get_locus ()));
    2390                 :           0 : }
    2391                 :             : 
    2392                 :             : // void TokenCollector::visit(RangePatternBound& ){}
    2393                 :             : 
    2394                 :             : void
    2395                 :           0 : TokenCollector::visit (RangePatternBoundLiteral &pattern)
    2396                 :             : {
    2397                 :           0 :   if (pattern.get_has_minus ())
    2398                 :             :     {
    2399                 :           0 :       push (Rust::Token::make (MINUS, pattern.get_locus ()));
    2400                 :             :     }
    2401                 :           0 :   auto literal = pattern.get_literal ();
    2402                 :           0 :   visit (literal);
    2403                 :           0 : }
    2404                 :             : 
    2405                 :             : void
    2406                 :           0 : TokenCollector::visit (RangePatternBoundPath &pattern)
    2407                 :             : {
    2408                 :           0 :   visit (pattern.get_path ());
    2409                 :           0 : }
    2410                 :             : 
    2411                 :             : void
    2412                 :           0 : TokenCollector::visit (RangePatternBoundQualPath &pattern)
    2413                 :             : {
    2414                 :           0 :   visit (pattern.get_qualified_path ());
    2415                 :           0 : }
    2416                 :             : 
    2417                 :             : void
    2418                 :           0 : TokenCollector::visit (RangePattern &pattern)
    2419                 :             : {
    2420                 :           0 :   if (pattern.get_has_lower_bound () && pattern.get_has_upper_bound ())
    2421                 :             :     {
    2422                 :           0 :       visit (pattern.get_lower_bound ());
    2423                 :           0 :       if (pattern.get_has_ellipsis_syntax ())
    2424                 :           0 :         push (Rust::Token::make (ELLIPSIS, pattern.get_locus ()));
    2425                 :             :       else
    2426                 :           0 :         push (Rust::Token::make (DOT_DOT_EQ, pattern.get_locus ()));
    2427                 :           0 :       visit (pattern.get_upper_bound ());
    2428                 :             :     }
    2429                 :           0 :   else if (pattern.get_has_lower_bound ())
    2430                 :             :     {
    2431                 :           0 :       visit (pattern.get_lower_bound ());
    2432                 :           0 :       push (Rust::Token::make (DOT_DOT, pattern.get_locus ()));
    2433                 :             :     }
    2434                 :             :   else
    2435                 :             :     {
    2436                 :           0 :       push (Rust::Token::make (DOT_DOT_EQ, pattern.get_locus ()));
    2437                 :           0 :       visit (pattern.get_upper_bound ());
    2438                 :             :     }
    2439                 :           0 : }
    2440                 :             : 
    2441                 :             : void
    2442                 :           4 : TokenCollector::visit (ReferencePattern &pattern)
    2443                 :             : {
    2444                 :           4 :   if (pattern.is_double_reference ())
    2445                 :             :     {
    2446                 :           4 :       push (Rust::Token::make (LOGICAL_AND, pattern.get_locus ()));
    2447                 :             :     }
    2448                 :             :   else
    2449                 :             :     {
    2450                 :           4 :       push (Rust::Token::make (AMP, pattern.get_locus ()));
    2451                 :             :     }
    2452                 :             : 
    2453                 :           4 :   if (pattern.get_is_mut ())
    2454                 :             :     {
    2455                 :           0 :       push (Rust::Token::make (MUT, UNDEF_LOCATION));
    2456                 :             :     }
    2457                 :             : 
    2458                 :           4 :   visit (pattern.get_referenced_pattern ());
    2459                 :           4 : }
    2460                 :             : 
    2461                 :             : // void TokenCollector::visit(StructPatternField& ){}
    2462                 :             : 
    2463                 :             : void
    2464                 :           0 : TokenCollector::visit (StructPatternFieldTuplePat &pattern)
    2465                 :             : {
    2466                 :           0 :   visit_items_as_lines (pattern.get_outer_attrs ());
    2467                 :           0 :   push (Rust::Token::make_int (pattern.get_locus (),
    2468                 :           0 :                                std::to_string (pattern.get_index ())));
    2469                 :           0 :   push (Rust::Token::make (COLON, pattern.get_locus ()));
    2470                 :           0 :   visit (pattern.get_index_pattern ());
    2471                 :           0 : }
    2472                 :             : 
    2473                 :             : void
    2474                 :           2 : TokenCollector::visit (StructPatternFieldIdentPat &pattern)
    2475                 :             : {
    2476                 :           2 :   visit_items_as_lines (pattern.get_outer_attrs ());
    2477                 :             : 
    2478                 :           2 :   auto id = pattern.get_identifier ().as_string ();
    2479                 :           2 :   push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id)));
    2480                 :             : 
    2481                 :           2 :   push (Rust::Token::make (COLON, pattern.get_locus ()));
    2482                 :             : 
    2483                 :           2 :   visit (pattern.get_ident_pattern ());
    2484                 :           2 : }
    2485                 :             : 
    2486                 :             : void
    2487                 :           0 : TokenCollector::visit (StructPatternFieldIdent &pattern)
    2488                 :             : {
    2489                 :           0 :   visit_items_as_lines (pattern.get_outer_attrs ());
    2490                 :           0 :   if (pattern.is_ref ())
    2491                 :           0 :     push (Rust::Token::make (REF, UNDEF_LOCATION));
    2492                 :           0 :   if (pattern.is_mut ())
    2493                 :           0 :     push (Rust::Token::make (MUT, UNDEF_LOCATION));
    2494                 :             : 
    2495                 :           0 :   auto id = pattern.get_identifier ().as_string ();
    2496                 :           0 :   push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id)));
    2497                 :           0 : }
    2498                 :             : 
    2499                 :             : void
    2500                 :           2 : TokenCollector::visit (StructPattern &pattern)
    2501                 :             : {
    2502                 :           2 :   visit (pattern.get_path ());
    2503                 :           2 :   push (Rust::Token::make (LEFT_CURLY, pattern.get_locus ()));
    2504                 :           2 :   auto elems = pattern.get_struct_pattern_elems ();
    2505                 :           2 :   if (elems.has_struct_pattern_fields ())
    2506                 :             :     {
    2507                 :           2 :       visit_items_joined_by_separator (elems.get_struct_pattern_fields ());
    2508                 :           2 :       if (elems.has_etc ())
    2509                 :             :         {
    2510                 :           0 :           push (Rust::Token::make (COMMA, UNDEF_LOCATION));
    2511                 :           0 :           visit_items_as_lines (elems.get_etc_outer_attrs ());
    2512                 :             :         }
    2513                 :             :     }
    2514                 :             :   else
    2515                 :             :     {
    2516                 :           0 :       visit_items_as_lines (elems.get_etc_outer_attrs ());
    2517                 :             :     }
    2518                 :             : 
    2519                 :           4 :   push (Rust::Token::make (RIGHT_CURLY, UNDEF_LOCATION));
    2520                 :           2 : }
    2521                 :             : 
    2522                 :             : // void TokenCollector::visit(TupleStructItems& ){}
    2523                 :             : 
    2524                 :             : void
    2525                 :          31 : TokenCollector::visit (TupleStructItemsNoRange &pattern)
    2526                 :             : {
    2527                 :          31 :   visit_items_joined_by_separator (pattern.get_patterns ());
    2528                 :          31 : }
    2529                 :             : 
    2530                 :             : void
    2531                 :           0 : TokenCollector::visit (TupleStructItemsRange &pattern)
    2532                 :             : {
    2533                 :           0 :   for (auto &lower : pattern.get_lower_patterns ())
    2534                 :             :     {
    2535                 :           0 :       visit (lower);
    2536                 :             :     }
    2537                 :           0 :   push (Rust::Token::make (DOT_DOT, UNDEF_LOCATION));
    2538                 :           0 :   for (auto &upper : pattern.get_lower_patterns ())
    2539                 :             :     {
    2540                 :           0 :       visit (upper);
    2541                 :             :     }
    2542                 :           0 : }
    2543                 :             : 
    2544                 :             : void
    2545                 :          31 : TokenCollector::visit (TupleStructPattern &pattern)
    2546                 :             : {
    2547                 :          31 :   visit (pattern.get_path ());
    2548                 :          31 :   push (Rust::Token::make (LEFT_PAREN, pattern.get_locus ()));
    2549                 :          31 :   visit (pattern.get_items ());
    2550                 :          31 :   push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
    2551                 :          31 : }
    2552                 :             : 
    2553                 :             : // void
    2554                 :             : // TokenCollector::visit (TuplePatternItems &)
    2555                 :             : // {}
    2556                 :             : 
    2557                 :             : void
    2558                 :          10 : TokenCollector::visit (TuplePatternItemsMultiple &pattern)
    2559                 :             : {
    2560                 :          10 :   visit_items_joined_by_separator (pattern.get_patterns (), COMMA);
    2561                 :          10 : }
    2562                 :             : 
    2563                 :             : void
    2564                 :           0 : TokenCollector::visit (TuplePatternItemsRanged &pattern)
    2565                 :             : {
    2566                 :           0 :   for (auto &lower : pattern.get_lower_patterns ())
    2567                 :             :     {
    2568                 :           0 :       visit (lower);
    2569                 :             :     }
    2570                 :           0 :   push (Rust::Token::make (DOT_DOT, UNDEF_LOCATION));
    2571                 :           0 :   for (auto &upper : pattern.get_lower_patterns ())
    2572                 :             :     {
    2573                 :           0 :       visit (upper);
    2574                 :             :     }
    2575                 :           0 : }
    2576                 :             : 
    2577                 :             : void
    2578                 :          10 : TokenCollector::visit (TuplePattern &pattern)
    2579                 :             : {
    2580                 :          10 :   push (Rust::Token::make (LEFT_PAREN, pattern.get_locus ()));
    2581                 :          10 :   visit (pattern.get_items ());
    2582                 :          10 :   push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
    2583                 :          10 : }
    2584                 :             : 
    2585                 :             : void
    2586                 :           0 : TokenCollector::visit (GroupedPattern &pattern)
    2587                 :             : {
    2588                 :           0 :   push (Rust::Token::make (LEFT_PAREN, pattern.get_locus ()));
    2589                 :           0 :   visit (pattern.get_pattern_in_parens ());
    2590                 :           0 :   push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
    2591                 :           0 : }
    2592                 :             : 
    2593                 :             : void
    2594                 :           0 : TokenCollector::visit (SlicePattern &pattern)
    2595                 :             : {
    2596                 :           0 :   push (Rust::Token::make (LEFT_SQUARE, pattern.get_locus ()));
    2597                 :           0 :   visit_items_joined_by_separator (pattern.get_items (), COMMA);
    2598                 :           0 :   push (Rust::Token::make (RIGHT_SQUARE, UNDEF_LOCATION));
    2599                 :           0 : }
    2600                 :             : 
    2601                 :             : void
    2602                 :           6 : TokenCollector::visit (AltPattern &pattern)
    2603                 :             : {
    2604                 :           6 :   visit_items_joined_by_separator (pattern.get_alts (), PIPE);
    2605                 :           6 : }
    2606                 :             : 
    2607                 :             : // rust-stmt.h
    2608                 :             : void
    2609                 :           8 : TokenCollector::visit (EmptyStmt &)
    2610                 :           8 : {}
    2611                 :             : 
    2612                 :             : void
    2613                 :        1587 : TokenCollector::visit (LetStmt &stmt)
    2614                 :             : {
    2615                 :        1587 :   push (Rust::Token::make (LET, stmt.get_locus ()));
    2616                 :        1587 :   auto &pattern = stmt.get_pattern ();
    2617                 :        1587 :   visit (pattern);
    2618                 :             : 
    2619                 :        1587 :   if (stmt.has_type ())
    2620                 :             :     {
    2621                 :         301 :       push (Rust::Token::make (COLON, UNDEF_LOCATION));
    2622                 :         301 :       visit (stmt.get_type ());
    2623                 :             :     }
    2624                 :             : 
    2625                 :        1587 :   if (stmt.has_init_expr ())
    2626                 :             :     {
    2627                 :        1469 :       push (Rust::Token::make (EQUAL, UNDEF_LOCATION));
    2628                 :        1469 :       visit (stmt.get_init_expr ());
    2629                 :             :     }
    2630                 :             : 
    2631                 :        1587 :   if (stmt.has_else_expr ())
    2632                 :             :     {
    2633                 :           0 :       push (Rust::Token::make (ELSE, UNDEF_LOCATION));
    2634                 :           0 :       visit (stmt.get_else_expr ());
    2635                 :             :     }
    2636                 :             : 
    2637                 :        1587 :   push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION));
    2638                 :        1587 : }
    2639                 :             : 
    2640                 :             : void
    2641                 :         957 : TokenCollector::visit (ExprStmt &stmt)
    2642                 :             : {
    2643                 :         957 :   visit (stmt.get_expr ());
    2644                 :         957 :   if (stmt.is_semicolon_followed ())
    2645                 :        1410 :     push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION));
    2646                 :         957 : }
    2647                 :             : 
    2648                 :             : // rust-type.h
    2649                 :             : void
    2650                 :         103 : TokenCollector::visit (TraitBound &bound)
    2651                 :             : {
    2652                 :             :   // Syntax:
    2653                 :             :   //      ?? ForLifetimes? TypePath
    2654                 :             :   //   | ( ?? ForLifetimes? TypePath )
    2655                 :             : 
    2656                 :         103 :   if (bound.has_opening_question_mark ())
    2657                 :          26 :     push (Rust::Token::make (QUESTION_MARK, bound.get_locus ()));
    2658                 :             : 
    2659                 :         103 :   if (bound.has_for_lifetimes ())
    2660                 :           0 :     visit (bound.get_for_lifetimes ());
    2661                 :             : 
    2662                 :         103 :   visit (bound.get_type_path ());
    2663                 :         103 : }
    2664                 :             : 
    2665                 :             : void
    2666                 :           0 : TokenCollector::visit (ImplTraitType &type)
    2667                 :             : {
    2668                 :             :   // Syntax:
    2669                 :             :   //    impl TypeParamBounds
    2670                 :             :   // TypeParamBounds :
    2671                 :             :   //    TypeParamBound ( + TypeParamBound )* +?
    2672                 :             : 
    2673                 :           0 :   push (Rust::Token::make (IMPL, type.get_locus ()));
    2674                 :           0 :   visit_items_joined_by_separator (type.get_type_param_bounds (), PLUS);
    2675                 :           0 : }
    2676                 :             : 
    2677                 :             : void
    2678                 :           0 : TokenCollector::visit (TraitObjectType &type)
    2679                 :             : {
    2680                 :             :   // Syntax:
    2681                 :             :   //   dyn? TypeParamBounds
    2682                 :             :   // TypeParamBounds :
    2683                 :             :   //   TypeParamBound ( + TypeParamBound )* +?
    2684                 :             : 
    2685                 :           0 :   if (type.is_dyn ())
    2686                 :           0 :     push (Rust::Token::make (DYN, type.get_locus ()));
    2687                 :           0 :   visit_items_joined_by_separator (type.get_type_param_bounds (), PLUS);
    2688                 :           0 : }
    2689                 :             : 
    2690                 :             : void
    2691                 :           0 : TokenCollector::visit (ParenthesisedType &type)
    2692                 :             : {
    2693                 :             :   // Syntax:
    2694                 :             :   //    ( Type )
    2695                 :             : 
    2696                 :           0 :   push (Rust::Token::make (LEFT_PAREN, type.get_locus ()));
    2697                 :           0 :   visit (type.get_type_in_parens ());
    2698                 :           0 :   push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
    2699                 :           0 : }
    2700                 :             : 
    2701                 :             : void
    2702                 :           0 : TokenCollector::visit (ImplTraitTypeOneBound &type)
    2703                 :             : {
    2704                 :             :   // Syntax:
    2705                 :             :   //    impl TraitBound
    2706                 :             : 
    2707                 :           0 :   push (Rust::Token::make (IMPL, type.get_locus ()));
    2708                 :           0 :   visit (type.get_trait_bound ());
    2709                 :           0 : }
    2710                 :             : 
    2711                 :             : void
    2712                 :          62 : TokenCollector::visit (TraitObjectTypeOneBound &type)
    2713                 :             : {
    2714                 :             :   // Syntax:
    2715                 :             :   //    dyn? TraitBound
    2716                 :             : 
    2717                 :          62 :   if (type.is_dyn ())
    2718                 :         124 :     push (Rust::Token::make (DYN, type.get_locus ()));
    2719                 :          62 :   visit (type.get_trait_bound ());
    2720                 :          62 : }
    2721                 :             : 
    2722                 :             : void
    2723                 :          26 : TokenCollector::visit (TupleType &type)
    2724                 :             : {
    2725                 :             :   // Syntax:
    2726                 :             :   //   ( )
    2727                 :             :   //   | ( ( Type , )+ Type? )
    2728                 :             : 
    2729                 :          26 :   push (Rust::Token::make (LEFT_PAREN, type.get_locus ()));
    2730                 :          26 :   visit_items_joined_by_separator (type.get_elems (), COMMA);
    2731                 :          26 :   push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
    2732                 :          26 : }
    2733                 :             : 
    2734                 :             : void
    2735                 :           0 : TokenCollector::visit (NeverType &type)
    2736                 :             : {
    2737                 :             :   // Syntax:
    2738                 :             :   //  !
    2739                 :             : 
    2740                 :           0 :   push (Rust::Token::make (EXCLAM, type.get_locus ()));
    2741                 :           0 : }
    2742                 :             : 
    2743                 :             : void
    2744                 :         254 : TokenCollector::visit (RawPointerType &type)
    2745                 :             : {
    2746                 :             :   // Syntax:
    2747                 :             :   //    * ( mut | const ) TypeNoBounds
    2748                 :             : 
    2749                 :         254 :   push (Rust::Token::make (ASTERISK, type.get_locus ()));
    2750                 :         254 :   if (type.get_pointer_type () == RawPointerType::MUT)
    2751                 :          20 :     push (Rust::Token::make (MUT, UNDEF_LOCATION));
    2752                 :             :   else /* RawPointerType::CONST */
    2753                 :         488 :     push (Rust::Token::make (CONST, UNDEF_LOCATION));
    2754                 :             : 
    2755                 :         254 :   visit (type.get_type_pointed_to ());
    2756                 :         254 : }
    2757                 :             : 
    2758                 :             : void
    2759                 :         525 : TokenCollector::visit (ReferenceType &type)
    2760                 :             : {
    2761                 :             :   // Syntax:
    2762                 :             :   //    & Lifetime? mut? TypeNoBounds
    2763                 :             : 
    2764                 :         525 :   push (Rust::Token::make (AMP, type.get_locus ()));
    2765                 :             : 
    2766                 :         525 :   if (type.has_lifetime ())
    2767                 :             :     {
    2768                 :         525 :       visit (type.get_lifetime ());
    2769                 :             :     }
    2770                 :             : 
    2771                 :         525 :   if (type.get_has_mut ())
    2772                 :          98 :     push (Rust::Token::make (MUT, UNDEF_LOCATION));
    2773                 :             : 
    2774                 :         525 :   visit (type.get_type_referenced ());
    2775                 :         525 : }
    2776                 :             : 
    2777                 :             : void
    2778                 :          12 : TokenCollector::visit (ArrayType &type)
    2779                 :             : {
    2780                 :             :   // Syntax:
    2781                 :             :   //    [ Type ; Expression ]
    2782                 :             : 
    2783                 :          12 :   push (Rust::Token::make (LEFT_SQUARE, type.get_locus ()));
    2784                 :          12 :   visit (type.get_elem_type ());
    2785                 :          12 :   push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION));
    2786                 :          12 :   visit (type.get_size_expr ());
    2787                 :          12 :   push (Rust::Token::make (RIGHT_SQUARE, UNDEF_LOCATION));
    2788                 :          12 : }
    2789                 :             : 
    2790                 :             : void
    2791                 :           8 : TokenCollector::visit (SliceType &type)
    2792                 :             : {
    2793                 :             :   // Syntax:
    2794                 :             :   //    [ Type ]
    2795                 :             : 
    2796                 :           8 :   push (Rust::Token::make (LEFT_SQUARE, type.get_locus ()));
    2797                 :           8 :   visit (type.get_elem_type ());
    2798                 :           8 :   push (Rust::Token::make (RIGHT_SQUARE, UNDEF_LOCATION));
    2799                 :           8 : }
    2800                 :             : 
    2801                 :             : void
    2802                 :           6 : TokenCollector::visit (InferredType &type)
    2803                 :             : {
    2804                 :             :   // Syntax:
    2805                 :             :   //    _
    2806                 :             : 
    2807                 :           6 :   push (Rust::Token::make (UNDERSCORE, type.get_locus ()));
    2808                 :           6 : }
    2809                 :             : 
    2810                 :             : void
    2811                 :           4 : TokenCollector::visit (BareFunctionType &type)
    2812                 :             : {
    2813                 :             :   // Syntax:
    2814                 :             :   //    ForLifetimes? FunctionTypeQualifiers fn
    2815                 :             :   //      ( FunctionParametersMaybeNamedVariadic? ) BareFunctionReturnType?
    2816                 :             :   //
    2817                 :             :   //    BareFunctionReturnType:
    2818                 :             :   //      -> TypeNoBounds
    2819                 :             :   //
    2820                 :             :   //    FunctionParametersMaybeNamedVariadic :
    2821                 :             :   //      MaybeNamedFunctionParameters | MaybeNamedFunctionParametersVariadic
    2822                 :             :   //
    2823                 :             :   //    MaybeNamedFunctionParameters :
    2824                 :             :   //      MaybeNamedParam ( , MaybeNamedParam )* ,?
    2825                 :             :   //
    2826                 :             :   //    MaybeNamedFunctionParametersVariadic :
    2827                 :             :   //      ( MaybeNamedParam , )* MaybeNamedParam , OuterAttribute* ...
    2828                 :             : 
    2829                 :           4 :   if (type.has_for_lifetimes ())
    2830                 :           0 :     visit (type.get_for_lifetimes ());
    2831                 :             : 
    2832                 :           4 :   visit (type.get_function_qualifiers ());
    2833                 :             : 
    2834                 :           4 :   push (Rust::Token::make (FN_KW, type.get_locus ()));
    2835                 :           4 :   push (Rust::Token::make (LEFT_PAREN, UNDEF_LOCATION));
    2836                 :             : 
    2837                 :           4 :   visit_items_joined_by_separator (type.get_function_params (), COMMA);
    2838                 :             : 
    2839                 :           4 :   if (type.is_variadic ())
    2840                 :             :     {
    2841                 :           0 :       push (Rust::Token::make (COMMA, UNDEF_LOCATION));
    2842                 :           0 :       for (auto &item : type.get_variadic_attr ())
    2843                 :             :         {
    2844                 :           0 :           visit (item);
    2845                 :             :         }
    2846                 :           0 :       push (Rust::Token::make (ELLIPSIS, UNDEF_LOCATION));
    2847                 :             :     }
    2848                 :             : 
    2849                 :           4 :   push (Rust::Token::make (RIGHT_PAREN, UNDEF_LOCATION));
    2850                 :             : 
    2851                 :           4 :   if (type.has_return_type ())
    2852                 :             :     {
    2853                 :           0 :       push (Rust::Token::make (RETURN_TYPE, UNDEF_LOCATION));
    2854                 :           0 :       visit (type.get_return_type ());
    2855                 :             :     }
    2856                 :           4 : }
    2857                 :             : 
    2858                 :             : void
    2859                 :           0 : TokenCollector::visit (AST::FormatArgs &fmt)
    2860                 :             : {
    2861                 :           0 :   rust_sorry_at (fmt.get_locus (), "%s:%u: unimplemented FormatArgs visitor",
    2862                 :             :                  __FILE__, __LINE__);
    2863                 :           0 : }
    2864                 :             : 
    2865                 :             : } // namespace AST
    2866                 :             : } // namespace Rust
        

Generated by: LCOV version 2.1-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.