devgen-tree-sitter-sql

Crates.iodevgen-tree-sitter-sql
lib.rsdevgen-tree-sitter-sql
version
sourcesrc
created_at2024-11-18 10:04:08.930732
updated_at2024-11-18 10:04:08.930732
descriptionSQL grammar for the tree-sitter parsing library
homepage
repositoryhttps://github.com/m-novikov/tree-sitter-sql
max_upload_size
id1452058
Cargo.toml error:TOML parse error at line 24, column 1 | 24 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
imotai (imotai)

documentation

README

Node.js CI

SQL syntax for tree-sitter

This project initially focuses on PostgreSQL flavor of SQL

Try it out

You can try out the parser here: Tree Sitter SQL Playground

Development

Install pre-commit and run pre-commit install in the root of this repo. This will ensure that code follows code style of this repo.

File describing grammar is grammar.js

Every time the grammar file changes code generation needs to be run by invoking npm run gen

npm test command automatically performs code generation

Tests files are located in test/corpus

Here is the documentation on test file syntax

Running tests

npm install --also=dev
npm test

Debbuging

  • npm run parse <file.sql> outputs a syntax tree
  • npm run extract-error <file.sql> shows first offending line

Goals

This parser is supposed to be used in text editors. As a result:

  • it's very lax in what it considers valid SQL parse
  • adding extra nodes to have convenient selection anchors is okay

Other projects

Commit count: 200

cargo fmt