@@ -309,10 +309,12 @@ impl<'a> Printer<'a> {
309309 pub fn last_token ( & mut self ) -> Token {
310310 self . buf [ self . right ] . token . clone ( )
311311 }
312- /// be very careful with this!
312+
313+ /// Be very careful with this!
313314 pub fn replace_last_token ( & mut self , t : Token ) {
314315 self . buf [ self . right ] . token = t;
315316 }
317+
316318 pub fn pretty_print ( & mut self , token : Token ) -> io:: Result < ( ) > {
317319 debug ! ( "pp Vec<{},{}>" , self . left, self . right) ;
318320 match token {
@@ -387,6 +389,7 @@ impl<'a> Printer<'a> {
387389 }
388390 }
389391 }
392+
390393 pub fn check_stream ( & mut self ) -> io:: Result < ( ) > {
391394 debug ! ( "check_stream Vec<{}, {}> with left_total={}, right_total={}" ,
392395 self . left, self . right, self . left_total, self . right_total) ;
@@ -405,19 +408,24 @@ impl<'a> Printer<'a> {
405408 }
406409 Ok ( ( ) )
407410 }
411+
408412 pub fn scan_push ( & mut self , x : usize ) {
409413 debug ! ( "scan_push {}" , x) ;
410414 self . scan_stack . push_front ( x) ;
411415 }
416+
412417 pub fn scan_pop ( & mut self ) -> usize {
413418 self . scan_stack . pop_front ( ) . unwrap ( )
414419 }
420+
415421 pub fn scan_top ( & mut self ) -> usize {
416422 * self . scan_stack . front ( ) . unwrap ( )
417423 }
424+
418425 pub fn scan_pop_bottom ( & mut self ) -> usize {
419426 self . scan_stack . pop_back ( ) . unwrap ( )
420427 }
428+
421429 pub fn advance_right ( & mut self ) {
422430 self . right += 1 ;
423431 self . right %= self . buf_max_len ;
@@ -427,6 +435,7 @@ impl<'a> Printer<'a> {
427435 }
428436 assert_ne ! ( self . right, self . left) ;
429437 }
438+
430439 pub fn advance_left ( & mut self ) -> io:: Result < ( ) > {
431440 debug ! ( "advance_left Vec<{},{}>, sizeof({})={}" , self . left, self . right,
432441 self . left, self . buf[ self . left] . size) ;
@@ -461,6 +470,7 @@ impl<'a> Printer<'a> {
461470
462471 Ok ( ( ) )
463472 }
473+
464474 pub fn check_stack ( & mut self , k : isize ) {
465475 if !self . scan_stack . is_empty ( ) {
466476 let x = self . scan_top ( ) ;
@@ -488,17 +498,20 @@ impl<'a> Printer<'a> {
488498 }
489499 }
490500 }
501+
491502 pub fn print_newline ( & mut self , amount : isize ) -> io:: Result < ( ) > {
492503 debug ! ( "NEWLINE {}" , amount) ;
493504 let ret = write ! ( self . out, "\n " ) ;
494505 self . pending_indentation = 0 ;
495506 self . indent ( amount) ;
496507 ret
497508 }
509+
498510 pub fn indent ( & mut self , amount : isize ) {
499511 debug ! ( "INDENT {}" , amount) ;
500512 self . pending_indentation += amount;
501513 }
514+
502515 pub fn get_top ( & mut self ) -> PrintStackElem {
503516 match self . print_stack . last ( ) {
504517 Some ( el) => * el,
@@ -508,13 +521,15 @@ impl<'a> Printer<'a> {
508521 }
509522 }
510523 }
524+
511525 pub fn print_str ( & mut self , s : & str ) -> io:: Result < ( ) > {
512526 while self . pending_indentation > 0 {
513527 write ! ( self . out, " " ) ?;
514528 self . pending_indentation -= 1 ;
515529 }
516530 write ! ( self . out, "{}" , s)
517531 }
532+
518533 pub fn print ( & mut self , token : Token , l : isize ) -> io:: Result < ( ) > {
519534 debug ! ( "print {} {} (remaining line space={})" , token, l,
520535 self . space) ;
@@ -633,14 +648,6 @@ impl<'a> Printer<'a> {
633648 self . pretty_print ( Token :: String ( wrd. to_string ( ) , wrd. len ( ) as isize ) )
634649 }
635650
636- pub fn huge_word ( & mut self , wrd : & str ) -> io:: Result < ( ) > {
637- self . pretty_print ( Token :: String ( wrd. to_string ( ) , SIZE_INFINITY ) )
638- }
639-
640- pub fn zero_word ( & mut self , wrd : & str ) -> io:: Result < ( ) > {
641- self . pretty_print ( Token :: String ( wrd. to_string ( ) , 0 ) )
642- }
643-
644651 fn spaces ( & mut self , n : usize ) -> io:: Result < ( ) > {
645652 self . break_offset ( n, 0 )
646653 }
0 commit comments