Skip to content

About

The official grammar for GritQL, implemented as a tree sitter parser

Resources

Stars

23 stars

Watchers

2 watching

Forks

Repository files navigation

tree-sitter-gritql

CI Status MIT License Discord

A tree-sitter parser for GritQL files.

GritQl is an AST-aware query language for searching and transforming source code.

Syntax Example

language js

`console.log($my_message)` => `winston.info($my_message)` where {
  $my_message <: string()
}

Explore the interactive tutorial to learn more about GritQL.

TextMate Grammar

A TextMate grammar for GritQL lives in syntaxes/gritql.tmLanguage.json and ships with the npm package. Its scope name is source.gritql, and it covers both the Grit (Marzano) syntax in this repo and the GritQL dialect used by Biome plugins. It can be used by VS Code, Shiki, and GitHub Linguist.

The grammar has snapshot tests that run vscode-tmgrammar-test against the fixtures in test/grammar/. The fixtures are copied unchanged from real GritQL sources (Biome's and Marzano's test suites, and this repo's corpus); test/grammar/SOURCES.md lists where each one came from. Files in test/grammar/biome/ are valid Biome plugins, and files in test/grammar/marzano/ are valid for Grit's Marzano engine.

npm run test:grammar

After changing the grammar, regenerate the snapshots with npx vscode-tmgrammar-snap -s source.gritql -g syntaxes/gritql.tmLanguage.json --updateSnapshot "test/grammar/**/*.grit", then review the .snap diffs.

References

About

The official grammar for GritQL, implemented as a tree sitter parser

Resources

Stars

23 stars

Watchers

2 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages