The target language is the programming language of the code you want to migrate. Currently, Grit supports the following target languages:
- JavaScript/TypeScript
- Python
- JSON
- Java (Alpha)
- Terraform HCL (Alpha)
- Solidity (Alpha)
- CSS
- Markdown (Alpha)
- YAML (Alpha)
- Rust
- Ruby (Beta)
- PHP (Beta)
- Go (Alpha)
- SQL (Alpha)
If you would like to see support for a language that is not listed here, please let us know.
Language declaration
Grit supports multiple target languages. To select a language, start a pattern file with a language declaration.
language js `myPattern`
If no language is specified, Grit defaults to JavaScript. This behavior may change in the future, so it is recommended to always specify a language.
Language variants
In some rare cases, you may need to specify an alternative parser for a language. Alternative parsers can be specified in parentheses with the language declaration.
language js(jsx)
The above example specifies the jsx
version of JavaScript, which enables JSX syntax.
The following are a few examples of available language versions:
language js(typescript,jsx)
-- TypeScript with JSX enabledlanguage js(typescript)
-- TypeScript without JSX
For JavaScript without a language version, Grit will default to TypeScript with JSX enabled (specifically language js(typescript,jsx)
).
When parsing JavaScript code files, Grit decides which language version to use based the language of the GritQL pattern being executed.