Skip to content

peterhal/presto_rs

Repository files navigation

presto_rs

presto_rs is a Presto parser written in rust. It is a hand coded recursive descent parser based on the grammar in https://github.com/prestodb/presto/blob/master/presto-parser/src/main/antlr4/com/facebook/presto/sql/parser/SqlBase.g4.

Example usage:

fn parse(contents: &str) {
    let mut parser = Parser::new(contents);
    let tree = parser.parse_statement();
    let errors = errors_of_tree(&tree);
    if errors.is_empty() {
        println!("{:#?}", tree);
    } else {
        println!("{:#?}", errors[0]);
    }
}

See src/main.rs for the complete example usage.

Developing the parser:

  • parse trees are generated by adding to the list at the top of tools/generate_parse_trees/src/main.rs.
  • Then run ./scripts/generate_parse_trees.sh to regenerate src/parsing/parse_tree.rs.
  • The core parser is in /src/parsing/parser/rs.

About

Presto Parser in Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published