mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-30 18:27:49 +08:00
custom language tutorial: move step (IJSDK-1353, 2.3)
This commit is contained in:
parent
153d545faa
commit
c792692656
@ -62,10 +62,24 @@ Note that the `SimpleTypes` class in the `elementTypeHolderClass` attribute abov
|
||||
## Generate a Parser
|
||||
Now that the grammar is defined, generate a parser with PSI classes via <control>Generate Parser Code</control> from the context menu on the <path>Simple.bnf</path> file.
|
||||
This step generates a parser and PSI elements in the <path>/src/main/gen</path> folder of the project.
|
||||
Mark this folder as <control>Generated Sources Root</control> and make sure everything compiles without errors.
|
||||
|
||||
> Gradle plugin [gradle-grammarkit-plugin](https://github.com/JetBrains/gradle-grammar-kit-plugin) can be used alternatively.
|
||||
>
|
||||
{type="tip"}
|
||||
|
||||
{width="800"}
|
||||
|
||||
## Add Generated Sources Root
|
||||
|
||||
To include the sources generated into <path>/src/main/gen</path>, the project's `sourceSets` must be expanded by inserting the following line in the project's <path>build.gradle</path> file:
|
||||
|
||||
```groovy
|
||||
sourceSets.main.java.srcDirs 'src/main/gen'
|
||||
```
|
||||
|
||||
Or the following line in the project's <path>build.gradle.kts</path> file:
|
||||
```kotlin
|
||||
sourceSets["main"].java.srcDirs("src/main/gen")
|
||||
```
|
||||
|
||||
Reload the Gradle project for changes to take effect and build the project.
|
||||
|
@ -9,21 +9,6 @@ The easiest way to create a lexer is to use [JFlex](https://jflex.de/).
|
||||
|
||||
**Reference**: [](implementing_lexer.md)
|
||||
|
||||
## Required Project Configuration Change
|
||||
The previous tutorial step [Grammar and Parser](grammar_and_parser.md), and this page, generate source files in the directory <path>src/main/gen</path>.
|
||||
To include those files, the project's `sourceSets` must be expanded by inserting the following line in the project's <path>build.gradle</path> file:
|
||||
|
||||
```groovy
|
||||
sourceSets.main.java.srcDirs 'src/main/gen'
|
||||
```
|
||||
|
||||
Or the following line in the project's <path>build.gradle.kts</path> file:
|
||||
```kotlin
|
||||
sourceSets["main"].java.srcDirs("src/main/gen")
|
||||
```
|
||||
|
||||
Reload the Gradle project for changes to take effect.
|
||||
|
||||
## Define a Lexer
|
||||
Define a <path>Simple.flex</path> file with rules for the Simple Language lexer, as demonstrated in `org.intellij.sdk.language.Simple.flex`.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user