MCPcopy Create free account
hub / github.com/csskit/csskit / run

Method run

crates/csskit/src/commands/dbg_lex.rs:15–39  ·  view source on GitHub ↗
(&self, _config: GlobalConfig)

Source from the content-addressed store, hash-verified

13
14impl 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}

Callers

nothing calls this directly

Calls 8

sourcesMethod · 0.80
advanceMethod · 0.80
with_cursorMethod · 0.80
str_sliceMethod · 0.80
as_strMethod · 0.45
offsetMethod · 0.45
kindMethod · 0.45
sourceMethod · 0.45

Tested by

no test coverage detected