Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/m-novikov/tree-sitter-sql
SQL syntax highlighting for tree-sitter
https://github.com/m-novikov/tree-sitter-sql
grammar parser sql syntax syntax-highlighting tree-sitter
Last synced: about 20 hours ago
JSON representation
SQL syntax highlighting for tree-sitter
- Host: GitHub
- URL: https://github.com/m-novikov/tree-sitter-sql
- Owner: m-novikov
- License: mit
- Created: 2021-05-30T12:49:56.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-06T11:55:08.000Z (11 months ago)
- Last Synced: 2025-01-15T05:21:37.078Z (8 days ago)
- Topics: grammar, parser, sql, syntax, syntax-highlighting, tree-sitter
- Language: JavaScript
- Homepage:
- Size: 19.8 MB
- Stars: 112
- Watchers: 3
- Forks: 33
- Open Issues: 37
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Node.js CI](https://github.com/m-novikov/tree-sitter-sql/actions/workflows/node.js.yml/badge.svg)](https://github.com/m-novikov/tree-sitter-sql/actions/workflows/node.js.yml)
# 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](https://m-novikov.github.io/tree-sitter-sql/)
## Development
Install [pre-commit](https://pre-commit.com/#install) 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](./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](./test/corpus)
[Here](https://tree-sitter.github.io/tree-sitter/creating-parsers#command-test) is the documentation on test file syntax
### Running tests
```
npm install --also=dev
npm test
```### Debbuging
* `npm run parse ` outputs a syntax tree
* `npm run extract-error ` 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
* https://github.com/DerekStride/tree-sitter-sql
* https://github.com/dhcmrlchtdj/tree-sitter-sqlite
*