@@ -900,30 +900,45 @@ pub impl Parser {
900
900
codemap:: spanned { node : lit, span : mk_sp ( lo, self . last_span . hi ) }
901
901
}
902
902
903
- // parse a path that doesn't have type parameters attached
904
- fn parse_path_without_tps ( & self )
905
- -> @ast:: Path {
906
- maybe_whole ! ( self , nt_path) ;
903
+ // parse a path into a vector of idents, whether the path starts
904
+ // with ::, and a span.
905
+ fn parse_path ( & self ) -> ( ~[ ast:: ident ] , bool , span ) {
906
+ let lo = self . span . lo ;
907
+ let is_global = self . eat ( & token:: MOD_SEP ) ;
908
+ let ( ids, span { lo : _, hi, expn_info} ) = self . parse_path_non_global ( ) ;
909
+ ( ids, is_global, span { lo : lo, hi : hi, expn_info : expn_info} )
910
+ }
911
+
912
+ // parse a path beginning with an identifier into a vector of idents and a span
913
+ fn parse_path_non_global ( & self ) -> ( ~[ ast:: ident ] , span ) {
907
914
let lo = self . span . lo ;
908
- let global = self . eat ( & token:: MOD_SEP ) ;
909
915
let mut ids = ~[ ] ;
916
+ // must be at least one to begin:
917
+ ids. push ( self . parse_ident ( ) ) ;
910
918
loop {
911
- // if there's a ::< coming, stop processing
912
- // the path.
913
- let is_not_last =
914
- self . look_ahead ( 2 u) != token:: LT
915
- && self . look_ahead ( 1 u) == token:: MOD_SEP ;
916
-
917
- if is_not_last {
918
- ids. push ( self . parse_ident ( ) ) ;
919
- self . expect ( & token:: MOD_SEP ) ;
920
- } else {
921
- ids. push ( self . parse_ident ( ) ) ;
922
- break ;
919
+ match * self . token {
920
+ token:: MOD_SEP => {
921
+ match self . look_ahead ( 1 u) {
922
+ token:: IDENT ( id, _) => {
923
+ self . bump ( ) ;
924
+ ids. push ( self . parse_ident ( ) ) ;
925
+ }
926
+ _ => break
927
+ }
928
+ }
929
+ _ => break
923
930
}
924
931
}
925
- @ast:: Path { span : mk_sp ( lo, self . last_span . hi ) ,
926
- global : global,
932
+ ( ids, mk_sp ( lo, self . last_span . hi ) )
933
+ }
934
+
935
+ // parse a path that doesn't have type parameters attached
936
+ fn parse_path_without_tps ( & self )
937
+ -> @ast:: Path {
938
+ maybe_whole ! ( self , nt_path) ;
939
+ let ( ids, is_global, sp) = self . parse_path ( ) ;
940
+ @ast:: Path { span : sp,
941
+ global : is_global,
927
942
idents : ids,
928
943
rp : None ,
929
944
types : ~[ ] }
0 commit comments