lex_lua

Crates.iolex_lua
lib.rslex_lua
version0.2.0
sourcesrc
created_at2021-01-04 03:33:09.623658
updated_at2024-05-15 19:09:07.160486
descriptionA lexer for Lua
homepage
repositoryhttps://github.com/FreeMasen/lex_lua
max_upload_size
id331369
size36,678
Robert Masen (FreeMasen)

documentation

README

Lex Lua

A Lua lexer written in Rust.

Example

use lex_lua::Lexer;

fn main() {
    let bytes = std::fs::read("./readme.lua").unwrap();
    let l = Lexer::new(bytes.as_slice());
    for (i, token) in l.enumerate() {
        println!("{}: {:?}", i, token);
    }
}
$ cargo run --example readme
0: Keyword(Function)
1: Name("say_hello")
2: Punct(OpenParen)
3: Punct(CloseParen)
4: Name("print")
5: Punct(OpenParen)
6: LiteralString("\'Hi!\'")
7: Punct(CloseParen)
8: Keyword(End)
9: Name("say_hello")
10: Punct(OpenParen)
11: Punct(CloseParen)
Commit count: 23

cargo fmt