Adds src/main/grammar/Jai.bnf, the generated parser/PSI in src/main/gen, a
JaiParserDefinition, and the Tier 3 corpus parse gate (406/714 files clean).
Two things were not obvious:
- Grammar-Kit mints its own token instances from the .bnf 'tokens' block, which
are different objects from the ones JaiLexer emits, so every rule silently
failed to match. Fixed with tokenTypeFactory -> JaiTokenTypes.byName.
- A backslash inside an identifier is a continuation in the compiler's lexer
(Jai_Lexer/module.jai:444): 'left\_margin' is one identifier. JaiLexer now
does the same; the Tier 0 round-trip still holds because the token span
covers the backslash and the skipped spaces.
Constructs that BNF alone cannot express live in JaiParserUtil: directive-name
tests (#ident is one token), '==' before '{' for the switch form, procedure
header vs parenthesised expression, and the declaration lookahead.
37 lines
1.1 KiB
Kotlin
37 lines
1.1 KiB
Kotlin
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
|
|
|
|
plugins {
|
|
id("org.jetbrains.kotlin.jvm")
|
|
id("org.jetbrains.changelog")
|
|
id("org.jetbrains.intellij.platform")
|
|
id("org.jetbrains.intellij.platform.grammarkit")
|
|
}
|
|
|
|
sourceSets {
|
|
main {
|
|
java.srcDirs("src/main/gen")
|
|
}
|
|
}
|
|
|
|
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html
|
|
dependencies {
|
|
testImplementation(libs.junit)
|
|
|
|
// IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html
|
|
intellijPlatform {
|
|
intellijIdea("2025.3.5")
|
|
testFramework(TestFrameworkType.Platform)
|
|
|
|
// Add plugin dependencies for compilation here, for example:
|
|
// bundledPlugin("com.intellij.java")
|
|
}
|
|
}
|
|
|
|
tasks.generateParser {
|
|
sourceFile.set(file("src/main/grammar/Jai.bnf"))
|
|
targetRootOutputDir.set(file("src/main/gen"))
|
|
pathToParser.set("dev/hgh/jai/parser/JaiParser.java")
|
|
pathToPsiRoot.set("dev/hgh/jai/psi")
|
|
purgeOldFiles.set(true)
|
|
}
|