-
Notifications
You must be signed in to change notification settings - Fork 134
Introducing Kotlin-based parser generation #417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
KrylovBoris
wants to merge
81
commits into
JetBrains:master
Choose a base branch
from
KrylovBoris:rebasing-kotlin-generator
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Introducing Kotlin-based parser generation #417
KrylovBoris
wants to merge
81
commits into
JetBrains:master
from
KrylovBoris:rebasing-kotlin-generator
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(cherry picked from commit 70ab9d7)
…or api to use before importing ParserUtils
…erface in generator
…in way to generate grammars.
…them for external methods
c8afb6f to
145c4ed
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In this pull request, @Chr1sps and I have introduced a generation of parsers that use a new multiplatform Syntax API.
Why the changes were made?
Currently, generated parsers depend heavily on IntelliJ IDEA PSI-related functionality, which is written in Java and is not KMP-compatible. Syntax API alleviates this issue by reducing the number of dependencies and enabling Kotlin-based parsers.
These changes make Fleet-compatible generation obsolete, thus we had to remove associated functionality.
What has changed
We introduced
KotlinParserGeneratorclass that is responsible for generating Kotlin-based files. To access new functionality, you need to addgenerate=[parser-api="syntax"]to your grammar file. This allows us to use the same "Generated Parser Code" for both old Java parser generation and new Kotlin one.PSI support
To continue to support PSI-related functionality and keep it compatible with KMP, we added a setting that specifies a path to a separate module that will contain all generated PSI classes. This path must be relative to the project root.
Putting
psiOutputPath="your-psi-plugin"in your BNF file would generate files in the '/your-psi-plugin / gen' folder. This allows the user to keep their Java code and KMP code separated.How have the other parts of the plugin been affected?
Core generation functionality has been drastically changed, including the behaviour of the "Generate Parser Code "action. However, existing generation tests remained unchanged, ensuring that the main generation functionality remains stable.