forked from phoedos/pmd
Merge branch 'pr-2359' into pmd/7.0.x
[matlab] Use new javacc wrapper script in Matlab module
This commit is contained in:
@ -18,17 +18,17 @@ options {
|
||||
UNICODE_INPUT = true;
|
||||
}
|
||||
|
||||
PARSER_BEGIN(MatlabParser)
|
||||
PARSER_BEGIN(MatlabParserImpl)
|
||||
package net.sourceforge.pmd.lang.matlab.ast;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.CharStream;
|
||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
||||
|
||||
public class MatlabParser {
|
||||
public class MatlabParserImpl {
|
||||
|
||||
}
|
||||
|
||||
PARSER_END(MatlabParser)
|
||||
PARSER_END(MatlabParserImpl)
|
||||
|
||||
<DEFAULT, TRANSPOSE> SKIP :
|
||||
{
|
||||
@ -159,4 +159,4 @@ PARSER_END(MatlabParser)
|
||||
<DEFAULT, TRANSPOSE> TOKEN :
|
||||
{
|
||||
< TR : "'" > : TRANSPOSE
|
||||
}
|
||||
}
|
@ -32,8 +32,10 @@
|
||||
<phase>generate-sources</phase>
|
||||
<configuration>
|
||||
<target>
|
||||
<ant antfile="src/main/ant/alljavacc.xml">
|
||||
<property name="target" value="${project.build.directory}/generated-sources/javacc" />
|
||||
<ant antfile="${javacc.ant.wrapper}" target="alljavacc">
|
||||
<property name="no-jjtree" value="true"/> <!-- This is a CPD module -->
|
||||
<property name="lang-name" value="Matlab" />
|
||||
<property name="lang-terse-name" value="matlab" />
|
||||
<property name="javacc.jar" value="${javacc.jar}" />
|
||||
</ant>
|
||||
</target>
|
||||
|
@ -1,112 +0,0 @@
|
||||
<project name="pmd" default="alljavacc" basedir="../../">
|
||||
|
||||
<property name="javacc-home.path" value="target/lib" />
|
||||
|
||||
<target name="alljavacc"
|
||||
description="Generates all JavaCC aspects within PMD"
|
||||
depends="checkUpToDate,init,matlabjavacc,cleanup" />
|
||||
|
||||
<target name="checkUpToDate">
|
||||
<uptodate property="javaccBuildNotRequired" targetfile="${target}/last-generated-timestamp">
|
||||
<srcfiles dir="etc/grammar" includes="*.jj*"/>
|
||||
</uptodate>
|
||||
<echo message="up to date check: javaccBuildNotRequired=${javaccBuildNotRequired}"/>
|
||||
</target>
|
||||
|
||||
<target name="init" unless="javaccBuildNotRequired">
|
||||
<mkdir dir="${javacc-home.path}" />
|
||||
<copy file="${javacc.jar}" tofile="${javacc-home.path}/javacc.jar" />
|
||||
|
||||
<mkdir dir="${target}"/>
|
||||
<touch file="${target}/last-generated-timestamp"/>
|
||||
</target>
|
||||
|
||||
<target name="cleanup">
|
||||
<delete dir="${javacc-home.path}" />
|
||||
</target>
|
||||
|
||||
<target name="matlabjavacc" description="Generates the Matlab grammar" unless="javaccBuildNotRequired">
|
||||
<delete dir="${target}/net/sourceforge/pmd/lang/matlab/ast" />
|
||||
<mkdir dir="${target}/net/sourceforge/pmd/lang/matlab/ast" />
|
||||
<!-- Ensure generated using CharStream interface -->
|
||||
<javacc static="false"
|
||||
usercharstream="true"
|
||||
target="etc/grammar/matlab.jj"
|
||||
outputdirectory="${target}/net/sourceforge/pmd/lang/matlab/ast"
|
||||
javacchome="${javacc-home.path}" />
|
||||
<replace file="${target}/net/sourceforge/pmd/lang/matlab/ast/MatlabParserTokenManager.java"
|
||||
token="class MatlabParserTokenManager"
|
||||
value="class MatlabParserTokenManager extends net.sourceforge.pmd.lang.ast.AbstractTokenManager" />
|
||||
<delete file="${target}/net/sourceforge/pmd/lang/matlab/ast/CharStream.java" />
|
||||
<delete file="${target}/net/sourceforge/pmd/lang/matlab/ast/ParseException.java" />
|
||||
<delete file="${target}/net/sourceforge/pmd/lang/matlab/ast/TokenMgrError.java" />
|
||||
|
||||
<replace file="${target}/net/sourceforge/pmd/lang/matlab/ast/Token.java">
|
||||
<replacetoken>public class Token implements java.io.Serializable</replacetoken>
|
||||
<replacevalue><![CDATA[import net.sourceforge.pmd.lang.ast.GenericToken;
|
||||
|
||||
public class Token implements GenericToken, java.io.Serializable]]></replacevalue>
|
||||
</replace>
|
||||
|
||||
<!--Add implementation methods of GenericToken-->
|
||||
<replace file="${target}/net/sourceforge/pmd/lang/matlab/ast/Token.java">
|
||||
<replacetoken>public Token specialToken;</replacetoken>
|
||||
<replacevalue><![CDATA[public Token specialToken;
|
||||
|
||||
@Override
|
||||
public GenericToken getNext() {
|
||||
return next;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenericToken getPreviousComment() {
|
||||
return specialToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBeginLine() {
|
||||
return beginLine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEndLine() {
|
||||
return endLine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBeginColumn() {
|
||||
return beginColumn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEndColumn() {
|
||||
return endColumn;
|
||||
}
|
||||
|
||||
]]></replacevalue>
|
||||
</replace>
|
||||
|
||||
|
||||
|
||||
<replaceregexp>
|
||||
<regexp pattern="class|interface" />
|
||||
<substitution expression="@Deprecated @net.sourceforge.pmd.annotation.InternalApi \0" />
|
||||
<fileset dir="${target}/net/sourceforge/pmd/lang/matlab/ast">
|
||||
<exclude name="AST*.java" />
|
||||
</fileset>
|
||||
</replaceregexp>
|
||||
|
||||
<replaceregexp>
|
||||
<regexp pattern="public class ParseException " />
|
||||
<substitution expression=" /** @deprecated Use superclass {@link net.sourceforge.pmd.lang.ast.ParseException} */
|
||||
@Deprecated @net.sourceforge.pmd.annotation.InternalApi \0" />
|
||||
<fileset file="${target}/net/sourceforge/pmd/lang/matlab/ast/ParseException.java"/>
|
||||
</replaceregexp>
|
||||
</target>
|
||||
|
||||
</project>
|
@ -8,7 +8,7 @@ import java.io.StringReader;
|
||||
|
||||
import net.sourceforge.pmd.cpd.internal.JavaCCTokenizer;
|
||||
import net.sourceforge.pmd.lang.TokenManager;
|
||||
import net.sourceforge.pmd.lang.matlab.MatlabTokenManager;
|
||||
import net.sourceforge.pmd.lang.matlab.ast.MatlabTokenManager;
|
||||
import net.sourceforge.pmd.util.IOUtil;
|
||||
|
||||
/**
|
||||
|
@ -1,34 +1,24 @@
|
||||
/**
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.matlab;
|
||||
package net.sourceforge.pmd.lang.matlab.ast;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
import net.sourceforge.pmd.annotation.InternalApi;
|
||||
import net.sourceforge.pmd.lang.TokenManager;
|
||||
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStreamFactory;
|
||||
import net.sourceforge.pmd.lang.matlab.ast.MatlabParserTokenManager;
|
||||
|
||||
/**
|
||||
* Matlab Token Manager implementation.
|
||||
*
|
||||
* @deprecated This is internal API
|
||||
*/
|
||||
@Deprecated
|
||||
@InternalApi
|
||||
public class MatlabTokenManager implements TokenManager {
|
||||
private final MatlabParserTokenManager tokenManager;
|
||||
private final MatlabParserImplTokenManager tokenManager;
|
||||
|
||||
/**
|
||||
* Creates a new Matlab Token Manager from the given source code.
|
||||
*
|
||||
* @param source
|
||||
* the source code
|
||||
*/
|
||||
public MatlabTokenManager(Reader source) {
|
||||
tokenManager = new MatlabParserTokenManager(CharStreamFactory.simpleCharStream(source));
|
||||
tokenManager = new MatlabParserImplTokenManager(CharStreamFactory.simpleCharStream(source));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -38,6 +28,6 @@ public class MatlabTokenManager implements TokenManager {
|
||||
|
||||
@Override
|
||||
public void setFileName(String fileName) {
|
||||
MatlabParserTokenManager.setFileName(fileName);
|
||||
MatlabParserImplTokenManager.setFileName(fileName);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user