lexgen 0.16.0

A fully-featured lexer generator implemented as a proc macro
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use lexgen_util::Loc;

pub fn ignore_pos<A, E, L>(ret: Option<Result<(L, A, L), E>>) -> Option<Result<A, E>> {
    ret.map(|res| res.map(|(_, a, _)| a))
}

pub fn next<A, E, L>(iter: &mut dyn Iterator<Item = Result<(L, A, L), E>>) -> Option<Result<A, E>> {
    ignore_pos(iter.next())
}

pub fn loc(line: u32, col: u32, byte_idx: usize) -> Loc {
    Loc {
        line,
        col,
        byte_idx,
    }
}