Move CharStream into impl.javacc package

This commit is contained in:
Clément Fournier
2020-01-06 16:30:25 +01:00
parent 65a28827e3
commit 4ce104a41b
24 changed files with 102 additions and 81 deletions

View File

@ -2,6 +2,17 @@
<property name="javacc-home.path" value="target/lib" />
<property name="tmp-package" value="net.sourceforge.pmd.lang.ast.dummy" />
<property name="tmp-package.dir" value="${target}/net/sourceforge/pmd/lang/ast/dummy" />
<property name="base-ast-package" value="net.sourceforge.pmd.lang.ast" />
<property name="base-ast-package.dir" value="${target}/net/sourceforge/pmd/lang/ast" />
<property name="target-package" value="${base-ast-package}.impl.javacc" />
<property name="target-package.dir" value="${base-ast-package.dir}/impl/javacc" />
<target name="alljavacc"
description="Generates all JavaCC aspects within PMD"
depends="checkUpToDate,init,dummyjjtree,cleanup" />
@ -27,88 +38,98 @@
<target name="dummyjjtree" description="Generates the reusable JavaCC aspects" unless="javaccBuildNotRequired">
<delete dir="${target}/net/sourceforge/pmd/lang/ast/dummy" />
<mkdir dir="${target}/net/sourceforge/pmd/lang/ast/dummy" />
<delete dir="${tmp-package.dir}" />
<mkdir dir="${tmp-package.dir}" />
<echo>Using JavaCC home: ${javacc-home.path}</echo>
<jjtree target="etc/grammar/dummy.jjt"
outputdirectory="${target}/net/sourceforge/pmd/lang/ast/dummy"
outputdirectory="${tmp-package.dir}"
javacchome="${javacc-home.path}" />
<!-- Generate CharStream interface -->
<javacc usercharstream="true"
target="${target}/net/sourceforge/pmd/lang/ast/dummy/dummy.jj"
outputdirectory="${target}/net/sourceforge/pmd/lang/ast/dummy"
target="${tmp-package.dir}/dummy.jj"
outputdirectory="${tmp-package.dir}"
javacchome="${javacc-home.path}" />
<replace file="${target}/net/sourceforge/pmd/lang/ast/dummy/CharStream.java"
token="net.sourceforge.pmd.lang.ast.dummy"
value="net.sourceforge.pmd.lang.ast" />
<move overwrite="true"
file="${target}/net/sourceforge/pmd/lang/ast/dummy/CharStream.java"
tofile="${target}/net/sourceforge/pmd/lang/ast/CharStream.java" />
<!-- Generate ASCII w/ Unicode Escapes CharStream implementation -->
<javacc usercharstream="false"
unicodeinput="false"
javaunicodeescape="true"
static="false"
target="${target}/net/sourceforge/pmd/lang/ast/dummy/dummy.jj"
outputdirectory="${target}/net/sourceforge/pmd/lang/ast/dummy"
target="${tmp-package.dir}/dummy.jj"
outputdirectory="${tmp-package.dir}"
javacchome="${javacc-home.path}" />
<replace file="${target}/net/sourceforge/pmd/lang/ast/dummy/JavaCharStream.java"
token="net.sourceforge.pmd.lang.ast.dummy"
value="net.sourceforge.pmd.lang.ast.impl.javacc" />
<replace file="${target}/net/sourceforge/pmd/lang/ast/dummy/JavaCharStream.java"
<replace file="${tmp-package.dir}/JavaCharStream.java"
token="${tmp-package}"
value="${target-package}">
<fileset dir="${tmp-package.dir}">
</fileset>
</replace>
<!-- Patch JavaCharStream -->
<replace file="${tmp-package.dir}/JavaCharStream.java"
token="JavaCharStream"
value="JavaCharStreamBase"/>
<replace file="${target}/net/sourceforge/pmd/lang/ast/dummy/JavaCharStream.java"
<replace file="${tmp-package.dir}/JavaCharStream.java"
token="class JavaCharStreamBase"
value="abstract class JavaCharStreamBase implements net.sourceforge.pmd.lang.ast.CharStream" />
<replace file="${target}/net/sourceforge/pmd/lang/ast/dummy/JavaCharStream.java"
value="abstract class JavaCharStreamBase implements ${target-package}.CharStream" />
<replace file="${tmp-package.dir}/JavaCharStream.java"
token="char c;"
value="char c; beforeReadChar();" />
<replace file="${target}/net/sourceforge/pmd/lang/ast/dummy/JavaCharStream.java"
<replace file="${tmp-package.dir}/JavaCharStream.java"
token="/** Read a character. */"
value="protected void beforeReadChar() { }" />
<move overwrite="true"
file="${target}/net/sourceforge/pmd/lang/ast/dummy/JavaCharStream.java"
tofile="${target}/net/sourceforge/pmd/lang/ast/impl/javacc/JavaCharStreamBase.java" />
file="${tmp-package.dir}/JavaCharStream.java"
tofile="${target-package.dir}/JavaCharStreamBase.java" />
<!-- Generate ASCII w/o Unicode Escapes CharStream implementation -->
<javacc usercharstream="false"
unicodeinput="false"
javaunicodeescape="false"
static="false"
target="${target}/net/sourceforge/pmd/lang/ast/dummy/dummy.jj"
outputdirectory="${target}/net/sourceforge/pmd/lang/ast/dummy"
target="${tmp-package.dir}/dummy.jj"
outputdirectory="${tmp-package.dir}"
javacchome="${javacc-home.path}" />
<replace file="${target}/net/sourceforge/pmd/lang/ast/dummy/SimpleCharStream.java"
token="net.sourceforge.pmd.lang.ast.dummy"
value="net.sourceforge.pmd.lang.ast" />
<replace file="${target}/net/sourceforge/pmd/lang/ast/dummy/SimpleCharStream.java"
<replace file="${tmp-package.dir}/SimpleCharStream.java"
token="public class SimpleCharStream"
value="public class SimpleCharStream implements CharStream" />
<move overwrite="true"
file="${target}/net/sourceforge/pmd/lang/ast/dummy/SimpleCharStream.java"
tofile="${target}/net/sourceforge/pmd/lang/ast/SimpleCharStream.java" />
<replace file="${target}/net/sourceforge/pmd/lang/ast/dummy/TokenMgrError.java"
token="net.sourceforge.pmd.lang.ast.dummy"
value="net.sourceforge.pmd.lang.ast" />
<replace file="${target}/net/sourceforge/pmd/lang/ast/dummy/TokenMgrError.java"
<replace file="${tmp-package.dir}/TokenMgrError.java"
token="${target-package}"
value="${base-ast-package}" />
<replace file="${tmp-package.dir}/TokenMgrError.java"
token="extends Error"
value="extends RuntimeException" />
<replace file="${target}/net/sourceforge/pmd/lang/ast/dummy/TokenMgrError.java"
<replace file="${tmp-package.dir}/TokenMgrError.java"
token="static final int"
value="public static final int" />
<replace file="${target}/net/sourceforge/pmd/lang/ast/dummy/TokenMgrError.java">
<replacetoken><![CDATA["Lexical error at line "]]></replacetoken>
<replacevalue><![CDATA["Lexical error in file " + net.sourceforge.pmd.lang.ast.impl.javacc.AbstractTokenManager.getFileName() + " at line "]]></replacevalue>
</replace>
<move overwrite="true"
file="${target}/net/sourceforge/pmd/lang/ast/dummy/TokenMgrError.java"
tofile="${target}/net/sourceforge/pmd/lang/ast/TokenMgrError.java" />
<delete dir="${target}/net/sourceforge/pmd/lang/ast/dummy" />
<replace file="${tmp-package.dir}/TokenMgrError.java">
<replacetoken><![CDATA["Lexical error at line "]]></replacetoken>
<replacevalue>&quot;Lexical error in file &quot; + net.sourceforge.pmd.lang.ast.impl.javacc.AbstractTokenManager.getFileName() + &quot; at line &quot;</replacevalue>
</replace>
<move overwrite="true"
file="${tmp-package.dir}/TokenMgrError.java"
tofile="${base-ast-package.dir}/TokenMgrError.java" />
<move overwrite="true"
todir="${target-package.dir}">
<fileset dir="${tmp-package.dir}">
<include name="SimpleCharStream.java" />
<include name="CharStream.java" />
</fileset>
</move>
<delete dir="${tmp-package.dir}" />
</target>

