quasi_lexer.gleam

 1import gleam/list
 2import nibble/lexer.{type Token, Keep}
 3
 4pub fn chars() -> lexer.Lexer(String, Nil) {
 5  lexer.simple([lexer.custom(fn(_, lexeme, _) { Keep(lexeme, Nil) })])
 6}
 7
 8pub fn run(
 9  lexer: lexer.Lexer(String, Nil),
10  on input: String,
11) -> List(Token(String)) {
12  let assert Ok(tokens) = lexer.run(input, lexer)
13
14  // Nibble's lexer prepends an empty string to the quasi_lexer's
15  // otherwise acceptable output
16  tokens |> list.drop(1)
17}