- Restructure conditionals into a condExpr precedence level and exception handling into a postfix rule, removing the mutual left recursion through expr/atomExpr (ANTLR error 119) - Rewrite pattern as patternAtom (COMMA patternAtom)*, removing left recursion with an empty-matchable tail (ANTLR error 148) - Drop the LAMBDA token fully shadowed by LAMBDA_VAR (warning 184) - Give \Rightarrow to EXPORT only; IMPLIES keeps \implies (warning 184) - Remove @header package declaration that duplicated the -package argument and made the generated parser uncompilable - Point the ANTLR source set at src/main/antlr4 so Gradle actually finds the grammar - Treat ANTLR warnings as errors (-Werror) - Record decisions in DECISIONS.md
54 lines
No EOL
1.3 KiB
Groovy
54 lines
No EOL
1.3 KiB
Groovy
plugins {
|
|
id 'java'
|
|
id 'antlr'
|
|
}
|
|
|
|
group = 'com.mpl'
|
|
version = '0.1-alpha'
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
|
|
dependencies {
|
|
antlr 'org.antlr:antlr4:4.13.1'
|
|
implementation 'org.antlr:antlr4-runtime:4.13.1'
|
|
|
|
testImplementation 'junit:junit:4.13.2'
|
|
testImplementation 'org.hamcrest:hamcrest:2.2'
|
|
}
|
|
|
|
generateGrammarSource {
|
|
maxHeapSize = "64m"
|
|
// -Werror: any ANTLR warning (e.g. 184, token shadowing) fails the build
|
|
arguments += ["-visitor", "-listener", "-Werror", "-package", "com.mpl.parser"]
|
|
outputDirectory = file("${project.buildDir}/generated-src/antlr/main/com/mpl/parser")
|
|
}
|
|
|
|
compileJava.dependsOn generateGrammarSource
|
|
|
|
sourceSets {
|
|
main {
|
|
antlr {
|
|
// The Gradle ANTLR plugin defaults to src/main/antlr; the grammar
|
|
// lives in src/main/antlr4 (Maven layout).
|
|
srcDirs = ['src/main/antlr4']
|
|
}
|
|
java {
|
|
srcDirs += "${project.buildDir}/generated-src/antlr/main"
|
|
}
|
|
}
|
|
}
|
|
|
|
test {
|
|
testLogging {
|
|
events "passed", "skipped", "failed"
|
|
exceptionFormat "full"
|
|
}
|
|
}
|
|
|
|
task parseExamples(type: JavaExec, dependsOn: classes) {
|
|
mainClass = 'com.mpl.test.ParseExamples'
|
|
classpath = sourceSets.main.runtimeClasspath
|
|
args = ['examples']
|
|
} |