@@ -12,7 +12,6 @@ use ast::{self, Ident};
12
12
use syntax_pos:: { self , BytePos , CharPos , Pos , Span } ;
13
13
use codemap:: CodeMap ;
14
14
use errors:: { FatalError , DiagnosticBuilder } ;
15
- use ext:: tt:: transcribe:: tt_next_token;
16
15
use parse:: { token, ParseSess } ;
17
16
use str:: char_at;
18
17
use symbol:: { Symbol , keywords} ;
@@ -23,53 +22,10 @@ use std::char;
23
22
use std:: mem:: replace;
24
23
use std:: rc:: Rc ;
25
24
26
- pub use ext:: tt:: transcribe:: { TtReader , new_tt_reader} ;
27
-
28
25
pub mod comments;
29
26
mod tokentrees;
30
27
mod unicode_chars;
31
28
32
- pub trait Reader {
33
- fn is_eof ( & self ) -> bool ;
34
- fn try_next_token ( & mut self ) -> Result < TokenAndSpan , ( ) > ;
35
- fn next_token ( & mut self ) -> TokenAndSpan where Self : Sized {
36
- let res = self . try_next_token ( ) ;
37
- self . unwrap_or_abort ( res)
38
- }
39
- /// Report a fatal error with the current span.
40
- fn fatal ( & self , & str ) -> FatalError ;
41
- /// Report a non-fatal error with the current span.
42
- fn err ( & self , & str ) ;
43
- fn emit_fatal_errors ( & mut self ) ;
44
- fn unwrap_or_abort ( & mut self , res : Result < TokenAndSpan , ( ) > ) -> TokenAndSpan {
45
- match res {
46
- Ok ( tok) => tok,
47
- Err ( _) => {
48
- self . emit_fatal_errors ( ) ;
49
- panic ! ( FatalError ) ;
50
- }
51
- }
52
- }
53
- fn peek ( & self ) -> TokenAndSpan ;
54
- /// Get a token the parser cares about.
55
- fn try_real_token ( & mut self ) -> Result < TokenAndSpan , ( ) > {
56
- let mut t = self . try_next_token ( ) ?;
57
- loop {
58
- match t. tok {
59
- token:: Whitespace | token:: Comment | token:: Shebang ( _) => {
60
- t = self . try_next_token ( ) ?;
61
- }
62
- _ => break ,
63
- }
64
- }
65
- Ok ( t)
66
- }
67
- fn real_token ( & mut self ) -> TokenAndSpan {
68
- let res = self . try_real_token ( ) ;
69
- self . unwrap_or_abort ( res)
70
- }
71
- }
72
-
73
29
#[ derive( Clone , PartialEq , Eq , Debug ) ]
74
30
pub struct TokenAndSpan {
75
31
pub tok : token:: Token ,
@@ -182,36 +138,6 @@ impl<'a> StringReader<'a> {
182
138
}
183
139
}
184
140
185
- impl < ' a > Reader for TtReader < ' a > {
186
- fn is_eof ( & self ) -> bool {
187
- self . peek ( ) . tok == token:: Eof
188
- }
189
- fn try_next_token ( & mut self ) -> Result < TokenAndSpan , ( ) > {
190
- assert ! ( self . fatal_errs. is_empty( ) ) ;
191
- let r = tt_next_token ( self ) ;
192
- debug ! ( "TtReader: r={:?}" , r) ;
193
- Ok ( r)
194
- }
195
- fn fatal ( & self , m : & str ) -> FatalError {
196
- self . sp_diag . span_fatal ( self . cur_span , m)
197
- }
198
- fn err ( & self , m : & str ) {
199
- self . sp_diag . span_err ( self . cur_span , m) ;
200
- }
201
- fn emit_fatal_errors ( & mut self ) {
202
- for err in & mut self . fatal_errs {
203
- err. emit ( ) ;
204
- }
205
- self . fatal_errs . clear ( ) ;
206
- }
207
- fn peek ( & self ) -> TokenAndSpan {
208
- TokenAndSpan {
209
- tok : self . cur_tok . clone ( ) ,
210
- sp : self . cur_span ,
211
- }
212
- }
213
- }
214
-
215
141
impl < ' a > StringReader < ' a > {
216
142
/// For comments.rs, which hackily pokes into next_pos and ch
217
143
pub fn new_raw < ' b > ( sess : & ' a ParseSess , filemap : Rc < syntax_pos:: FileMap > ) -> Self {
0 commit comments