@@ -510,9 +510,34 @@ pub use self::num::Radix;
510510pub use self :: num:: RadixFmt ;
511511
512512mod num;
513- pub mod parse;
514513pub mod rt;
515514
515+ #[ cfg( stage0) ]
516+ #[ allow( missing_doc) ]
517+ pub mod parse {
518+ #[ deriving( Eq ) ]
519+ pub enum Alignment {
520+ AlignLeft ,
521+ AlignRight ,
522+ AlignUnknown ,
523+ }
524+
525+ pub enum PluralKeyword {
526+ Zero ,
527+ One ,
528+ Two ,
529+ Few ,
530+ Many ,
531+ }
532+
533+ pub enum Flag {
534+ FlagSignPlus ,
535+ FlagSignMinus ,
536+ FlagAlternate ,
537+ FlagSignAwareZeroPad ,
538+ }
539+ }
540+
516541pub type Result = io:: IoResult < ( ) > ;
517542
518543/// A struct to represent both where to emit formatting strings to and how they
@@ -524,7 +549,7 @@ pub struct Formatter<'a> {
524549 /// Character used as 'fill' whenever there is alignment
525550 pub fill : char ,
526551 /// Boolean indication of whether the output should be left-aligned
527- pub align : parse :: Alignment ,
552+ pub align : rt :: Alignment ,
528553 /// Optionally specified integer width that the output should be
529554 pub width : Option < uint > ,
530555 /// Optionally specified precision for numeric types
@@ -757,7 +782,7 @@ pub unsafe fn write_unsafe(output: &mut io::Writer,
757782 width : None ,
758783 precision : None ,
759784 buf : output,
760- align : parse :: AlignUnknown ,
785+ align : rt :: AlignUnknown ,
761786 fill : ' ' ,
762787 args : args,
763788 curarg : args. iter ( ) ,
@@ -890,15 +915,15 @@ impl<'a> Formatter<'a> {
890915 let value = value - match offset { Some ( i) => i, None => 0 } ;
891916 for s in selectors. iter ( ) {
892917 let run = match s. selector {
893- rt:: Keyword ( parse :: Zero ) => value == 0 ,
894- rt:: Keyword ( parse :: One ) => value == 1 ,
895- rt:: Keyword ( parse :: Two ) => value == 2 ,
918+ rt:: Keyword ( rt :: Zero ) => value == 0 ,
919+ rt:: Keyword ( rt :: One ) => value == 1 ,
920+ rt:: Keyword ( rt :: Two ) => value == 2 ,
896921
897922 // FIXME: Few/Many should have a user-specified boundary
898923 // One possible option would be in the function
899924 // pointer of the 'arg: Argument' struct.
900- rt:: Keyword ( parse :: Few ) => value < 8 ,
901- rt:: Keyword ( parse :: Many ) => value >= 8 ,
925+ rt:: Keyword ( rt :: Few ) => value < 8 ,
926+ rt:: Keyword ( rt :: Many ) => value >= 8 ,
902927
903928 rt:: Literal ( ..) => false
904929 } ;
@@ -960,7 +985,7 @@ impl<'a> Formatter<'a> {
960985 /// This function will correctly account for the flags provided as well as
961986 /// the minimum width. It will not take precision into account.
962987 pub fn pad_integral ( & mut self , is_positive : bool , prefix : & str , buf : & [ u8 ] ) -> Result {
963- use fmt:: parse :: { FlagAlternate , FlagSignPlus , FlagSignAwareZeroPad } ;
988+ use fmt:: rt :: { FlagAlternate , FlagSignPlus , FlagSignAwareZeroPad } ;
964989
965990 let mut width = buf. len ( ) ;
966991
@@ -1000,11 +1025,11 @@ impl<'a> Formatter<'a> {
10001025 Some ( min) if self . flags & ( 1 << ( FlagSignAwareZeroPad as uint ) ) != 0 => {
10011026 self . fill = '0' ;
10021027 try!( write_prefix ( self ) ) ;
1003- self . with_padding ( min - width, parse :: AlignRight , |f| f. buf . write ( buf) )
1028+ self . with_padding ( min - width, rt :: AlignRight , |f| f. buf . write ( buf) )
10041029 }
10051030 // Otherwise, the sign and prefix goes after the padding
10061031 Some ( min) => {
1007- self . with_padding ( min - width, parse :: AlignRight , |f| {
1032+ self . with_padding ( min - width, rt :: AlignRight , |f| {
10081033 try!( write_prefix ( f) ) ; f. buf . write ( buf)
10091034 } )
10101035 }
@@ -1055,7 +1080,7 @@ impl<'a> Formatter<'a> {
10551080 // If we're under both the maximum and the minimum width, then fill
10561081 // up the minimum width with the specified string + some alignment.
10571082 Some ( width) => {
1058- self . with_padding ( width - s. len ( ) , parse :: AlignLeft , |me| {
1083+ self . with_padding ( width - s. len ( ) , rt :: AlignLeft , |me| {
10591084 me. buf . write ( s. as_bytes ( ) )
10601085 } )
10611086 }
@@ -1066,21 +1091,21 @@ impl<'a> Formatter<'a> {
10661091 /// afterwards depending on whether right or left alingment is requested.
10671092 fn with_padding ( & mut self ,
10681093 padding : uint ,
1069- default : parse :: Alignment ,
1094+ default : rt :: Alignment ,
10701095 f: |& mut Formatter | -> Result ) -> Result {
10711096 let align = match self . align {
1072- parse :: AlignUnknown => default,
1073- parse :: AlignLeft | parse :: AlignRight => self . align
1097+ rt :: AlignUnknown => default,
1098+ rt :: AlignLeft | rt :: AlignRight => self . align
10741099 } ;
1075- if align == parse :: AlignLeft {
1100+ if align == rt :: AlignLeft {
10761101 try!( f ( self ) ) ;
10771102 }
10781103 let mut fill = [ 0u8 , ..4 ] ;
10791104 let len = self . fill . encode_utf8 ( fill) ;
10801105 for _ in range ( 0 , padding) {
10811106 try!( self . buf . write ( fill. slice_to ( len) ) ) ;
10821107 }
1083- if align == parse :: AlignRight {
1108+ if align == rt :: AlignRight {
10841109 try!( f ( self ) ) ;
10851110 }
10861111 Ok ( ( ) )
@@ -1203,7 +1228,7 @@ impl<T> Poly for T {
12031228
12041229impl < T > Pointer for * T {
12051230 fn fmt ( & self , f : & mut Formatter ) -> Result {
1206- f. flags |= 1 << ( parse :: FlagAlternate as uint ) ;
1231+ f. flags |= 1 << ( rt :: FlagAlternate as uint ) ;
12071232 secret_lower_hex :: < uint > ( & ( * self as uint ) , f)
12081233 }
12091234}
@@ -1304,7 +1329,7 @@ impl<T: Show, U: Show> Show for ::result::Result<T, U> {
13041329
13051330impl < ' a , T : Show > Show for & ' a [ T ] {
13061331 fn fmt ( & self , f : & mut Formatter ) -> Result {
1307- if f. flags & ( 1 << ( parse :: FlagAlternate as uint ) ) == 0 {
1332+ if f. flags & ( 1 << ( rt :: FlagAlternate as uint ) ) == 0 {
13081333 try!( write ! ( f. buf, "[" ) ) ;
13091334 }
13101335 let mut is_first = true ;
@@ -1316,7 +1341,7 @@ impl<'a, T: Show> Show for &'a [T] {
13161341 }
13171342 try!( write ! ( f. buf, "{}" , * x) )
13181343 }
1319- if f. flags & ( 1 << ( parse :: FlagAlternate as uint ) ) == 0 {
1344+ if f. flags & ( 1 << ( rt :: FlagAlternate as uint ) ) == 0 {
13201345 try!( write ! ( f. buf, "]" ) ) ;
13211346 }
13221347 Ok ( ( ) )
0 commit comments