Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
stdlib
The GritQL standard library provides common patterns for refactoring and upgrading code. (by getgrit)
-
codeql
CodeQL: the libraries and queries that power security researchers around the world, as well as code scanning in GitHub Advanced Security
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
Yes, Grit does support embedded languages. Right now we support Vue syntax: https://github.com/getgrit/gritql/blob/4ff989e8d665cc9ffa2cb...
We don't have support for HTML yet, but if you open an issue we're happy to explore it.
- Iterate on large codebases quickly: we use Rust for maximum performance
GritQL has already been used on thousands of repositories for complex migrations[1] but we're excited to collaborate more with the open source community.
[1] Ex. https://github.com/openai/openai-python/discussions/742
This looks great, thanks for building and sharing it.
Interested folks may also want to check out ast-grep:
https://github.com/ast-grep/ast-grep
ast-grep is great too, we've learned a lot from them. If you like yaml, you should definitely try ast-grep.
The main area GritQL shines is taking simpler transformation patterns and composing them into complex migrations. For example, the OpenAI migration was built by incrementally handling the different edge cases we've seen in the wild: https://github.com/getgrit/stdlib/blob/main/.grit/patterns/p...
apologies if this should be a discussion/issue/whatever but:
Do you envision going up against CodeQL and/or <https://www.jetbrains.com/help/qodana/about-qodana.html> by making semantic information available to the ast nodes? OT1H, I can imagine it could be an overwhelming increase in project scope, but OTOH it could also truly lead to some stunning transformation patterns
e.g. https://github.com/github/codeql/blob/v1.27.0/java/ql/exampl... or even more "textual" semantics such as
var foo = "hello".substring(1); // knowing "foo" is a String
security is up there, but from reading the examples in CodeQL it just seemed like it would be possible to express some truly great versions of "don't do that" rules in it. I am a total JetBrains fanboi, and their introspections are world-class, but getting Qodana to run to completion before the heat death of the universe has proven to require more glucose than I have to offer it. Thus, I'm always interested in alternate implementations, even though I am acutely aware of the computational complexity of what I'm asking
I recalled another link I wish I had included in my question from the SourceGraph folks https://github.com/sourcegraph/scip#scip-code-intelligence-p... which started out life as "Language Server Indexing Protocol" and seems to solve some similar project-wide introspection questions but TBH since their rug pull I've been a lot less willing to hitch my wagon to their train
You should check out https://github.com/tweag/topiary
Yes, theoretically if you had ~identical grammars you could use it to do a full transpilation. There's a lot of challenges with that though. Writing a correct grammar for 1 language is complicated enough, but writing one for two where all your nodes and fields end up the same is likely insurmountable.
In practice, languages are either:
- Far enough apart that any pure AST transformation is insufficient and you need an AI component to produce usable output
Related posts
- AST-grep(sg) AST grep based on Treesitter
- How I build a chatbot for my OSS project, for free, without code!
- AST-grep(sg) is a CLI tool for code structural search, lint, and rewriting
- AST-grep(sg) is a CLI tool for code structural search, lint, and rewriting
- AST-grep(sg) is a CLI tool for code structural search, lint, and rewriting