View File

@ -32,7 +32,7 @@ options {
PARSER_BEGIN(CppParser)
package net.sourceforge.pmd.lang.cpp.ast;
import net.sourceforge.pmd.lang.ast.CharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
import net.sourceforge.pmd.lang.ast.TokenMgrError;
public final class CppParser {

View File

@ -8,7 +8,7 @@ import java.io.IOException;
import java.io.Reader;
import java.util.regex.Pattern;
import net.sourceforge.pmd.lang.ast.SimpleCharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.SimpleCharStream;
/**
* A SimpleCharStream, that supports the continuation of lines via backslash+newline,

View File

@ -250,7 +250,7 @@ package net.sourceforge.pmd.lang.java.ast;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.sourceforge.pmd.lang.ast.CharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
import net.sourceforge.pmd.lang.ast.GenericToken;
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;
import net.sourceforge.pmd.lang.ast.TokenMgrError;

View File

@ -4,7 +4,7 @@
package net.sourceforge.pmd.lang.java.ast;
import net.sourceforge.pmd.lang.ast.CharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
import net.sourceforge.pmd.lang.ast.impl.TokenDocument;
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaCharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;

View File

@ -15,7 +15,7 @@ options {
PARSER_BEGIN(Ecmascript5Parser)
package net.sourceforge.pmd.lang.ecmascript5.ast;
import net.sourceforge.pmd.lang.ast.CharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
import net.sourceforge.pmd.lang.ast.TokenMgrError;
public class Ecmascript5Parser {

View File

@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang.ecmascript5;
import java.io.Reader;
import net.sourceforge.pmd.lang.TokenManager;
import net.sourceforge.pmd.lang.ast.SimpleCharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.SimpleCharStream;
import net.sourceforge.pmd.lang.ecmascript5.ast.Ecmascript5ParserTokenManager;
/**

View File

@ -15,26 +15,26 @@
* Script code inside <script> ... </script> is not parsed.
*/
options {
options {
USER_CHAR_STREAM = true;
NODE_USES_PARSER=true;
UNICODE_INPUT=true;
FORCE_LA_CHECK = false;
IGNORE_CASE = true;
STATIC = false;
FORCE_LA_CHECK = false;
IGNORE_CASE = true;
STATIC = false;
MULTI=true;
VISITOR=true;
TRACK_TOKENS = true;
}
}
PARSER_BEGIN(JspParser)
package net.sourceforge.pmd.lang.jsp.ast;
import net.sourceforge.pmd.lang.ast.CharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
import net.sourceforge.pmd.lang.ast.TokenMgrError;
/**
/**
* JSP Parser for PMD.
* @author Pieter, Application Engineers NV/SA, http://www.ae.be
*/

View File

@ -11,7 +11,7 @@ import net.sourceforge.pmd.lang.ParserOptions;
import net.sourceforge.pmd.lang.TokenManager;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.ast.ParseException;
import net.sourceforge.pmd.lang.ast.SimpleCharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.SimpleCharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.AbstractTokenManager;
/**

View File

@ -21,7 +21,7 @@ options {
PARSER_BEGIN(MatlabParser)
package net.sourceforge.pmd.lang.matlab.ast;
import net.sourceforge.pmd.lang.ast.CharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
import net.sourceforge.pmd.lang.ast.TokenMgrError;
public class MatlabParser {
@ -159,4 +159,4 @@ PARSER_END(MatlabParser)
<DEFAULT, TRANSPOSE> TOKEN :
{
< TR : "'" > : TRANSPOSE
}
}

View File

@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang.matlab;
import java.io.Reader;
import net.sourceforge.pmd.lang.TokenManager;
import net.sourceforge.pmd.lang.ast.SimpleCharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.SimpleCharStream;
import net.sourceforge.pmd.lang.matlab.ast.MatlabParserTokenManager;
/**

View File

@ -48,7 +48,7 @@ options {
PARSER_BEGIN(ModelicaParser)
package net.sourceforge.pmd.lang.modelica.ast;
import net.sourceforge.pmd.lang.ast.CharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
import net.sourceforge.pmd.lang.ast.TokenMgrError;
public class ModelicaParser {

View File

@ -11,8 +11,8 @@ import net.sourceforge.pmd.lang.ParserOptions;
import net.sourceforge.pmd.lang.TokenManager;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.ast.ParseException;
import net.sourceforge.pmd.lang.ast.SimpleCharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.AbstractTokenManager;
import net.sourceforge.pmd.lang.ast.impl.javacc.SimpleCharStream;
public class ModelicaParser extends AbstractParser {

View File

@ -7,8 +7,8 @@ package net.sourceforge.pmd.lang.modelica;
import java.io.Reader;
import net.sourceforge.pmd.lang.TokenManager;
import net.sourceforge.pmd.lang.ast.SimpleCharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.AbstractTokenManager;
import net.sourceforge.pmd.lang.ast.impl.javacc.SimpleCharStream;
import net.sourceforge.pmd.lang.modelica.ast.ModelicaParserTokenManager;

View File

@ -21,7 +21,7 @@ package net.sourceforge.pmd.lang.objectivec.ast;
import java.io.*;
import java.util.*;
import net.sourceforge.pmd.lang.ast.CharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
import net.sourceforge.pmd.lang.ast.TokenMgrError;
/**

View File

@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang.objectivec;
import java.io.Reader;
import net.sourceforge.pmd.lang.TokenManager;
import net.sourceforge.pmd.lang.ast.SimpleCharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.SimpleCharStream;
import net.sourceforge.pmd.lang.objectivec.ast.ObjectiveCParserTokenManager;
/**

View File

@ -155,7 +155,7 @@ package net.sourceforge.pmd.lang.plsql.ast;
import java.io.*;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.ast.SimpleCharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.SimpleCharStream;
import net.sourceforge.pmd.lang.ast.TokenMgrError;
public class PLSQLParser {

View File

@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang.plsql;
import java.io.Reader;
import net.sourceforge.pmd.lang.TokenManager;
import net.sourceforge.pmd.lang.ast.SimpleCharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.SimpleCharStream;
import net.sourceforge.pmd.lang.plsql.ast.PLSQLParserTokenManager;
/**

View File

@ -1,23 +1,23 @@
/**
* This Python 2.7 grammar was copied from the PyDev Project. (http://www.pydev.org/)
*
* Original source file:
* This Python 2.7 grammar was copied from the PyDev Project. (http://www.pydev.org/)
*
* Original source file:
* https://github.com/aptana/Pydev/blob/development/plugins/org.python.pydev.parser/src/org/python/pydev/parser/grammar27/python.jjt (commit 32950d534139f286e03d34795aec99edab09c04c)
*/
options {
BUILD_PARSER=false;
CACHE_TOKENS=true;
STATIC=false;
UNICODE_INPUT = true;
USER_CHAR_STREAM=true;
USER_CHAR_STREAM=true;
}
PARSER_BEGIN(PythonParser)
package net.sourceforge.pmd.lang.python.ast;
import net.sourceforge.pmd.lang.ast.CharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
import net.sourceforge.pmd.lang.ast.TokenMgrError;
public class PythonParser {

View File

@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang.python;
import java.io.Reader;
import net.sourceforge.pmd.lang.TokenManager;
import net.sourceforge.pmd.lang.ast.SimpleCharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.SimpleCharStream;
import net.sourceforge.pmd.lang.python.ast.PythonParserTokenManager;
/**

View File

@ -14,7 +14,7 @@ options {
PARSER_BEGIN(VfParser)
package net.sourceforge.pmd.lang.vf.ast;
import net.sourceforge.pmd.lang.ast.CharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
import net.sourceforge.pmd.lang.ast.TokenMgrError;
public class VfParser {

View File

@ -6,7 +6,7 @@ package net.sourceforge.pmd.lang.vf;
import java.io.Reader;
import net.sourceforge.pmd.lang.ast.SimpleCharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.SimpleCharStream;
/**
* @author sergey.gorbaty

View File

@ -93,7 +93,7 @@ import java.util.List;
import java.util.HashMap;
import java.util.Map;
import net.sourceforge.pmd.lang.ast.CharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
import net.sourceforge.pmd.lang.vm.directive.Directive;
import net.sourceforge.pmd.lang.vm.util.VelocityCharStream;
import net.sourceforge.pmd.lang.vm.util.DirectiveMapper;

View File

@ -1,7 +1,7 @@
package net.sourceforge.pmd.lang.vm.util;
import net.sourceforge.pmd.lang.ast.CharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
/*
* Licensed to the Apache Software Foundation (ASF) under one