javacc-wrapper: Avoid replace for non existent parser files

This avoids errors like
[ERROR] [replaceregexp] The following file is missing: '.../pmd/pmd-javascript/target/generated-sources/javacc/net/sourceforge/pmd/lang/ecmascript5/ast/Ecmascript5ParserImpl.java'
This commit is contained in:
Andreas Dangel 2024-03-07 12:01:57 +01:00
parent a69068de2d
commit e9a004e8dd
No known key found for this signature in database
GPG Key ID: 93450DF2DF9A3FA3

View File

@ -19,6 +19,9 @@
- lang-id: The language id, used in the conventional package names
- no-jjtree: true/false. Use true for CPD-only languages. Then a parser won't
be generated. By default, a parser will be generated (and jjtree will be called).
It also uses the following maven properties:
- javacc.outputDirectory: Directory in which to root the generated package tree
@ -219,11 +222,11 @@
</target>
<target name="cleanup-parser">
<target name="cleanup-parser" unless="jjtreeBuildNotRequired">
<replace token="new Token()" value="token_source.input_stream.getTokenDocument().open()">
<fileset file="${parser-file}" />
<file name="${parser-file}" />
</replace>
<replaceregexp flags="g">
@ -242,25 +245,25 @@
<replaceregexp flags="g">
<regexp pattern="\bJJT${parser-name}State\b" />
<substitution expression="${ast-impl-package}.JjtreeBuilder&lt;${base-class-name}&gt;" />
<fileset file="${parser-file}" />
<file name="${parser-file}" />
</replaceregexp>
<replaceregexp flags="g">
<regexp pattern="new ParseException\(token, exptokseq, tokenImage\);" />
<substitution expression="new ParseException(token, exptokseq);" />
<fileset file="${parser-file}" />
<file name="${parser-file}" />
</replaceregexp>
<replaceregexp flags="g">
<regexp pattern="throw new ParseException\(\);" />
<substitution expression='throw net.sourceforge.pmd.util.AssertionUtil.shouldNotReachHere("consumetoken(-1) should have thrown");' />
<fileset file="${parser-file}" />
<file name="${parser-file}" />
</replaceregexp>
<replaceregexp>
<regexp pattern="public interface"/>
<substitution expression="interface"/>
<fileset file="${target-package-dir}/${parser-name}TreeConstants.java" />
<file name="${target-package-dir}/${parser-name}TreeConstants.java" />
</replaceregexp>
</target>
@ -372,8 +375,8 @@
<replaceregexp>
<regexp pattern="package ${lang-ast-package};" />
<substitution expression="\0${line.separator}${line.separator}import static ${lang-ast-package}.${token-constants-name}.*;" />
<fileset file="${tokenmgr-file}" />
<fileset file="${parser-file}" />
<file name="${tokenmgr-file}" />
<file name="${parser-file}" />
</replaceregexp>
<!-- Create constants file -->
@ -387,26 +390,26 @@
public final class ${token-constants-name} \{${line.separator}
private ${token-constants-name}() { /* Utility class */ }${line.separator}
"/>
<fileset file="${token-constants-file}" />
<file name="${token-constants-file}" />
</replaceregexp>
<replaceregexp flags="g">
<regexp pattern="/\*\* RegularExpression Id. \*/\R" />
<substitution expression="public static final " />
<fileset file="${token-constants-file}" />
<file name="${token-constants-file}" />
</replaceregexp>
<replaceregexp flags="s">
<regexp pattern="/\*\* End of File. \*/\R" />
<substitution expression="public static final " />
<fileset file="${token-constants-file}" />
<file name="${token-constants-file}" />
</replaceregexp>
<!-- Lexical states are kept package-private -->
<replaceregexp flags="g">
<regexp pattern="/\*\* Lexical state. \*/\R" />
<substitution expression="static final " />
<fileset file="${token-constants-file}" />
<file name="${token-constants-file}" />
</replaceregexp>
<replace>
@ -438,7 +441,7 @@ public final class ${token-constants-name} \{${line.separator}
private static final
]]> </replacevalue>
<fileset file="${token-constants-file}" />
<file name="${token-constants-file}" />
</replace>
<replace>
@ -449,19 +452,19 @@ public final class ${token-constants-name} \{${line.separator}
/** Nams of the tokens, each index corresponds to a kind. See also {@link #describe(int)}. */
public static final java.util.List<String> TOKEN_NAMES = java.util.Collections.unmodifiableList(java.util.Arrays.asList(tokenImage));
]]> </replacevalue>
<fileset file="${token-constants-file}" />
<file name="${token-constants-file}" />
</replace>
<replaceregexp>
<regexp pattern="%%%TOKEN_MGR_NAME%%%" />
<substitution expression="${tokenmgr-name}" />
<fileset file="${token-constants-file}" />
<file name="${token-constants-file}" />
</replaceregexp>
<replaceregexp flags="g">
<regexp pattern="%%%API_PACK%%%" />
<substitution expression="${ast-api-package}" />
<fileset file="${token-constants-file}" />
<file name="${token-constants-file}" />
</replaceregexp>
</target>
@ -471,7 +474,7 @@ public final class ${token-constants-name} \{${line.separator}
<replaceregexp flags="g">
<regexp pattern="return new ${tokenmgr-name}\(cs\);" />
<substitution expression="return new ${parser-name}(cs).token_source;" />
<fileset file="${token-constants-file}"/>
<file name="${token-constants-file}" />
</replaceregexp>
</target>