Skip to main content

tokenize

Function tokenize 

Source
pub fn tokenize(input: &str) -> Result<Vec<Token>, Error>
Examples found in repository?
examples/tokenize/main.rs (line 17)
5fn main() {
6    let samples = fs::read_dir("samples").expect("failed to read samples directory");
7    for entry in samples {
8        let entry = entry.expect("failed to read sample");
9        let file_name = entry.file_name();
10        let file_name = file_name.to_str().expect("failed to read sample file name");
11        if !file_name.ends_with(".yaml") {
12            continue;
13        }
14        let contents = fs::read_to_string(entry.path())
15            .expect(&format!("failed to open sample {}", file_name));
16        let tokens =
17            tokenize(&contents).expect(&format!("failed to tokenize sample {}", file_name));
18        dbg!(file_name, tokens.len());
19    }
20}