Skip to main content

Crate tree_sitter_postgres

Crate tree_sitter_postgres 

Source
Expand description

This crate provides PostgreSQL and PL/pgSQL language support for the tree-sitter parsing library.

Typically, you will use the LANGUAGE constant to add the PostgreSQL SQL grammar to a tree-sitter Parser, and LANGUAGE_PLPGSQL for PL/pgSQL:

let code = r#"
"#;
let mut parser = tree_sitter::Parser::new();
let language = tree_sitter_postgres::LANGUAGE;
parser
    .set_language(&language.into())
    .expect("Error loading Postgres parser");
let tree = parser.parse(code, None).unwrap();
assert!(!tree.root_node().has_error());

Constantsยง

LANGUAGE
The tree-sitter LanguageFn for the PostgreSQL SQL grammar.
LANGUAGE_PLPGSQL
The tree-sitter LanguageFn for the PL/pgSQL grammar.
NODE_TYPES
The content of the [node-types.json][] file for the PostgreSQL grammar.
NODE_TYPES_PLPGSQL
The content of the [node-types.json][] file for the PL/pgSQL grammar.