File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -118,7 +118,8 @@ fn mk_printer(out: io::writer, linewidth: uint) -> printer {
118
118
mut top: 0 u,
119
119
mut bottom: 0 u,
120
120
print_stack : dvec( ) ,
121
- mut pending_indentation: 0 } )
121
+ mut pending_indentation: 0 ,
122
+ mut token_tree_last_was_ident: false } )
122
123
}
123
124
124
125
@@ -223,7 +224,8 @@ type printer_ = {
223
224
// stack of blocks-in-progress being flushed by print
224
225
print_stack : dvec < print_stack_elt > ,
225
226
// buffered indentation to avoid writing trailing whitespace
226
- mut pending_indentation : int
227
+ mut pending_indentation : int ,
228
+ mut token_tree_last_was_ident : bool
227
229
} ;
228
230
229
231
enum printer {
Original file line number Diff line number Diff line change @@ -622,12 +622,14 @@ fn print_tt(s: ps, tt: ast::token_tree) {
622
622
for tts. each ( ) |tt_elt| { print_tt ( s, tt_elt) ; }
623
623
}
624
624
ast:: tt_tok ( _, tk) {
625
- word ( s. s , parse:: token:: to_str ( * s. intr , tk) ) ;
626
625
alt tk {
627
- // gotta keep them separated
628
- parse : : token:: IDENT ( * ) { word ( s. s , ~" ") }
629
- _ {}
626
+ parse : : token:: IDENT ( * ) { // don't let idents run together
627
+ if s. s . token_tree_last_was_ident { word ( s. s , ~" ") }
628
+ s.s.token_tree_last_was_ident = true;
629
+ }
630
+ _ { s.s.token_tree_last_was_ident = false; }
630
631
}
632
+ word(s.s, parse::token::to_str(*s.intr, tk));
631
633
}
632
634
ast::tt_seq(_, tts, sep, zerok) {
633
635
word(s.s, ~" $( ");
@@ -638,9 +640,11 @@ fn print_tt(s: ps, tt: ast::token_tree) {
638
640
none { }
639
641
}
640
642
word ( s. s , if zerok { ~"* " } else { ~" +" });
643
+ s.s.token_tree_last_was_ident = false;
641
644
}
642
645
ast::tt_nonterminal(_, name) {
643
646
word(s.s, ~" $" + * name) ;
647
+ s. s . token_tree_last_was_ident = true ;
644
648
}
645
649
}
646
650
}
You can’t perform that action at this time.
0 commit comments