OpenRewrite language module for Pascal

Recursive descent parser with lossless round-trip fidelity for pure
Pascal syntax (ISO 7185 / Turbo Pascal). Includes LST node definitions,
visitor, printer, remote serialization support, and a standalone LST
generator for Moderne CLI integration. 65 parser tests covering programs,
units, control flow, expressions, types, and more.
This commit is contained in:
t3hn3rd committed 2026-03-10 23:32:06 +00:00
commit 8915c205cd
37 files changed
+12795

No files matched your search

+66
View File
@@ -0,0 +1,66 @@
plugins {
id("java")
id("application")
}
group = "org.openrewrite"
version = "0.1.0-SNAPSHOT"
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
repositories {
mavenCentral()
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
}
}
val rewriteVersion = "8.45.0"
dependencies {
implementation(project(":rewrite-pascal"))
implementation(platform("org.openrewrite:rewrite-bom:${rewriteVersion}"))
implementation("org.openrewrite:rewrite-core")
implementation("org.openrewrite:rewrite-java")
// The Moderne CLI JAR provides TreeSerializer and related classes at runtime.
// It must be on the classpath when running the generator (via the launch script).
compileOnly(files(findModerneCli()))
}
application {
mainClass.set("org.openrewrite.pascal.generator.PascalLstGenerator")
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.compilerArgs.addAll(listOf("-parameters"))
}
// Create a fat JAR with all project dependencies (excluding the CLI JAR)
tasks.register<Jar>("fatJar") {
archiveClassifier.set("all")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from(sourceSets.main.get().output)
dependsOn(configurations.runtimeClasspath)
from({
configurations.runtimeClasspath.get()
.filter { it.name.endsWith("jar") }
.map { zipTree(it) }
})
manifest {
attributes["Main-Class"] = "org.openrewrite.pascal.generator.PascalLstGenerator"
}
}
fun findModerneCli(): String {
val cliJar = file("${System.getProperty("user.home")}/.moderne/cli/dist/lib/moderne-cli.jar")
if (cliJar.exists()) return cliJar.absolutePath
// Fallback: allow building without the CLI JAR (runtime-only dependency)
return ""
}
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
# Launch script for the Pascal LST Generator.
# Uses the Moderne CLI's bundled JRE (Java 25) and TreeSerializer.
#
# Usage: ./generate-lst.sh <source-dir> [output-dir]
# Example: ./generate-lst.sh /g/Asuro/Asuro
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
# Moderne CLI location
CLI_HOME="${HOME}/.moderne/cli/dist"
CLI_JRE="${CLI_HOME}/jre/bin/java"
CLI_JAR="${CLI_HOME}/lib/moderne-cli.jar"
if [ ! -f "$CLI_JRE" ]; then
echo "Error: Moderne CLI JRE not found at $CLI_JRE"
echo "Install it with: curl -s https://docs.moderne.io/moderne-cli/cli-intro | bash"
exit 1
fi
if [ ! -f "$CLI_JAR" ]; then
echo "Error: Moderne CLI JAR not found at $CLI_JAR"
exit 1
fi
# Build the generator fat JAR if needed
FAT_JAR="${SCRIPT_DIR}/build/libs/rewrite-pascal-generator-0.1.0-SNAPSHOT-all.jar"
if [ ! -f "$FAT_JAR" ]; then
echo "Building generator fat JAR..."
(cd "$PROJECT_ROOT" && ./gradlew :rewrite-pascal-generator:fatJar)
fi
echo "Running Pascal LST Generator..."
"$CLI_JRE" -cp "$FAT_JAR:$CLI_JAR" \
org.openrewrite.pascal.generator.PascalLstGenerator "$@"