pub fn lex_indents(reader: &mut impl Reader, lexer: &mut impl Lexer) {
    // Only try to lex indents if at the start of a line.
    if !lexer.is_at_indentable() {
        return;
    }

    // Skip if this is an empty or comment-only line.
    if let ReaderResult::Match(_) = reader.strip_peek(&*NO_CODE_LINE_RE) {
        return;
    }

    // Determine the indent of the line.
    let mut line_indent = 0;
    let mut source: SourceSlice = reader.source_at_current();
    while let ReaderResult::Match(more_src) = reader.direct_match(&*INDENT_RE) {
        line_indent += 1;
        //TODO @mark: need test coverage for this source slice thing
        source = source.join(&more_src).unwrap()
    }

    // Determine the lexemes to create.
    let prev_indent = lexer.get_indent();
    for _ in line_indent..prev_indent {
        lexer.add(Lexeme::EndBlock(EndBlockLexeme::new(true, false, source.clone())));
    }
    for _ in prev_indent..line_indent {
        lexer.add(Lexeme::StartBlock(StartBlockLexeme::new(source.clone())));
    }

    lexer.set_at_indentable(false);
    lexer.set_indent(line_indent);
}
/// Process the indents at the start of a line, and add the lexemes to the Lexer.
Process the indents at the start of a line, and add the lexemes to the Lexer.
Process the indents at the start of a line and add the lexemes to the Lexer .
pub fn lex_indents(reader: &mut impl Reader, lexer: &mut impl Lexer) {
    // Only try to lex indents if at the start of a line.
    if !lexer.is_at_indentable() {
        return;
    }
    // Skip if this is an empty or comment-only line.
    if let ReaderResult::Match(_) = reader.strip_peek(&*NO_CODE_LINE_RE) {
        return;
    }
    // Determine the indent of the line.
    let mut line_indent = 0;
    let mut source: SourceSlice = reader.source_at_current();
    while let ReaderResult::Match(more_src) = reader.direct_match(&*INDENT_RE) {
        line_indent += 1;
        //TODO @mark: need test coverage for this source slice thing
        source = source.join(&more_src).unwrap()
    }
    // Determine the lexemes to create.
    let prev_indent = lexer.get_indent();
    for _ in line_indent..prev_indent {
        lexer.add(Lexeme::EndBlock(EndBlockLexeme::new(true, false, source.clone())));
    }
    for _ in prev_indent..line_indent {
        lexer.add(Lexeme::StartBlock(StartBlockLexeme::new(source.clone())));
    }
    lexer.set_at_indentable(false);
    lexer.set_indent(line_indent);
}
pub fn lex_indents ( reader : & mut impl Reader , lexer : & mut impl Lexer ) { // Only try to lex indents if at the start of a line. if ! lexer . is_at_indentable ( ) { return ; } // Skip if this is an empty or comment-only line. if let ReaderResult :: Match ( _ ) = reader . strip_peek ( & * NO_CODE_LINE_RE ) { return ; } // Determine the indent of the line. let mut line_indent = 0 ; let mut source : SourceSlice = reader . source_at_current ( ) ; while let ReaderResult :: Match ( more_src ) = reader . direct_match ( & * INDENT_RE ) { line_indent += 1 ; //TODO @mark: need test coverage for this source slice thing source = source . join ( & more_src ) . unwrap ( ) } // Determine the lexemes to create. let prev_indent = lexer . get_indent ( ) ; for _ in line_indent .. prev_indent { lexer . add ( Lexeme :: EndBlock ( EndBlockLexeme :: new ( true , false , source . clone ( ) ) ) ) ; } for _ in prev_indent .. line_indent { lexer . add ( Lexeme :: StartBlock ( StartBlockLexeme :: new ( source . clone ( ) ) ) ) ; } lexer . set_at_indentable ( false ) ; lexer . set_indent ( line_indent ) ; }
Process the indents at the start of a line, and add the lexemes to the Lexer.
Process the indents at the start of a line and add the lexemes to the Lexer .
reader
&mut impl Reader
lexer
&mut impl Lexer
reader
&mut impl Reader
lexer
&mut impl Lexer