Tier 2 golden trees, and #scope_file is a statement not a modifier
isDeclarationAhead used to skip *any* directive, so '#scope_file' was absorbed as
a modifier of the declaration after it. That misreports scope, since a scope
directive governs everything that follows it. Only #as, #overlay, #add_context
and #no_reset actually prefix a declaration in the corpus; the rest are
statements now, which the regenerated Directives.txt shows.
Golden fixtures cover the reference doc's gotcha list: declaration forms,
procedures (named/multiple/variadic/polymorphic/foreign returns), structs, enums,
unions, array and pointer types, the 'if x == { case }' switch form, for
modifiers, ifx, and directives including a here-string.
DebugParseTest is now inert by default and documented as the scratch loop.
generateParser wipes its output through a Delete task rather than a doFirst,
because a lambda added from a Kotlin build script captures the script object and
breaks the configuration cache ('./jaigradle check' failed to store it).
check and verifyPlugin (IU-253/261/262) both green.
This commit is contained in:
@@ -8,9 +8,11 @@ plugins {
|
||||
}
|
||||
|
||||
// Grammar-Kit output. Committed so diffs are reviewable, never hand-edited.
|
||||
val generatedSourceDir = file("src/main/gen")
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java.srcDirs("src/main/gen")
|
||||
java.srcDirs(generatedSourceDir)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,20 +30,25 @@ dependencies {
|
||||
}
|
||||
}
|
||||
|
||||
// purgeOldFiles is not enough: Grammar-Kit rewrites only the files whose rule
|
||||
// changed, so a PSI interface can keep an accessor its regenerated Impl no longer has
|
||||
// (`JaiDeclaration.getArgumentList()` with no override) and the build then fails
|
||||
// inside generated code. Wiping first makes every generation self-consistent.
|
||||
//
|
||||
// This is a separate Delete task rather than a doFirst, because any lambda added to a
|
||||
// task from a Kotlin build script captures the script object, which the configuration
|
||||
// cache cannot serialize.
|
||||
val cleanGeneratedSources by tasks.registering(Delete::class) {
|
||||
delete(generatedSourceDir)
|
||||
}
|
||||
|
||||
tasks.generateParser {
|
||||
dependsOn(cleanGeneratedSources)
|
||||
sourceFile.set(file("src/main/grammar/Jai.bnf"))
|
||||
targetRootOutputDir.set(file("src/main/gen"))
|
||||
targetRootOutputDir.set(generatedSourceDir)
|
||||
pathToParser.set("dev/hgh/jai/parser/JaiParser.java")
|
||||
pathToPsiRoot.set("dev/hgh/jai/psi")
|
||||
purgeOldFiles.set(true)
|
||||
|
||||
// purgeOldFiles is not enough: Grammar-Kit rewrites only the files whose rule
|
||||
// changed, so a PSI interface can keep an accessor its regenerated Impl no longer
|
||||
// has (`JaiDeclaration.getArgumentList()` with no override) and the build fails on
|
||||
// generated code. Always regenerate the whole tree.
|
||||
doFirst {
|
||||
delete(file("src/main/gen"))
|
||||
}
|
||||
}
|
||||
|
||||
// Without this the compile tasks read src/main/gen with no ordering guarantee, so an
|
||||
|
||||
Reference in New Issue
Block a user