| 13 | |
| 14 | impl DbgLex { |
| 15 | pub fn run(&self, _config: GlobalConfig) -> CliResult { |
| 16 | let DbgLex { content } = self; |
| 17 | for (_file_name, mut source) in content.sources()? { |
| 18 | let mut source_string = String::new(); |
| 19 | source.read_to_string(&mut source_string)?; |
| 20 | let source_text = source_string.as_str(); |
| 21 | let mut lexer = Lexer::new(&CssAtomSet::ATOMS, source_text); |
| 22 | |
| 23 | loop { |
| 24 | let offset = lexer.offset(); |
| 25 | let token = lexer.advance(); |
| 26 | let kind = token.kind(); |
| 27 | |
| 28 | if kind == Kind::Eof { |
| 29 | break; |
| 30 | } |
| 31 | |
| 32 | let cursor = token.with_cursor(offset); |
| 33 | let slice = cursor.str_slice(lexer.source()); |
| 34 | |
| 35 | println!("{:?} @ {} (len={}): {:?}", kind, offset.0, token.len(), slice); |
| 36 | } |
| 37 | } |
| 38 | Ok(()) |
| 39 | } |
| 40 | } |