From 9dfd4ee55dc1596ce7abad2c99173d50b78070a9 Mon Sep 17 00:00:00 2001 From: Martin Hickson Date: Wed, 11 Nov 2026 10:23:34 +1300 Subject: [PATCH] Generate the XPath parser with CUP 0.10k and the vendored JLex. edu.princeton.cup:java-cup:10k emits the same parser as tools/java_cup.jar, and tools/JLex.jar is run with -static. --- build-support/prepare-sources.groovy | 25 +++++++++++++------------ pom.xml | 6 +++--- xalan/pom.xml | 16 +++------------- 3 files changed, 19 insertions(+), 28 deletions(-) diff --git a/build-support/prepare-sources.groovy b/build-support/prepare-sources.groovy index eda8246ae..14e5bb5d6 100644 --- a/build-support/prepare-sources.groovy +++ b/build-support/prepare-sources.groovy @@ -111,16 +111,15 @@ if (command == 'generate-serializer') { def compilerOut = new File(generated, 'org/apache/xalan/xsltc/compiler') compilerOut.mkdirs() def codegen = new File(moduleTarget, 'codegen') - def cupJar = codegen.listFiles().find { it.name.startsWith('java-cup-') && !it.name.startsWith('java-cup-runtime-') } - def cupRuntimeJar = codegen.listFiles().find { it.name.startsWith('java-cup-runtime-') } - def jlexJar = codegen.listFiles().find { it.name.contains('jlex') || it.name.contains('JLex') } - if (!cupJar || !cupRuntimeJar || !jlexJar) { - throw new IllegalStateException("Maven codegen jars are missing from ${codegen}") + def cupJar = codegen.listFiles().find { it.name.startsWith('java-cup-') && it.name.endsWith('.jar') } + def jlexJar = new File(repo, 'tools/JLex.jar') + if (!cupJar?.isFile() || !jlexJar.isFile()) { + throw new IllegalStateException("CUP or tools/JLex.jar is missing") } run([ javaBin.absolutePath, '-cp', - cupJar.absolutePath + File.pathSeparator + cupRuntimeJar.absolutePath, + cupJar.absolutePath, 'java_cup.Main', '-parser', 'XPathParser', '-expect', '0', @@ -138,17 +137,19 @@ if (command == 'generate-serializer') { new File(repo, 'src/org/apache/xalan/xsltc/compiler/xpath.lex').toPath(), lexCopy.toPath(), StandardCopyOption.REPLACE_EXISTING) - def lexer = new File(compilerOut, 'XPathLexer.java') run([ javaBin.absolutePath, '-cp', jlexJar.absolutePath, - 'jlex.Main', - lexCopy.absolutePath, - lexer.absolutePath + 'JLex.Main', + '-static', + lexCopy.absolutePath ], compilerOut) - if (!lexer.isFile()) { - throw new IllegalStateException("JLex did not write XPathLexer.java") + def generatedLexer = new File(compilerOut, 'xpath.lex.java') + def lexer = new File(compilerOut, 'XPathLexer.java') + if (!generatedLexer.isFile()) { + throw new IllegalStateException("JLex did not write xpath.lex.java") } + Files.move(generatedLexer.toPath(), lexer.toPath(), StandardCopyOption.REPLACE_EXISTING) lexCopy.delete() } else { throw new IllegalArgumentException("Unknown command ${command}") diff --git a/pom.xml b/pom.xml index ec23658bc..0716057ea 100644 --- a/pom.xml +++ b/pom.xml @@ -42,7 +42,7 @@ 1.4.01 6.7.0 1.3 - 11b-20160615-3 + 10k @@ -68,8 +68,8 @@ ${regexp.version} - com.github.vbmacher - java-cup-runtime + edu.princeton.cup + java-cup ${java-cup.version} diff --git a/xalan/pom.xml b/xalan/pom.xml index 6392a9771..fe4ec6995 100644 --- a/xalan/pom.xml +++ b/xalan/pom.xml @@ -51,8 +51,8 @@ regexp - com.github.vbmacher - java-cup-runtime + edu.princeton.cup + java-cup @@ -90,20 +90,10 @@ ${project.build.directory}/codegen - com.github.vbmacher + edu.princeton.cup java-cup ${java-cup.version} - - com.github.vbmacher - java-cup-runtime - ${java-cup.version} - - - net.sourceforge.maven-jlex - maven-jlex-plugin - 1.0 -