luaparse 0.1.1

A Lua 5.3 parser
Documentation

luaparse

A Lua 5.3 parser. Preserves insignificant tokens (whitespace and comments) in the syntax tree.

Documentation.

Example

use luaparse::cursor::InputCursor;
use luaparse::error::Error;
use luaparse::lexer::Lexer;
use luaparse::parser::Parser;
use luaparse::span::HasSpan;

let buf = r#"
local a = 42
local b = 24

for i = 1, 100, 1 do
  b = a - b + i
end

print(b)
"#;

let mut parser = Parser::new(Lexer::new(InputCursor::new(buf)));

match parser.chunk() {
    Ok(block) => println!("{}", block),
    Err(e) => eprintln!("{:#}", Error::new(e.span(), e).with_buffer(buf)),
}