javacc-maven-plugin-2.6/0000755000175000017500000000000011411772450015032 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/0000755000175000017500000000000011411772441015621 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/main/0000755000175000017500000000000011411772440016544 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/main/java/0000755000175000017500000000000011411772436017472 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/main/java/org/0000755000175000017500000000000011411772436020261 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/main/java/org/codehaus/0000755000175000017500000000000011411772436022054 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/main/java/org/codehaus/mojo/0000755000175000017500000000000011411772436023020 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/main/java/org/codehaus/mojo/javacc/0000755000175000017500000000000011411772440024242 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/main/java/org/codehaus/mojo/javacc/JJTreeJavaCCMojo.java0000644000175000017500000003102111250747644030073 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; /** * Preprocesses decorated grammar files (*.jjt) with JJTree and passes the output to JavaCC in order to * finally generate a parser with parse tree actions. * * @goal jjtree-javacc * @phase generate-sources * @since 2.4 * @author Benjamin Bentmann * @version $Id: JJTreeJavaCCMojo.java 10603 2009-09-06 15:05:08Z bentmann $ */ public class JJTreeJavaCCMojo extends AbstractJavaCCMojo { /** * A flag whether to generate sample implementations for SimpleNode and any other nodes used in the * grammar. Default value is true. * * @parameter expression="${buildNodeFiles}" */ private Boolean buildNodeFiles; /** * A flag whether to generate a multi mode parse tree or a single mode parse tree. Default value is * false. * * @parameter expression="${multi}" */ private Boolean multi; /** * A flag whether to make each non-decorated production void instead of an indefinite node. Default value is * false. * * @parameter expression="${nodeDefaultVoid}" */ private Boolean nodeDefaultVoid; /** * The name of a custom class that extends SimpleNode and will be used as the super class for the * generated tree node classes. By default, the tree node classes will directly extend the class * SimpleNode. * * @parameter expression="${nodeClass}" * @since 2.5 */ private String nodeClass; /** * The name of a custom factory class used to create Node objects. This class must have a method with * the signature public static Node jjtCreate(int id). By default, the class SimpleNode * will be used as the factory class. * * @parameter expression="${nodeFactory}" */ private String nodeFactory; /** * The package to generate the AST node classes into. This value may use a leading asterisk to reference the package * of the corresponding parser. For example, if the parser package is org.apache and this parameter * is set to *.node, the tree node classes will be located in the package * org.apache.node. By default, the package of the corresponding parser is used. * * @parameter expression="${nodePackage}" */ private String nodePackage; /** * The prefix used to construct node class names from node identifiers in multi mode. Default value is * AST. * * @parameter expression="${nodePrefix}" */ private String nodePrefix; /** * A flag whether user-defined parser methods should be called on entry and exit of every node scope. Default value * is false. * * @parameter expression="${nodeScopeHook}" */ private Boolean nodeScopeHook; /** * A flag whether the node construction routines need an additional method parameter to receive the parser object. * Default value is false. * * @parameter expression="${nodeUsesParser}" */ private Boolean nodeUsesParser; /** * A flag whether to insert the methods jjtGetFirstToken(), jjtSetFirstToken(), * getLastToken() and jjtSetLastToken() into the class SimpleNode. Default * value is false. * * @parameter expression="${trackTokens}" * @since 2.5 */ private Boolean trackTokens; /** * A flag whether to insert a jjtAccept() method in the node classes and to generate a visitor * implementation with an entry for every node type used in the grammar. Default value is false. * * @parameter expression="${visitor}" */ private Boolean visitor; /** * The name of a class to use for the data argument of the jjtAccept() and visit() * methods. Default value is java.lang.Object. * * @parameter expression="${visitorDataType}" * @since 2.5 */ private String visitorDataType; /** * The name of a class to use as the return type of the jjtAccept() and visit() methods. * Default value is java.lang.Object. * * @parameter expression="${visitorReturnType}" * @since 2.5 */ private String visitorReturnType; /** * The name of an exception class to include in the signature of the generated jjtAccept() and * visit() methods. By default, the throws clause of the generated methods is empty such * that only unchecked exceptions can be thrown. * * @parameter expression="${visitorException}" */ private String visitorException; /** * The directory where the decorated JavaCC grammar files (*.jjt) are located. It will be * recursively scanned for input files to pass to JJTree. The parameters includes and * excludes can be used to select a subset of files. * * @parameter expression="${sourceDirectory}" default-value="${basedir}/src/main/jjtree" */ private File sourceDirectory; /** * The directory where the AST node files generated by JJTree will be stored. The directory will be registered as a * compile source root of the project such that the generated files will participate in later build phases like * compiling and packaging. * * @parameter expression="${interimDirectory}" default-value="${project.build.directory}/generated-sources/jjtree" */ private File interimDirectory; /** * The directory where the parser files generated by JavaCC will be stored. The directory will be registered as a * compile source root of the project such that the generated files will participate in later build phases like * compiling and packaging. * * @parameter expression="${outputDirectory}" default-value="${project.build.directory}/generated-sources/javacc" */ private File outputDirectory; /** * A set of Ant-like inclusion patterns used to select files from the source directory for processing. By default, * the patterns **/*.jj, **/*.JJ, **/*.jjt and * **/*.JJT are used to select grammar files. * * @parameter */ private String[] includes; /** * A set of Ant-like exclusion patterns used to prevent certain files from being processed. By default, this set is * empty such that no files are excluded. * * @parameter */ private String[] excludes; /** * The granularity in milliseconds of the last modification date for testing whether a grammar file needs * recompilation. * * @parameter expression="${lastModGranularityMs}" default-value="0" */ private int staleMillis; /** * {@inheritDoc} */ protected File getSourceDirectory() { return this.sourceDirectory; } /** * {@inheritDoc} */ protected String[] getIncludes() { if ( this.includes != null ) { return this.includes; } else { return new String[] { "**/*.jj", "**/*.JJ", "**/*.jjt", "**/*.JJT" }; } } /** * {@inheritDoc} */ protected String[] getExcludes() { return this.excludes; } /** * {@inheritDoc} */ protected File getOutputDirectory() { return this.outputDirectory; } /** * {@inheritDoc} */ protected int getStaleMillis() { return this.staleMillis; } /** * Gets the absolute path to the directory where the interim output from JJTree will be stored. * * @return The absolute path to the directory where the interim output from JJTree will be stored. */ private File getInterimDirectory() { return this.interimDirectory; } /** * {@inheritDoc} */ protected File[] getCompileSourceRoots() { return new File[] { getOutputDirectory(), getInterimDirectory() }; } /** * {@inheritDoc} */ protected void processGrammar( GrammarInfo grammarInfo ) throws MojoExecutionException, MojoFailureException { File jjtFile = grammarInfo.getGrammarFile(); File jjtDirectory = jjtFile.getParentFile(); File tempDirectory = getTempDirectory(); // setup output directory of grammar file (*.jj) and node files (*.java) generated by JJTree File jjDirectory = new File( tempDirectory, "node" ); // setup output directory of parser file (*.java) generated by JavaCC File parserDirectory = new File( tempDirectory, "parser" ); // setup output directory of tree node files (*.java) generated by JJTree String nodePackageName = grammarInfo.resolvePackageName( this.nodePackage ); // generate final grammar file JJTree jjtree = newJJTree(); jjtree.setInputFile( jjtFile ); jjtree.setOutputDirectory( jjDirectory ); jjtree.setNodePackage( nodePackageName ); jjtree.run(); // generate parser files JavaCC javacc = newJavaCC(); javacc.setInputFile( jjtree.getOutputFile() ); javacc.setOutputDirectory( parserDirectory ); javacc.run(); // copy output from JJTree copyGrammarOutput( getInterimDirectory(), ( nodePackageName != null ) ? nodePackageName : grammarInfo.getParserPackage(), jjDirectory, grammarInfo.getParserName() + "TreeConstants*" ); // copy parser files from JavaCC copyGrammarOutput( getOutputDirectory(), grammarInfo.getParserPackage(), parserDirectory, grammarInfo.getParserName() + "*" ); // copy source files which are next to grammar unless the grammar resides in an ordinary source root // (legacy support for custom sources) if ( !isSourceRoot( grammarInfo.getSourceDirectory() ) ) { copyGrammarOutput( getOutputDirectory(), grammarInfo.getParserPackage(), jjtDirectory, "*" ); } deleteTempDirectory( tempDirectory ); } /** * Creates a new facade to invoke JJTree. Most options for the invocation are derived from the current values of the * corresponding mojo parameters. The caller is responsible to set the input file, output directory and package on * the returned facade. * * @return The facade for the tool invocation, never null. */ protected JJTree newJJTree() { JJTree jjtree = new JJTree(); jjtree.setLog( getLog() ); jjtree.setGrammarEncoding( getGrammarEncoding() ); jjtree.setJdkVersion( getJdkVersion() ); jjtree.setStatic( getIsStatic() ); jjtree.setBuildNodeFiles( this.buildNodeFiles ); jjtree.setMulti( this.multi ); jjtree.setNodeDefaultVoid( this.nodeDefaultVoid ); jjtree.setNodeClass( this.nodeClass ); jjtree.setNodeFactory( this.nodeFactory ); jjtree.setNodePrefix( this.nodePrefix ); jjtree.setNodeScopeHook( this.nodeScopeHook ); jjtree.setNodeUsesParser( this.nodeUsesParser ); jjtree.setTrackTokens( this.trackTokens ); jjtree.setVisitor( this.visitor ); jjtree.setVisitorDataType( this.visitorDataType ); jjtree.setVisitorReturnType( this.visitorReturnType ); jjtree.setVisitorException( this.visitorException ); return jjtree; } } javacc-maven-plugin-2.6/src/main/java/org/codehaus/mojo/javacc/AbstractJavaCCMojo.java0000644000175000017500000006552311257376700030527 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.io.IOException; import java.util.Arrays; import java.util.Collection; import java.util.Iterator; import java.util.LinkedHashSet; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.SelectorUtils; import org.codehaus.plexus.util.StringUtils; /** * Provides common services for all mojos that compile JavaCC grammar files. * * @author jruiz@exist.com * @author jesse * @version $Id: AbstractJavaCCMojo.java 10774 2009-09-26 11:40:48Z bentmann $ */ public abstract class AbstractJavaCCMojo extends AbstractMojo { /** * The current Maven project. * * @parameter default-value="${project}" * @readonly * @required */ private MavenProject project; /** * The set of compile source roots whose contents are not generated as part of the build, i.e. those that usually * reside somewhere below "${basedir}/src" in the project structure. Files in these source roots are owned by the * user and must not be overwritten with generated files. */ private Collection nonGeneratedSourceRoots; /** * The Java version for which to generate source code. Default value is 1.5 for plugin version 2.6+ and * 1.4 in older versions. * * @parameter expression="${jdkVersion}" * @since 2.4 */ private String jdkVersion; /** * The number of tokens to look ahead before making a decision at a choice point during parsing. The default value * is 1. * * @parameter expression="${lookAhead}" */ private Integer lookAhead; /** * This is the number of tokens considered in checking choices of the form "A | B | ..." for ambiguity. Default * value is 2. * * @parameter expression="${choiceAmbiguityCheck}" */ private Integer choiceAmbiguityCheck; /** * This is the number of tokens considered in checking all other kinds of choices (i.e., of the forms "(A)*", * "(A)+", and "(A)?") for ambiguity. Default value is 1. * * @parameter expression="${otherAmbiguityCheck}" */ private Integer otherAmbiguityCheck; /** * If true, all methods and class variables are specified as static in the generated parser and * token manager. This allows only one parser object to be present, but it improves the performance of the parser. * Default value is true. * * @parameter expression="${isStatic}" */ private Boolean isStatic; /** * This option is used to obtain debugging information from the generated parser. Setting this option to * true causes the parser to generate a trace of its actions. Default value is false. * * @parameter expression="${debugParser}" */ private Boolean debugParser; /** * This is a boolean option whose default value is false. Setting this option to true * causes the parser to generate all the tracing information it does when the option debugParser is * true, and in addition, also causes it to generated a trace of actions performed during lookahead * operation. * * @parameter expression="${debugLookAhead}" */ private Boolean debugLookAhead; /** * This option is used to obtain debugging information from the generated token manager. Default value is * false. * * @parameter expression="${debugTokenManager}" */ private Boolean debugTokenManager; /** * Setting it to false causes errors due to parse errors to be reported in somewhat less detail. * Default value is true. * * @parameter expression="${errorReporting}" */ private Boolean errorReporting; /** * When set to true, the generated parser uses an input stream object that processes Java Unicode * escapes (\uxxxx) before sending characters to the token manager. Default * value is false. * * @parameter expression="${javaUnicodeEscape}" */ private Boolean javaUnicodeEscape; /** * When set to true, the generated parser uses uses an input stream object that reads Unicode files. * By default, ASCII files are assumed. Default value is false. * * @parameter expression="${unicodeInput}" */ private Boolean unicodeInput; /** * Setting this option to true causes the generated token manager to ignore case in the token * specifications and the input files. Default value is false. * * @parameter expression="${ignoreCase}" */ private Boolean ignoreCase; /** * When set to true, every call to the token manager's method getNextToken() (see the * description of the Java Compiler Compiler API) * will cause a call to a user-defined method CommonTokenAction() after the token has been scanned in * by the token manager. Default value is false. * * @parameter expression="${commonTokenAction}" */ private Boolean commonTokenAction; /** * The default action is to generate a token manager that works on the specified grammar tokens. If this option is * set to true, then the parser is generated to accept tokens from any token manager of type * TokenManager - this interface is generated into the generated parser directory. Default value is * false. * * @parameter expression="${userTokenManager}" */ private Boolean userTokenManager; /** * This flag controls whether the token manager will read characters from a character stream reader as defined by * the options javaUnicodeEscape and unicodeInput or whether the token manager reads * from a user-supplied implementation of CharStream. Default value is false. * * @parameter expression="${userCharStream}" */ private Boolean userCharStream; /** * A flag that controls whether the parser file (*Parser.java) should be generated or not. If set * to false, only the token manager is generated. Default value is true. * * @parameter expression="${buildParser}" */ private Boolean buildParser; /** * A flag that controls whether the token manager file (*TokenManager.java) should be generated or * not. Setting this to false can speed up the generation process if only the parser part of the * grammar changed. Default value is true. * * @parameter expression="${buildTokenManager}" */ private Boolean buildTokenManager; /** * When set to true, the generated token manager will include a field called parser * that references the instantiating parser instance. Default value is false. * * @parameter expression="${tokenManagerUsesParser}" */ private Boolean tokenManagerUsesParser; /** * The name of the base class for the generated Token class. Default value is * java.lang.Object. * * @parameter expression="${tokenExtends}" * @since 2.5 */ private String tokenExtends; /** * The name of a custom factory class used to create Token objects. This class must have a method with * the signature public static Token newToken(int ofKind, String image). By default, tokens are created * by calling Token.newToken(). * * @parameter expression="${tokenFactory}" * @since 2.5 */ private String tokenFactory; /** * Enables/disables many syntactic and semantic checks on the grammar file during parser generation. Default value * is true. * * @parameter expression="${sanityCheck}" */ private Boolean sanityCheck; /** * This option setting controls lookahead ambiguity checking performed by JavaCC. Default value is * false. * * @parameter expression="${forceLaCheck}" */ private Boolean forceLaCheck; /** * Setting this option to true causes the generated parser to lookahead for extra tokens ahead of * time. Default value is false. * * @parameter expression="${cacheTokens}" */ private Boolean cacheTokens; /** * A flag whether to keep line and column information along with a token. Default value is true. * * @parameter expression="${keepLineColumn}" */ private Boolean keepLineColumn; /** * A flag whether the generated support classes of the parser should have public or package-private visibility. * Default value is true. * * @parameter expression="${supportClassVisibilityPublic}" * @since 2.6 */ private Boolean supportClassVisibilityPublic; /** * The file encoding to use for reading the grammar files. * * @parameter expression="${grammarEncoding}" default-value="${project.build.sourceEncoding}" * @since 2.6 */ private String grammarEncoding; /** * Gets the file encoding of the grammar files. * * @return The file encoding of the grammar files or null if the user did not specify this mojo * parameter. */ protected String getGrammarEncoding() { return this.grammarEncoding; } /** * Gets the Java version for which to generate source code. * * @return The Java version for which to generate source code, will be null if the user did not specify * this mojo parameter. */ protected String getJdkVersion() { return this.jdkVersion; } /** * Gets the flag whether to generate static parser. * * @return The flag whether to generate static parser, will be null if the user did not specify this * mojo parameter. */ protected Boolean getIsStatic() { return this.isStatic; } /** * Gets the absolute path to the directory where the grammar files are located. * * @return The absolute path to the directory where the grammar files are located, never null. */ protected abstract File getSourceDirectory(); /** * Gets a set of Ant-like inclusion patterns used to select files from the source directory for processing. * * @return A set of Ant-like inclusion patterns used to select files from the source directory for processing, can * be null if all files should be included. */ protected abstract String[] getIncludes(); /** * Gets a set of Ant-like exclusion patterns used to unselect files from the source directory for processing. * * @return A set of Ant-like inclusion patterns used to unselect files from the source directory for processing, can * be null if no files should be excluded. */ protected abstract String[] getExcludes(); /** * Gets the absolute path to the directory where the generated Java files for the parser will be stored. * * @return The absolute path to the directory where the generated Java files for the parser will be stored, never * null. */ protected abstract File getOutputDirectory(); /** * Gets the granularity in milliseconds of the last modification date for testing whether a source needs * recompilation. * * @return The granularity in milliseconds of the last modification date for testing whether a source needs * recompilation. */ protected abstract int getStaleMillis(); /** * Gets all the output directories to register with the project for compilation. * * @return The compile source roots to register with the project, never null. */ protected abstract File[] getCompileSourceRoots(); /** * Gets the package into which the generated parser files should be stored. * * @return The package into which the generated parser files should be stored, can be null to use the * package declaration from the grammar file. */ // TODO: Once the parameter "packageName" from the javacc mojo has been deleted, remove this method, too. protected String getParserPackage() { return null; } /** * Execute the tool. * * @throws MojoExecutionException If the invocation of the tool failed. * @throws MojoFailureException If the tool reported a non-zero exit code. */ public void execute() throws MojoExecutionException, MojoFailureException { GrammarInfo[] grammarInfos = scanForGrammars(); if ( grammarInfos == null ) { getLog().info( "Skipping non-existing source directory: " + getSourceDirectory() ); return; } else if ( grammarInfos.length <= 0 ) { getLog().info( "Skipping - all parsers are up to date" ); } else { determineNonGeneratedSourceRoots(); if ( StringUtils.isEmpty( grammarEncoding ) ) { getLog().warn( "File encoding for grammars has not been configured" + ", using platform default encoding, i.e. build is platform dependent!" ); } for ( int i = 0; i < grammarInfos.length; i++ ) { processGrammar( grammarInfos[i] ); } getLog().info( "Processed " + grammarInfos.length + " grammar" + ( grammarInfos.length != 1 ? "s" : "" ) ); } Collection compileSourceRoots = new LinkedHashSet( Arrays.asList( getCompileSourceRoots() ) ); for ( Iterator it = compileSourceRoots.iterator(); it.hasNext(); ) { addSourceRoot( (File) it.next() ); } } /** * Passes the specified grammar file through the tool. * * @param grammarInfo The grammar info describing the grammar file to process, must not be null. * @throws MojoExecutionException If the invocation of the tool failed. * @throws MojoFailureException If the tool reported a non-zero exit code. */ protected abstract void processGrammar( GrammarInfo grammarInfo ) throws MojoExecutionException, MojoFailureException; /** * Scans the configured source directory for grammar files which need processing. * * @return An array of grammar infos describing the found grammar files or null if the source * directory does not exist. * @throws MojoExecutionException If the source directory could not be scanned. */ private GrammarInfo[] scanForGrammars() throws MojoExecutionException { if ( !getSourceDirectory().isDirectory() ) { return null; } GrammarInfo[] grammarInfos; getLog().debug( "Scanning for grammars: " + getSourceDirectory() ); try { GrammarDirectoryScanner scanner = new GrammarDirectoryScanner(); scanner.setSourceDirectory( getSourceDirectory() ); scanner.setIncludes( getIncludes() ); scanner.setExcludes( getExcludes() ); scanner.setOutputDirectory( getOutputDirectory() ); scanner.setParserPackage( getParserPackage() ); scanner.setStaleMillis( getStaleMillis() ); scanner.scan(); grammarInfos = scanner.getIncludedGrammars(); } catch ( Exception e ) { throw new MojoExecutionException( "Failed to scan for grammars: " + getSourceDirectory(), e ); } getLog().debug( "Found grammars: " + Arrays.asList( grammarInfos ) ); return grammarInfos; } /** * Gets a temporary directory within the project's build directory. * * @return The path to the temporary directory, never null. */ protected File getTempDirectory() { return new File( this.project.getBuild().getDirectory(), "javacc-" + System.currentTimeMillis() ); } /** * Deletes the specified temporary directory. * * @param tempDirectory The directory to delete, must not be null. */ protected void deleteTempDirectory( File tempDirectory ) { try { FileUtils.deleteDirectory( tempDirectory ); } catch ( IOException e ) { getLog().warn( "Failed to delete temporary directory: " + tempDirectory, e ); } } /** * Scans the filesystem for output files and copies them to the specified compile source root. An output file is * only copied to the compile source root if it doesn't already exist in another compile source root. This prevents * duplicate class errors during compilation in case the user provided customized files in * src/main/java or similar. * * @param packageName The name of the destination package for the output files, must not be null. * @param sourceRoot The (absolute) path to the compile source root into which the output files should eventually be * copied, must not be null. * @param tempDirectory The (absolute) path to the directory to scan for generated output files, must not be * null. * @param updatePattern A glob pattern that matches the (simple) names of those files which should always be updated * in case we are outputting directly into src/main/java, may be null. A * leading "!" may be used to negate the pattern. * @throws MojoExecutionException If the output files could not be copied. */ protected void copyGrammarOutput( File sourceRoot, String packageName, File tempDirectory, String updatePattern ) throws MojoExecutionException { try { Collection tempFiles = FileUtils.getFiles( tempDirectory, "*.java", null ); for ( Iterator it = tempFiles.iterator(); it.hasNext(); ) { File tempFile = (File) it.next(); String outputPath = ""; if ( packageName.length() > 0 ) { outputPath = packageName.replace( '.', '/' ) + '/'; } outputPath += tempFile.getName(); File outputFile = new File( sourceRoot, outputPath ); File sourceFile = findSourceFile( outputPath ); boolean alwaysUpdate = false; if ( updatePattern != null && sourceFile != null ) { if ( updatePattern.startsWith( "!" ) ) { alwaysUpdate = !SelectorUtils.match( updatePattern.substring( 1 ), tempFile.getName() ); } else { alwaysUpdate = SelectorUtils.match( updatePattern, tempFile.getName() ); } } if ( sourceFile == null || ( alwaysUpdate && sourceFile.equals( outputFile ) ) ) { getLog().debug( "Copying generated file: " + outputPath ); try { FileUtils.copyFile( tempFile, outputFile ); } catch ( IOException e ) { throw new MojoExecutionException( "Failed to copy generated source file to output directory:" + tempFile + " -> " + outputFile, e ); } } else { getLog().debug( "Skipping customized file: " + outputPath ); } } } catch ( IOException e ) { throw new MojoExecutionException( "Failed to copy generated source files", e ); } } /** * Determines those compile source roots of the project that do not reside below the project's build directories. * These compile source roots are assumed to contain hand-crafted sources that must not be overwritten with * generated files. In most cases, this is simply "${project.build.sourceDirectory}". * * @throws MojoExecutionException If the compile source rotos could not be determined. */ private void determineNonGeneratedSourceRoots() throws MojoExecutionException { this.nonGeneratedSourceRoots = new LinkedHashSet(); try { String targetPrefix = new File( this.project.getBuild().getDirectory() ).getCanonicalPath() + File.separator; Collection sourceRoots = this.project.getCompileSourceRoots(); for ( Iterator it = sourceRoots.iterator(); it.hasNext(); ) { File sourceRoot = new File( it.next().toString() ); if ( !sourceRoot.isAbsolute() ) { sourceRoot = new File( this.project.getBasedir(), sourceRoot.getPath() ); } String sourcePath = sourceRoot.getCanonicalPath(); if ( !sourcePath.startsWith( targetPrefix ) ) { this.nonGeneratedSourceRoots.add( sourceRoot ); getLog().debug( "Non-generated compile source root: " + sourceRoot ); } else { getLog().debug( "Generated compile source root: " + sourceRoot ); } } } catch ( IOException e ) { throw new MojoExecutionException( "Failed to determine non-generated source roots", e ); } } /** * Determines whether the specified source file is already present in any of the compile source roots registered * with the current Maven project. * * @param filename The source filename to check, relative to a source root, must not be null. * @return The (absolute) path to the existing source file if any, null otherwise. */ private File findSourceFile( String filename ) { Collection sourceRoots = this.nonGeneratedSourceRoots; for ( Iterator it = sourceRoots.iterator(); it.hasNext(); ) { File sourceRoot = (File) it.next(); File sourceFile = new File( sourceRoot, filename ); if ( sourceFile.exists() ) { return sourceFile; } } return null; } /** * Determines whether the specified directory denotes a compile source root of the current project. * * @param directory The directory to check, must not be null. * @return true if the specified directory is a compile source root of the project, false * otherwise. */ protected boolean isSourceRoot( File directory ) { return this.nonGeneratedSourceRoots.contains( directory ); } /** * Registers the specified directory as a compile source root for the current project. * * @param directory The absolute path to the source root, must not be null. */ private void addSourceRoot( File directory ) { if ( this.project != null ) { getLog().debug( "Adding compile source root: " + directory ); this.project.addCompileSourceRoot( directory.getAbsolutePath() ); } } /** * Creates a new facade to invoke JavaCC. Most options for the invocation are derived from the current values of the * corresponding mojo parameters. The caller is responsible to set the input file and output directory on the * returned facade. * * @return The facade for the tool invocation, never null. */ protected JavaCC newJavaCC() { JavaCC javacc = new JavaCC(); javacc.setLog( getLog() ); javacc.setGrammarEncoding( this.grammarEncoding ); javacc.setJdkVersion( this.jdkVersion ); javacc.setStatic( this.isStatic ); javacc.setBuildParser( this.buildParser ); javacc.setBuildTokenManager( this.buildTokenManager ); javacc.setCacheTokens( this.cacheTokens ); javacc.setChoiceAmbiguityCheck( this.choiceAmbiguityCheck ); javacc.setCommonTokenAction( this.commonTokenAction ); javacc.setDebugLookAhead( this.debugLookAhead ); javacc.setDebugParser( this.debugParser ); javacc.setDebugTokenManager( this.debugTokenManager ); javacc.setErrorReporting( this.errorReporting ); javacc.setForceLaCheck( this.forceLaCheck ); javacc.setIgnoreCase( this.ignoreCase ); javacc.setJavaUnicodeEscape( this.javaUnicodeEscape ); javacc.setKeepLineColumn( this.keepLineColumn ); javacc.setLookAhead( this.lookAhead ); javacc.setOtherAmbiguityCheck( this.otherAmbiguityCheck ); javacc.setSanityCheck( this.sanityCheck ); javacc.setTokenManagerUsesParser( this.tokenManagerUsesParser ); javacc.setTokenExtends( this.tokenExtends ); javacc.setTokenFactory( this.tokenFactory ); javacc.setUnicodeInput( this.unicodeInput ); javacc.setUserCharStream( this.userCharStream ); javacc.setUserTokenManager( this.userTokenManager ); javacc.setSupportClassVisibilityPublic( this.supportClassVisibilityPublic ); return javacc; } } javacc-maven-plugin-2.6/src/main/java/org/codehaus/mojo/javacc/AbstractPreprocessorMojo.java0000644000175000017500000001726310761360260032115 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.util.Arrays; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.FileUtils; /** * Provides common services for all mojos that preprocess JavaCC grammar files. * * @author Benjamin Bentmann * @version $Id: AbstractPreprocessorMojo.java 6353 2008-02-27 22:14:08Z bentmann $ */ public abstract class AbstractPreprocessorMojo extends AbstractMojo { /** * The current Maven project. * * @parameter default-value="${project}" * @readonly * @required */ private MavenProject project; /** * Gets the absolute path to the directory where the grammar files are located. * * @return The absolute path to the directory where the grammar files are located, never null. */ protected abstract File getSourceDirectory(); /** * Gets a set of Ant-like inclusion patterns used to select files from the source directory for processing. * * @return A set of Ant-like inclusion patterns used to select files from the source directory for processing, can * be null if all files should be included. */ protected abstract String[] getIncludes(); /** * Gets a set of Ant-like exclusion patterns used to unselect files from the source directory for processing. * * @return A set of Ant-like inclusion patterns used to unselect files from the source directory for processing, can * be null if no files should be excluded. */ protected abstract String[] getExcludes(); /** * Gets the absolute path to the directory where the generated Java files for the parser will be stored. * * @return The absolute path to the directory where the generated Java files for the parser will be stored, never * null. */ protected abstract File getOutputDirectory(); /** * Gets the absolute path to the directory where the processed input files will be stored for later detection of * stale sources. * * @return The absolute path to the directory where the processed input files will be stored for later detection of * stale sources, never null. */ protected abstract File getTimestampDirectory(); /** * Gets the granularity in milliseconds of the last modification date for testing whether a source needs * recompilation. * * @return The granularity in milliseconds of the last modification date for testing whether a source needs * recompilation. */ protected abstract int getStaleMillis(); /** * Execute the tool. * * @throws MojoExecutionException If the invocation of the tool failed. * @throws MojoFailureException If the tool reported a non-zero exit code. */ public void execute() throws MojoExecutionException, MojoFailureException { getLog().warn( "This goal has been deprecated. Please update your plugin configuration." ); GrammarInfo[] grammarInfos = scanForGrammars(); if ( grammarInfos == null ) { getLog().info( "Skipping non-existing source directory: " + getSourceDirectory() ); return; } else if ( grammarInfos.length <= 0 ) { getLog().info( "Skipping - all parsers are up to date" ); } else { if ( !getTimestampDirectory().exists() ) { getTimestampDirectory().mkdirs(); } for ( int i = 0; i < grammarInfos.length; i++ ) { processGrammar( grammarInfos[i] ); } getLog().info( "Processed " + grammarInfos.length + " grammar" + ( grammarInfos.length != 1 ? "s" : "" ) ); } addCompileSourceRoot(); } /** * Passes the specified grammar file through the tool. * * @param grammarInfo The grammar info describing the grammar file to process, must not be null. * @throws MojoExecutionException If the invocation of the tool failed. * @throws MojoFailureException If the tool reported a non-zero exit code. */ protected abstract void processGrammar( GrammarInfo grammarInfo ) throws MojoExecutionException, MojoFailureException; /** * Scans the configured source directory for grammar files which need processing. * * @return An array of grammar infos describing the found grammar files or null if the source * directory does not exist. * @throws MojoExecutionException If the source directory could not be scanned. */ private GrammarInfo[] scanForGrammars() throws MojoExecutionException { if ( !getSourceDirectory().isDirectory() ) { return null; } GrammarInfo[] grammarInfos; getLog().debug( "Scanning for grammars: " + getSourceDirectory() ); try { GrammarDirectoryScanner scanner = new LegacyGrammarDirectoryScanner(); scanner.setSourceDirectory( getSourceDirectory() ); scanner.setIncludes( getIncludes() ); scanner.setExcludes( getExcludes() ); scanner.setOutputDirectory( getTimestampDirectory() ); scanner.setStaleMillis( getStaleMillis() ); scanner.scan(); grammarInfos = scanner.getIncludedGrammars(); } catch ( Exception e ) { throw new MojoExecutionException( "Failed to scan for grammars: " + getSourceDirectory(), e ); } getLog().debug( "Found grammars: " + Arrays.asList( grammarInfos ) ); return grammarInfos; } /** * Creates the timestamp file for the specified grammar file. * * @param grammarInfo The grammar info describing the grammar file to process, must not be null. */ protected void createTimestamp( GrammarInfo grammarInfo ) { File jjFile = grammarInfo.getGrammarFile(); File timestampFile = new File( getTimestampDirectory(), grammarInfo.getRelativeGrammarFile() ); try { FileUtils.copyFile( jjFile, timestampFile ); } catch ( Exception e ) { getLog().warn( "Failed to create copy for timestamp check: " + jjFile, e ); } } /** * Registers the configured output directory as a compile source root for the current project. */ protected void addCompileSourceRoot() { if ( this.project != null ) { getLog().debug( "Adding compile source root: " + getOutputDirectory() ); this.project.addCompileSourceRoot( getOutputDirectory().getAbsolutePath() ); } } } javacc-maven-plugin-2.6/src/main/java/org/codehaus/mojo/javacc/JTBJavaCCMojo.java0000644000175000017500000003165711113311543027365 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; /** * Preprocesses ordinary grammar files (*.jtb) with JTB and passes the output to JavaCC in order to * finally generate a parser with parse tree actions.

Note: JTB requires Java 1.5 or higher. This goal will not work with earlier * versions of the JRE. * * @goal jtb-javacc * @phase generate-sources * @since 2.4 * @author Benjamin Bentmann * @version $Id: JTBJavaCCMojo.java 8156 2008-11-26 18:20:19Z bentmann $ */ public class JTBJavaCCMojo extends AbstractJavaCCMojo { /** * This option is short for nodePackageName = <packageName>.syntaxtree and * visitorPackageName = <packageName>.visitor. Note that this option takes * precedence over nodePackageName and visitorPackageName if specified. * * @parameter expression="${package}" */ private String packageName; /** * This option specifies the package for the generated AST nodes. This value may use a leading asterisk to reference * the package of the corresponding parser. For example, if the parser package is org.apache and this * parameter is set to *.demo, the tree node classes will be located in the package * org.apache.demo. Default value is *.syntaxtree. * * @parameter expression="${nodePackageName}" */ private String nodePackageName; /** * This option specifies the package for the generated visitors. This value may use a leading asterisk to reference * the package of the corresponding parser. For example, if the parser package is org.apache and this * parameter is set to *.demo, the visitor classes will be located in the package * org.apache.demo. Default value is *.visitor. * * @parameter expression="${visitorPackageName}" */ private String visitorPackageName; /** * If true, JTB will suppress its semantic error checking. Default value is false. * * @parameter expression="${supressErrorChecking}" */ private Boolean supressErrorChecking; /** * If true, all generated comments will be wrapped in <pre> tags so that they * are formatted correctly in API docs. Default value is false. * * @parameter expression="${javadocFriendlyComments}" */ private Boolean javadocFriendlyComments; /** * Setting this option to true causes JTB to generate field names that reflect the structure of the * tree instead of generic names like f0, f1 etc. Default value is false. * * @parameter expression="${descriptiveFieldNames}" */ private Boolean descriptiveFieldNames; /** * The qualified name of a user-defined class from which all AST nodes will inherit. By default, AST nodes will * inherit from the generated class Node. * * @parameter expression="${nodeParentClass}" */ private String nodeParentClass; /** * If true, all nodes will contain fields for its parent node. Default value is false. * * @parameter expression="${parentPointers}" */ private Boolean parentPointers; /** * If true, JTB will include JavaCC "special tokens" in the AST. Default value is false. * * @parameter expression="${specialTokens}" */ private Boolean specialTokens; /** * If true, JTB will generate the following files to support the Schema programming language: * * Default value is false. * * @parameter expression="${scheme}" */ private Boolean scheme; /** * If true, JTB will generate a syntax tree dumping visitor. Default value is false. * * @parameter expression="${printer}" */ private Boolean printer; /** * The directory where the JavaCC grammar files (*.jtb) are located. It will be recursively scanned * for input files to pass to JTB. The parameters includes and excludes can be used to * select a subset of files. * * @parameter expression="${sourceDirectory}" default-value="${basedir}/src/main/jtb" */ private File sourceDirectory; /** * The directory where the visitor and AST node files generated by JTB will be stored. The directory will be * registered as a compile source root of the project such that the generated files will participate in later build * phases like compiling and packaging. * * @parameter expression="${interimDirectory}" default-value="${project.build.directory}/generated-sources/jtb" */ private File interimDirectory; /** * The directory where the parser files generated by JavaCC will be stored. The directory will be registered as a * compile source root of the project such that the generated files will participate in later build phases like * compiling and packaging. * * @parameter expression="${outputDirectory}" default-value="${project.build.directory}/generated-sources/javacc" */ private File outputDirectory; /** * A set of Ant-like inclusion patterns used to select files from the source directory for processing. By default, * the patterns **/*.jj, **/*.JJ, **/*.jtb and * **/*.JTB are used to select grammar files. * * @parameter */ private String[] includes; /** * A set of Ant-like exclusion patterns used to prevent certain files from being processing. By default, this set is * empty such that no files are excluded. * * @parameter */ private String[] excludes; /** * The granularity in milliseconds of the last modification date for testing whether a grammar file needs * recompilation. * * @parameter expression="${lastModGranularityMs}" default-value="0" */ private int staleMillis; /** * {@inheritDoc} */ protected File getSourceDirectory() { return this.sourceDirectory; } /** * {@inheritDoc} */ protected String[] getIncludes() { if ( this.includes != null ) { return this.includes; } else { return new String[] { "**/*.jj", "**/*.JJ", "**/*.jtb", "**/*.JTB" }; } } /** * {@inheritDoc} */ protected String[] getExcludes() { return this.excludes; } /** * {@inheritDoc} */ protected File getOutputDirectory() { return this.outputDirectory; } /** * {@inheritDoc} */ protected int getStaleMillis() { return this.staleMillis; } /** * Gets the absolute path to the directory where the interim output from JTB will be stored. * * @return The absolute path to the directory where the interim output from JTB will be stored. */ private File getInterimDirectory() { return this.interimDirectory; } /** * {@inheritDoc} */ protected File[] getCompileSourceRoots() { return new File[] { getOutputDirectory(), getInterimDirectory() }; } /** * {@inheritDoc} */ protected void processGrammar( GrammarInfo grammarInfo ) throws MojoExecutionException, MojoFailureException { File jtbFile = grammarInfo.getGrammarFile(); File jtbDirectory = jtbFile.getParentFile(); File tempDirectory = getTempDirectory(); // setup output directory of grammar file (*.jj) generated by JTB File jjDirectory = tempDirectory; // setup output directory of tree node files (*.java) generated by JTB String nodePackage = grammarInfo.resolvePackageName( getNodePackageName() ); File nodeDirectory = new File( tempDirectory, "node" ); // setup output directory of visitor files (*.java) generated by JTB String visitorPackage = grammarInfo.resolvePackageName( getVisitorPackageName() ); File visitorDirectory = new File( tempDirectory, "visitor" ); // setup output directory of parser file (*.java) generated by JavaCC File parserDirectory = new File( tempDirectory, "parser" ); // generate final grammar file and the node/visitor files JTB jtb = newJTB(); jtb.setInputFile( jtbFile ); jtb.setOutputDirectory( jjDirectory ); jtb.setNodeDirectory( nodeDirectory ); jtb.setVisitorDirectory( visitorDirectory ); jtb.setNodePackageName( nodePackage ); jtb.setVisitorPackageName( visitorPackage ); jtb.run(); // generate parser files JavaCC javacc = newJavaCC(); javacc.setInputFile( jtb.getOutputFile() ); javacc.setOutputDirectory( parserDirectory ); javacc.run(); // copy tree node files from JTB copyGrammarOutput( getInterimDirectory(), nodePackage, nodeDirectory, "!Node*" ); // copy visitor files from JTB copyGrammarOutput( getInterimDirectory(), visitorPackage, visitorDirectory, "" ); // copy parser files from JavaCC copyGrammarOutput( getOutputDirectory(), grammarInfo.getParserPackage(), parserDirectory, grammarInfo.getParserName() + "*" ); // copy source files which are next to grammar unless the grammar resides in an ordinary source root // (legacy support for custom sources) if ( !isSourceRoot( grammarInfo.getSourceDirectory() ) ) { copyGrammarOutput( getOutputDirectory(), grammarInfo.getParserPackage(), jtbDirectory, "*" ); } deleteTempDirectory( tempDirectory ); } /** * Gets the effective package name for the AST node files. * * @return The effective package name for the AST node files, never null. */ private String getNodePackageName() { if ( this.packageName != null ) { return this.packageName + ".syntaxtree"; } else if ( this.nodePackageName != null ) { return this.nodePackageName; } else { return "*.syntaxtree"; } } /** * Gets the effective package name for the visitor files. * * @return The effective package name for the visitor files, never null. */ private String getVisitorPackageName() { if ( this.packageName != null ) { return this.packageName + ".visitor"; } else if ( this.visitorPackageName != null ) { return this.visitorPackageName; } else { return "*.visitor"; } } /** * Creates a new facade to invoke JTB. Most options for the invocation are derived from the current values of the * corresponding mojo parameters. The caller is responsible to set the input file, output directories and packages * on the returned facade. * * @return The facade for the tool invocation, never null. */ private JTB newJTB() { JTB jtb = new JTB(); jtb.setLog( getLog() ); jtb.setDescriptiveFieldNames( this.descriptiveFieldNames ); jtb.setJavadocFriendlyComments( this.javadocFriendlyComments ); jtb.setNodeParentClass( this.nodeParentClass ); jtb.setParentPointers( this.parentPointers ); jtb.setPrinter( this.printer ); jtb.setScheme( this.scheme ); jtb.setSpecialTokens( this.specialTokens ); jtb.setSupressErrorChecking( this.supressErrorChecking ); return jtb; } } javacc-maven-plugin-2.6/src/main/java/org/codehaus/mojo/javacc/JJDocMojo.java0000644000175000017500000004625711250747644026712 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.util.Arrays; import java.util.Comparator; import java.util.LinkedHashSet; import java.util.Locale; import java.util.ResourceBundle; import java.util.Set; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.doxia.siterenderer.Renderer; import org.apache.maven.project.MavenProject; import org.apache.maven.reporting.AbstractMavenReport; import org.apache.maven.reporting.MavenReportException; /** * JJDoc takes a JavaCC parser specification and produces * documentation for the BNF grammar. This mojo will search the source directory for all *.jj files and * run JJDoc once for each file it finds. Each of these output files, along with an index.html file will * be placed in the site directory (target/site/jjdoc), and a link will be created in the "Project * Reports" menu of the generated site. * * @goal jjdoc * @execute phase=generate-sources * @since 2.3 * @author Paul Gier * @version $Id: JJDocMojo.java 10603 2009-09-06 15:05:08Z bentmann $ * @see JJDoc Documentation */ public class JJDocMojo extends AbstractMavenReport { // ---------------------------------------------------------------------- // Mojo Parameters // ---------------------------------------------------------------------- /** * The current Maven project. * * @parameter expression="${project}" * @required * @readonly */ private MavenProject project; /** * The site renderer. * * @component */ private Renderer siteRenderer; /** * The directories where the JavaCC grammar files (*.jj) are located. By default, the directories * ${basedir}/src/main/javacc, ${project.build.directory}/generated-sources/jjtree * and ${project.build.directory}/generated-sources/jtb are scanned for grammar files to document. * * @parameter */ private File[] sourceDirectories; /** * The default source directory for hand-crafted grammar files. * * @parameter default-value="${basedir}/src/main/javacc" * @readonly */ private File defaultGrammarDirectoryJavaCC; /** * The default source directory for grammar files generated by JJTree. * * @parameter default-value="${project.build.directory}/generated-sources/jjtree" * @readonly */ private File defaultGrammarDirectoryJJTree; /** * The default source directory for grammar files generated by JTB. * * @parameter default-value="${project.build.directory}/generated-sources/jtb" * @readonly */ private File defaultGrammarDirectoryJTB; /** * The relative path of the JJDoc reports in the output directory. This path will be appended to the output * directory. * * @parameter default-value="jjdoc"; */ private String jjdocDirectory; /** * The destination directory where JJDoc saves the generated documentation files. Note that this parameter is only * relevant if the goal is run from the command line or from the default build lifecycle. If the goal is run * indirectly as part of a site generation, the output directory configured in the Maven Site Plugin is used * instead. * * @parameter expression="${outputDirectory}" default-value="${project.reporting.outputDirectory}" */ private File outputDirectory; /** * The file encoding to use for reading the grammar files. * * @parameter expression="${grammarEncoding}" default-value="${project.build.sourceEncoding}" * @since 2.6 */ private String grammarEncoding; /** * The hypertext reference to an optional CSS file for the generated HTML documents. If specified, this CSS file * will be included via a <link> element in the HTML documents. Otherwise, the default style will * be used. * * @parameter expression="${cssHref}" * @since 2.5 */ private String cssHref; /** * A flag to specify the output format for the generated documentation. If set to true, JJDoc will * generate a plain text description of the BNF. Some formatting is done via tab characters, but the intention is to * leave it as plain as possible. Specifying false causes JJDoc to generate a hyperlinked HTML document * unless the parameter {@link #bnf} has been set to true. Default value is false. * * @parameter expression="${text}" */ private Boolean text; /** * A flag whether to generate a plain text document with the unformatted BNF. Note that setting this option to * true is only effective if the parameter {@link #text} is false. Default value is * false. * * @parameter expression="${bnf}" * @since 2.6 */ private Boolean bnf; /** * This option controls the structure of the generated HTML output. If set to true, a single HTML * table for the entire BNF is generated. Setting it to false will produce one table for every * production in the grammar. * * @parameter expression="${oneTable}" default-value=true */ private boolean oneTable; /** * Get the maven project. * * @see org.apache.maven.reporting.AbstractMavenReport#getProject() * @return The current Maven project. */ protected MavenProject getProject() { return this.project; } /** * Get the site renderer. * * @see org.apache.maven.reporting.AbstractMavenReport#getSiteRenderer() * @return The site renderer. */ protected Renderer getSiteRenderer() { return this.siteRenderer; } /** * Get the output directory of the report if run directly from the command line. * * @see org.apache.maven.reporting.AbstractMavenReport#getOutputDirectory() * @return The report output directory. */ protected String getOutputDirectory() { return this.outputDirectory.getAbsolutePath(); } /** * Get the output directory of the JJDoc files, i.e. the sub directory in the report output directory as specified * by the {@link #jjdocDirectory} parameter. * * @return The report output directory of the JJDoc files. */ private File getJJDocOutputDirectory() { return new File( getReportOutputDirectory(), this.jjdocDirectory ); } /** * Get the source directories that should be scanned for grammar files. * * @return The source directories that should be scanned for grammar files, never null. */ private File[] getSourceDirectories() { Set directories = new LinkedHashSet(); if ( this.sourceDirectories != null && this.sourceDirectories.length > 0 ) { directories.addAll( Arrays.asList( this.sourceDirectories ) ); } else { if ( this.defaultGrammarDirectoryJavaCC != null ) { directories.add( this.defaultGrammarDirectoryJavaCC ); } if ( this.defaultGrammarDirectoryJJTree != null ) { directories.add( this.defaultGrammarDirectoryJJTree ); } if ( this.defaultGrammarDirectoryJTB != null ) { directories.add( this.defaultGrammarDirectoryJTB ); } } return (File[]) directories.toArray( new File[directories.size()] ); } // ---------------------------------------------------------------------- // public methods // ---------------------------------------------------------------------- /** * @see org.apache.maven.reporting.MavenReport#getName(java.util.Locale) * @param locale The locale to use for this report. * @return The name of this report. */ public String getName( Locale locale ) { return getBundle( locale ).getString( "report.jjdoc.name" ); } /** * @see org.apache.maven.reporting.MavenReport#getDescription(java.util.Locale) * @param locale The locale to use for this report. * @return The description of this report. */ public String getDescription( Locale locale ) { return getBundle( locale ).getString( "report.jjdoc.short.description" ); } /** * @see org.apache.maven.reporting.MavenReport#getOutputName() * @return The name of the main report file. */ public String getOutputName() { return this.jjdocDirectory + "/index"; } /** * @see org.apache.maven.reporting.MavenReport#canGenerateReport() * @return true if the configured source directories are not empty, false otherwise. */ public boolean canGenerateReport() { File sourceDirs[] = getSourceDirectories(); for ( int i = 0; i < sourceDirs.length; i++ ) { File sourceDir = sourceDirs[i]; String[] files = sourceDir.list(); if ( files != null && files.length > 0 ) { return true; } } return false; } /** * Run the actual report. * * @param locale The locale to use for this report. * @throws MavenReportException If the report generation failed. */ public void executeReport( Locale locale ) throws MavenReportException { Sink sink = getSink(); createReportHeader( getBundle( locale ), sink ); File[] sourceDirs = getSourceDirectories(); for ( int j = 0; j < sourceDirs.length; j++ ) { File sourceDir = sourceDirs[j]; GrammarInfo[] grammarInfos = scanForGrammars( sourceDir ); if ( grammarInfos == null ) { getLog().debug( "Skipping non-existing source directory: " + sourceDir ); } else { Arrays.sort( grammarInfos, GrammarInfoComparator.getInstance() ); for ( int i = 0; i < grammarInfos.length; i++ ) { GrammarInfo grammarInfo = grammarInfos[i]; File grammarFile = grammarInfo.getGrammarFile(); String relativeOutputFileName = grammarInfo.getRelativeGrammarFile(); relativeOutputFileName = relativeOutputFileName.replaceAll( "(?i)\\.(jj|jjt|jtb)$", getOutputFileExtension() ); File jjdocOutputFile = new File( getJJDocOutputDirectory(), relativeOutputFileName ); JJDoc jjdoc = newJJDoc(); jjdoc.setInputFile( grammarFile ); jjdoc.setOutputFile( jjdocOutputFile ); try { jjdoc.run(); } catch ( Exception e ) { throw new MavenReportException( "Failed to create BNF documentation: " + grammarFile, e ); } createReportLink( sink, sourceDir, grammarFile, relativeOutputFileName ); } } } createReportFooter( sink ); sink.flush(); sink.close(); } /** * The JJDoc output file will have a .html or .txt extension depending on the value of * the parameters {@link #text} and {@link #bnf}. * * @return The file extension (including the leading period) to be used for the JJDoc output files. */ private String getOutputFileExtension() { if ( Boolean.TRUE.equals( this.text ) || Boolean.TRUE.equals( this.bnf ) ) { return ".txt"; } else { return ".html"; } } /** * Create the header and title for the HTML report page. * * @param bundle The resource bundle with the text. * @param sink The sink for writing to the main report file. */ private void createReportHeader( ResourceBundle bundle, Sink sink ) { sink.head(); sink.title(); sink.text( bundle.getString( "report.jjdoc.title" ) ); sink.title_(); sink.head_(); sink.body(); sink.section1(); sink.sectionTitle1(); sink.text( bundle.getString( "report.jjdoc.title" ) ); sink.sectionTitle1_(); sink.text( bundle.getString( "report.jjdoc.description" ) ); sink.section1_(); sink.lineBreak(); sink.table(); sink.tableRow(); sink.tableHeaderCell(); sink.text( bundle.getString( "report.jjdoc.table.heading" ) ); sink.tableHeaderCell_(); sink.tableRow_(); } /** * Create a table row containing a link to the JJDoc report for a grammar file. * * @param sink The sink to write the report * @param sourceDirectory The source directory of the grammar file. * @param grammarFile The JavaCC grammar file. * @param linkPath The path to the JJDoc output. */ private void createReportLink( Sink sink, File sourceDirectory, File grammarFile, String linkPath ) { sink.tableRow(); sink.tableCell(); if ( linkPath.startsWith( "/" ) ) { linkPath = linkPath.substring( 1 ); } sink.link( linkPath ); String grammarFileRelativePath = sourceDirectory.toURI().relativize( grammarFile.toURI() ).toString(); if ( grammarFileRelativePath.startsWith( "/" ) ) { grammarFileRelativePath = grammarFileRelativePath.substring( 1 ); } sink.text( grammarFileRelativePath ); sink.link_(); sink.tableCell_(); sink.tableRow_(); } /** * Create the HTML footer for the report page. * * @param sink The sink to write the HTML report page. */ private void createReportFooter( Sink sink ) { sink.table_(); sink.body_(); } /** * Creates a new facade to invoke JJDoc. Most options for the invocation are derived from the current values of the * corresponding mojo parameters. The caller is responsible to set the input file and output file on the returned * facade. * * @return The facade for the tool invocation, never null. */ private JJDoc newJJDoc() { JJDoc jjdoc = new JJDoc(); jjdoc.setLog( getLog() ); jjdoc.setGrammarEncoding( this.grammarEncoding ); jjdoc.setCssHref( this.cssHref ); jjdoc.setText( this.text ); jjdoc.setBnf( this.bnf ); jjdoc.setOneTable( Boolean.valueOf( this.oneTable ) ); return jjdoc; } /** * Searches the specified source directory to find grammar files that can be documented. * * @param sourceDirectory The source directory to scan for grammar files. * @return An array of grammar infos describing the found grammar files or null if the source * directory does not exist. * @throws MavenReportException If there is a problem while scanning for .jj files. */ private GrammarInfo[] scanForGrammars( File sourceDirectory ) throws MavenReportException { if ( !sourceDirectory.isDirectory() ) { return null; } GrammarInfo[] grammarInfos; getLog().debug( "Scanning for grammars: " + sourceDirectory ); try { String[] includes = { "**/*.jj", "**/*.JJ", "**/*.jjt", "**/*.JJT", "**/*.jtb", "**/*.JTB" }; GrammarDirectoryScanner scanner = new GrammarDirectoryScanner(); scanner.setSourceDirectory( sourceDirectory ); scanner.setIncludes( includes ); scanner.scan(); grammarInfos = scanner.getIncludedGrammars(); } catch ( Exception e ) { throw new MavenReportException( "Failed to scan for grammars: " + sourceDirectory, e ); } getLog().debug( "Found grammars: " + Arrays.asList( grammarInfos ) ); return grammarInfos; } /** * Get the resource bundle for the report text. * * @param locale The locale to use for this report. * @return The resource bundle. */ private ResourceBundle getBundle( Locale locale ) { return ResourceBundle.getBundle( "jjdoc-report", locale, getClass().getClassLoader() ); } /** * Compares grammar infos using their relative grammar file paths as the sort key. */ private static class GrammarInfoComparator implements Comparator { /** * The singleton instance of this comparator. */ private static final GrammarInfoComparator INSTANCE = new GrammarInfoComparator(); /** * Gets the singleton instance of this class. * * @return The singleton instance of this class. */ public static GrammarInfoComparator getInstance() { return INSTANCE; } /** * Compares the path of two grammar files lexicographically. * * @param o1 The first grammar info. * @param o2 The second grammar info. * @return A negative integer if the first grammar is considered "smaller", a positive integer if it is * considered "greater" and zero otherwise. */ public int compare( Object o1, Object o2 ) { int rel; GrammarInfo info1 = (GrammarInfo) o1; String[] paths1 = info1.getRelativeGrammarFile().split( "\\" + File.separatorChar ); GrammarInfo info2 = (GrammarInfo) o2; String[] paths2 = info2.getRelativeGrammarFile().split( "\\" + File.separatorChar ); int dirs = Math.min( paths1.length, paths2.length ) - 1; for ( int i = 0; i < dirs; i++ ) { rel = paths1[i].compareToIgnoreCase( paths2[i] ); if ( rel != 0 ) { return rel; } } rel = paths1.length - paths2.length; if ( rel != 0 ) { return rel; } return paths1[paths1.length - 1].compareToIgnoreCase( paths2[paths1.length - 1] ); } } } javacc-maven-plugin-2.6/src/main/java/org/codehaus/mojo/javacc/JTBMojo.java0000644000175000017500000002545311067720504026363 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; /** * Parses a JTB file and transforms it into source files for an AST and a JavaCC grammar file which automatically builds * the AST.

Note: JTB requires Java 1.5 * or higher. This goal will not work with earlier versions of the JRE. * * @goal jtb * @phase generate-sources * @since 2.2 * @deprecated As of version 2.4, use the jtb-javacc goal instead. * @author Gregory Kick (gk5885@kickstyle.net) * @version $Id: JTBMojo.java 7743 2008-09-28 15:22:44Z bentmann $ */ public class JTBMojo extends AbstractPreprocessorMojo { /** * This option is short for nodePackageName = <packageName>.syntaxtree and * visitorPackageName = <packageName>.visitor. Note that this option takes * precedence over nodePackageName and visitorPackageName if specified. * * @parameter expression="${package}" */ private String packageName; /** * This option specifies the package for the generated AST nodes. This value may use a leading asterisk to reference * the package of the corresponding parser. For example, if the parser package is org.apache and this * parameter is set to *.demo, the tree node classes will be located in the package * org.apache.demo. Default value is *.syntaxtree. * * @parameter expression="${nodePackageName}" */ private String nodePackageName; /** * This option specifies the package for the generated visitors. This value may use a leading asterisk to reference * the package of the corresponding parser. For example, if the parser package is org.apache and this * parameter is set to *.demo, the visitor classes will be located in the package * org.apache.demo. Default value is *.visitor. * * @parameter expression="${visitorPackageName}" */ private String visitorPackageName; /** * If true, JTB will suppress its semantic error checking. Default value is false. * * @parameter expression="${supressErrorChecking}" */ private Boolean supressErrorChecking; /** * If true, all generated comments will be wrapped in <pre> tags so that they * are formatted correctly in API docs. Default value is false. * * @parameter expression="${javadocFriendlyComments}" */ private Boolean javadocFriendlyComments; /** * Setting this option to true causes JTB to generate field names that reflect the structure of the * tree instead of generic names like f0, f1 etc. Default value is false. * * @parameter expression="${descriptiveFieldNames}" */ private Boolean descriptiveFieldNames; /** * The qualified name of a user-defined class from which all AST nodes will inherit. By default, AST nodes will * inherit from the generated class Node. * * @parameter expression="${nodeParentClass}" */ private String nodeParentClass; /** * If true, all nodes will contain fields for its parent node. Default value is false. * * @parameter expression="${parentPointers}" */ private Boolean parentPointers; /** * If true, JTB will include JavaCC "special tokens" in the AST. Default value is false. * * @parameter expression="${specialTokens}" */ private Boolean specialTokens; /** * If true, JTB will generate the following files to support the Schema programming language: * * Default value is false. * * @parameter expression="${scheme}" */ private Boolean scheme; /** * If true, JTB will generate a syntax tree dumping visitor. Default value is false. * * @parameter expression="${printer}" */ private Boolean printer; /** * The directory where the JavaCC grammar files (*.jtb) are located. It will be recursively scanned * for input files to pass to JTB. * * @parameter expression="${sourceDirectory}" default-value="${basedir}/src/main/jtb" */ private File sourceDirectory; /** * The directory where the output Java files will be located. * * @parameter expression="${outputDirectory}" default-value="${project.build.directory}/generated-sources/jtb" */ private File outputDirectory; /** * The directory to store the processed input files for later detection of stale sources. * * @parameter expression="${timestampDirectory}" * default-value="${project.build.directory}/generated-sources/jtb-timestamp" */ private File timestampDirectory; /** * The granularity in milliseconds of the last modification date for testing whether a source needs recompilation. * * @parameter expression="${lastModGranularityMs}" default-value="0" */ private int staleMillis; /** * A set of Ant-like inclusion patterns used to select files from the source directory for processing. By default, * the patterns **/*.jtb and **/*.JTB are used to select grammar files. * * @parameter */ private String[] includes; /** * A set of Ant-like exclusion patterns used to prevent certain files from being processed. By default, this set is * empty such that no files are excluded. * * @parameter */ private String[] excludes; /** * {@inheritDoc} */ protected File getSourceDirectory() { return this.sourceDirectory; } /** * {@inheritDoc} */ protected String[] getIncludes() { if ( this.includes != null ) { return this.includes; } else { return new String[] { "**/*.jtb", "**/*.JTB" }; } } /** * {@inheritDoc} */ protected String[] getExcludes() { return this.excludes; } /** * {@inheritDoc} */ protected File getOutputDirectory() { return this.outputDirectory; } /** * {@inheritDoc} */ protected File getTimestampDirectory() { return this.timestampDirectory; } /** * {@inheritDoc} */ protected int getStaleMillis() { return this.staleMillis; } /** * {@inheritDoc} */ protected void processGrammar( GrammarInfo grammarInfo ) throws MojoExecutionException, MojoFailureException { File jtbFile = grammarInfo.getGrammarFile(); File jjDirectory = new File( getOutputDirectory(), grammarInfo.getParserDirectory() ); String nodePackage = grammarInfo.resolvePackageName( getNodePackageName() ); File nodeDirectory = new File( getOutputDirectory(), nodePackage.replace( '.', File.separatorChar ) ); String visitorPackage = grammarInfo.resolvePackageName( getVisitorPackageName() ); File visitorDirectory = new File( getOutputDirectory(), visitorPackage.replace( '.', File.separatorChar ) ); // generate final grammar file and the node/visitor files JTB jtb = newJTB(); jtb.setInputFile( jtbFile ); jtb.setOutputDirectory( jjDirectory ); jtb.setNodeDirectory( nodeDirectory ); jtb.setVisitorDirectory( visitorDirectory ); jtb.setNodePackageName( nodePackage ); jtb.setVisitorPackageName( visitorPackage ); jtb.run(); // create timestamp file createTimestamp( grammarInfo ); } /** * Gets the effective package name for the AST node files. * * @return The effective package name for the AST node files, never null. */ private String getNodePackageName() { if ( this.packageName != null ) { return this.packageName + ".syntaxtree"; } else if ( this.nodePackageName != null ) { return this.nodePackageName; } else { return "*.syntaxtree"; } } /** * Gets the effective package name for the visitor files. * * @return The effective package name for the visitor files, never null. */ private String getVisitorPackageName() { if ( this.packageName != null ) { return this.packageName + ".visitor"; } else if ( this.visitorPackageName != null ) { return this.visitorPackageName; } else { return "*.visitor"; } } /** * Creates a new facade to invoke JTB. Most options for the invocation are derived from the current values of the * corresponding mojo parameters. The caller is responsible to set the input file, output directories and packages * on the returned facade. * * @return The facade for the tool invocation, never null. */ private JTB newJTB() { JTB jtb = new JTB(); jtb.setLog( getLog() ); jtb.setDescriptiveFieldNames( this.descriptiveFieldNames ); jtb.setJavadocFriendlyComments( this.javadocFriendlyComments ); jtb.setNodeParentClass( this.nodeParentClass ); jtb.setParentPointers( this.parentPointers ); jtb.setPrinter( this.printer ); jtb.setScheme( this.scheme ); jtb.setSpecialTokens( this.specialTokens ); jtb.setSupressErrorChecking( this.supressErrorChecking ); return jtb; } } javacc-maven-plugin-2.6/src/main/java/org/codehaus/mojo/javacc/ForkedJvm.java0000644000175000017500000002600111070232511026762 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.net.URL; import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; import org.codehaus.plexus.util.cli.StreamConsumer; /** * Runs the main() method of some tool in a forked JVM. * * @author Benjamin Bentmann * @version $Id: ForkedJvm.java 7758 2008-09-29 20:06:33Z bentmann $ * @see java - The Java Application * Launcher */ class ForkedJvm { /** * The consumer for System.out messages. */ private StreamConsumer systemOut; /** * The consumer for System.err messages. */ private StreamConsumer systemErr; /** * The executable used to fork the JVM. */ private String executable; /** * The working directory for the forked JVM. */ private File workingDirectory; /** * The class path entries for the forked JVM, given as strings. */ private Set classPathEntries = new LinkedHashSet(); /** * The qualified name of the class on which to invoke the main() method. */ private String mainClass; /** * The command line arguments to pass to the main() method, given as strings. */ private List cmdLineArgs = new ArrayList(); /** * Creates a new configuration to fork a JVM. */ public ForkedJvm() { this.executable = getDefaultExecutable(); } /** * Gets the absolute path to the JVM executable. * * @return The absolute path to the JVM executable. */ private static String getDefaultExecutable() { return System.getProperty( "java.home" ) + File.separator + "bin" + File.separator + "java"; } /** * Sets the working directory for the forked JVM. * * @param directory The working directory for the forked JVM, may be null to inherit the working * directory of the current JVM. */ public void setWorkingDirectory( File directory ) { this.workingDirectory = directory; } /** * Sets the stream consumer used to handle messages from System.out. * * @param consumer The stream consumer, may be null to discard the output. */ public void setSystemOut( StreamConsumer consumer ) { this.systemOut = consumer; } /** * Sets the stream consumer used to handle messages from System.err. * * @param consumer The stream consumer, may be null to discard the output. */ public void setSystemErr( StreamConsumer consumer ) { this.systemErr = consumer; } /** * Gets the class path for the forked JVM. * * @return The class path for the forked JVM. */ private String getClassPath() { return StringUtils.join( this.classPathEntries.iterator(), File.pathSeparator ); } /** * Adds the specified path to the class path of the forked JVM. * * @param path The path to add, may be null. */ public void addClassPathEntry( String path ) { if ( path != null ) { this.classPathEntries.add( path ); } } /** * Adds the specified path to the class path of the forked JVM. * * @param path The path to add, may be null. */ public void addClassPathEntry( File path ) { if ( path != null ) { this.classPathEntries.add( path.getAbsolutePath() ); } } /** * Adds the source JAR of the specified class/interface to the class path of the forked JVM. * * @param type The class/interface to add, may be null. */ public void addClassPathEntry( Class type ) { addClassPathEntry( getClassSource( type ) ); } /** * Gets the JAR file or directory that contains the specified class. * * @param type The class/interface to find, may be null. * @return The absolute path to the class source location or null if unknown. */ private static File getClassSource( Class type ) { if ( type != null ) { String classResource = type.getName().replace( '.', '/' ) + ".class"; return getResourceSource( classResource, type.getClassLoader() ); } return null; } /** * Gets the JAR file or directory that contains the specified class. * * @param className The qualified name of the class/interface to find, may be null. * @return The absolute path to the class source location or null if unknown. */ private static File getClassSource( String className ) { if ( className != null ) { String classResource = className.replace( '.', '/' ) + ".class"; return getResourceSource( classResource, Thread.currentThread().getContextClassLoader() ); } return null; } /** * Gets the JAR file or directory that contains the specified resource. * * @param resource The absolute name of the resource to find, may be null. * @param loader The class loader to use for searching the resource, may be null. * @return The absolute path to the resource location or null if unknown. */ private static File getResourceSource( String resource, ClassLoader loader ) { if ( resource != null ) { URL url; if ( loader != null ) { url = loader.getResource( resource ); } else { url = ClassLoader.getSystemResource( resource ); } return UrlUtils.getResourceRoot( url, resource ); } return null; } /** * Sets the qualified name of the class on which to invoke the main() method. The source of the * specified class will automatically be added to the class path of the forked JVM. * * @param name The qualified name of the class on which to invoke the main() method. */ public void setMainClass( String name ) { this.mainClass = name; addClassPathEntry( getClassSource( name ) ); } /** * Sets the class on which to invoke the main() method. The source of the specified class will * automatically be added to the class path of the forked JVM. * * @param type The class on which to invoke the main() method, may be null. */ public void setMainClass( Class type ) { this.mainClass = ( type != null ) ? type.getName() : null; addClassPathEntry( type ); } /** * Gets the command line arguments for the main() method. * * @return The command line arguments for the main() method. */ private String[] getArguments() { return (String[]) this.cmdLineArgs.toArray( new String[this.cmdLineArgs.size()] ); } /** * Adds the specified argument to the command line for the main() method. * * @param argument The argument to add, may be null. */ public void addArgument( String argument ) { if ( argument != null ) { this.cmdLineArgs.add( argument ); } } /** * Adds the specified file path to the command line for the main() method. * * @param argument The argument to add, may be null. */ public void addArgument( File argument ) { if ( argument != null ) { this.cmdLineArgs.add( argument.getAbsolutePath() ); } } /** * Adds the specified arguments to the command line for the main() method. * * @param arguments The arguments to add, may be null. */ public void addArguments( String[] arguments ) { if ( arguments != null ) { for ( int i = 0; i < arguments.length; i++ ) { addArgument( arguments[i] ); } } } /** * Creates the command line for the new JVM based on the current configuration. * * @return The command line used to fork the JVM, never null. */ private Commandline createCommandLine() { /* * NOTE: This method is designed to work with plexus-utils:1.1 which is used by all Maven versions before 2.0.6 * regardless of our plugin dependency. Therefore, we use setWorkingDirectory(String) rather than * setWorkingDirectory(File) and addArguments() rather than createArg(). */ Commandline cli = new Commandline(); cli.setExecutable( this.executable ); if ( this.workingDirectory != null ) { cli.setWorkingDirectory( this.workingDirectory.getAbsolutePath() ); } String classPath = getClassPath(); if ( classPath != null && classPath.length() > 0 ) { cli.addArguments( new String[] { "-cp", classPath } ); } if ( this.mainClass != null && this.mainClass.length() > 0 ) { cli.addArguments( new String[] { this.mainClass } ); } cli.addArguments( getArguments() ); return cli; } /** * Forks a JVM using the previously set parameters. * * @return The exit code of the forked JVM. * @throws Exception If the JVM could not be forked. */ public int run() throws Exception { return CommandLineUtils.executeCommandLine( createCommandLine(), this.systemOut, this.systemErr ); } /** * Gets a string representation of the command line arguments. * * @return A string representation of the command line arguments. */ public String toString() { return String.valueOf( createCommandLine() ); } } javacc-maven-plugin-2.6/src/main/java/org/codehaus/mojo/javacc/JJTreeMojo.java0000644000175000017500000002672511072177317027076 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; /** * Parses a JJTree grammar file (*.jjt) and transforms it to Java source files and a JavaCC grammar * file. Please see the JJTree Reference Documentation for * more information. * * @goal jjtree * @phase generate-sources * @since 2.0 * @deprecated As of version 2.4, use the jjtree-javacc goal instead. * @author jesse * @version $Id: JJTreeMojo.java 7847 2008-10-05 17:52:15Z bentmann $ */ public class JJTreeMojo extends AbstractPreprocessorMojo { /** * The Java version for which to generate source code. Default value is 1.4. * * @parameter expression="${jdkVersion}" * @since 2.4 */ private String jdkVersion; /** * A flag whether to generate sample implementations for SimpleNode and any other nodes used in the * grammar. Default value is true. * * @parameter expression="${buildNodeFiles}" */ private Boolean buildNodeFiles; /** * A flag whether to generate a multi mode parse tree or a single mode parse tree. Default value is * false. * * @parameter expression="${multi}" */ private Boolean multi; /** * A flag whether to make each non-decorated production void instead of an indefinite node. Default value is * false. * * @parameter expression="${nodeDefaultVoid}" */ private Boolean nodeDefaultVoid; /** * The name of a custom class that extends SimpleNode and will be used as the super class for the * generated tree node classes. By default, the tree node classes will directly extend the class * SimpleNode. * * @parameter expression="${nodeClass}" * @since 2.5 */ private String nodeClass; /** * The name of a custom factory class used to create Node objects. This class must have a method with * the signature public static Node jjtCreate(int id). By default, the class SimpleNode * will be used as the factory class. * * @parameter expression="${nodeFactory}" */ private String nodeFactory; /** * The package to generate the AST node classes into. This value may use a leading asterisk to reference the package * of the corresponding parser. For example, if the parser package is org.apache and this parameter * is set to *.demo, the tree node classes will be located in the package * org.apache.demo. By default, the package of the corresponding parser is used. * * @parameter expression="${nodePackage}" */ private String nodePackage; /** * The prefix used to construct node class names from node identifiers in multi mode. Default value is * AST. * * @parameter expression="${nodePrefix}" */ private String nodePrefix; /** * A flag whether user-defined parser methods should be called on entry and exit of every node scope. Default value * is false. * * @parameter expression="${nodeScopeHook}" */ private Boolean nodeScopeHook; /** * A flag whether the node construction routines need an additional method parameter to receive the parser object. * Default value is false. * * @parameter expression="${nodeUsesParser}" */ private Boolean nodeUsesParser; /** * A flag whether to generate code for a static parser. Note that this setting must match the corresponding option * for the javacc mojo. Default value is true. * * @parameter expression="${isStatic}" alias="staticOption" */ private Boolean isStatic; /** * A flag whether to insert the methods jjtGetFirstToken(), jjtSetFirstToken(), * getLastToken() and jjtSetLastToken() into the class SimpleNode. Default * value is false. * * @parameter expression="${trackTokens}" * @since 2.5 */ private Boolean trackTokens; /** * A flag whether to insert a jjtAccept() method in the node classes and to generate a visitor * implementation with an entry for every node type used in the grammar. Default value is false. * * @parameter expression="${visitor}" */ private Boolean visitor; /** * The name of a class to use for the data argument of the jjtAccept() and visit() * methods. Default value is java.lang.Object. * * @parameter expression="${visitorDataType}" * @since 2.5 */ private String visitorDataType; /** * The name of a class to use as the return type of the jjtAccept() and visit() methods. * Default value is java.lang.Object. * * @parameter expression="${visitorReturnType}" * @since 2.5 */ private String visitorReturnType; /** * The name of an exception class to include in the signature of the generated jjtAccept() * and visit() methods. By default, the throws clause of the generated methods is * empty such that only unchecked exceptions can be thrown. * * @parameter expression="${visitorException}" */ private String visitorException; /** * Directory where the input JJTree files (*.jjt) are located. * * @parameter expression="${sourceDirectory}" default-value="${basedir}/src/main/jjtree" */ private File sourceDirectory; /** * Directory where the output Java files for the node classes and the JavaCC grammar file will be located. * * @parameter expression="${outputDirectory}" default-value="${project.build.directory}/generated-sources/jjtree" */ private File outputDirectory; /** * The directory to store the processed input files for later detection of stale sources. * * @parameter expression="${timestampDirectory}" * default-value="${project.build.directory}/generated-sources/jjtree-timestamp" */ private File timestampDirectory; /** * The granularity in milliseconds of the last modification date for testing whether a source needs recompilation. * * @parameter expression="${lastModGranularityMs}" default-value="0" */ private int staleMillis; /** * A set of Ant-like inclusion patterns used to select files from the source directory for processing. By default, * the patterns **/*.jjt and **/*.JJT are used to select grammar files. * * @parameter */ private String[] includes; /** * A set of Ant-like exclusion patterns used to prevent certain files from being processed. By default, this set is * empty such that no files are excluded. * * @parameter */ private String[] excludes; /** * {@inheritDoc} */ protected File getSourceDirectory() { return this.sourceDirectory; } /** * {@inheritDoc} */ protected String[] getIncludes() { if ( this.includes != null ) { return this.includes; } else { return new String[] { "**/*.jjt", "**/*.JJT" }; } } /** * {@inheritDoc} */ protected String[] getExcludes() { return this.excludes; } /** * {@inheritDoc} */ protected File getOutputDirectory() { return this.outputDirectory; } /** * {@inheritDoc} */ protected File getTimestampDirectory() { return this.timestampDirectory; } /** * {@inheritDoc} */ protected int getStaleMillis() { return this.staleMillis; } /** * {@inheritDoc} */ protected void processGrammar( GrammarInfo grammarInfo ) throws MojoExecutionException, MojoFailureException { File jjtFile = grammarInfo.getGrammarFile(); // determine target directory for tree node files String nodePackageName = grammarInfo.resolvePackageName( this.nodePackage ); File nodeDirectory; if ( nodePackageName != null ) { nodeDirectory = new File( nodePackageName.replace( '.', File.separatorChar ) ); } else { nodeDirectory = new File( grammarInfo.getParserDirectory() ); } nodeDirectory = new File( getOutputDirectory(), nodeDirectory.getPath() ); // generate final grammar file and node files JJTree jjtree = newJJTree(); jjtree.setInputFile( jjtFile ); jjtree.setOutputDirectory( nodeDirectory ); jjtree.setNodePackage( nodePackageName ); jjtree.run(); // create timestamp file createTimestamp( grammarInfo ); } /** * Creates a new facade to invoke JJTree. Most options for the invocation are derived from the current values of the * corresponding mojo parameters. The caller is responsible to set the input file, output directory and package on * the returned facade. * * @return The facade for the tool invocation, never null. */ protected JJTree newJJTree() { JJTree jjtree = new JJTree(); jjtree.setLog( getLog() ); jjtree.setJdkVersion( this.jdkVersion ); jjtree.setStatic( this.isStatic ); jjtree.setBuildNodeFiles( this.buildNodeFiles ); jjtree.setMulti( this.multi ); jjtree.setNodeDefaultVoid( this.nodeDefaultVoid ); jjtree.setNodeClass( this.nodeClass ); jjtree.setNodeFactory( this.nodeFactory ); jjtree.setNodePrefix( this.nodePrefix ); jjtree.setNodeScopeHook( this.nodeScopeHook ); jjtree.setNodeUsesParser( this.nodeUsesParser ); jjtree.setTrackTokens( this.trackTokens ); jjtree.setVisitor( this.visitor ); jjtree.setVisitorDataType( this.visitorDataType ); jjtree.setVisitorReturnType( this.visitorReturnType ); jjtree.setVisitorException( this.visitorException ); return jjtree; } /** * Prevents registration of our output or a following invocation of the javacc mojo will cause duplicate sources * which in turn will make compilation fail. */ protected void addCompileSourceRoot() { // do nothing } } javacc-maven-plugin-2.6/src/main/java/org/codehaus/mojo/javacc/GrammarDirectoryScanner.java0000644000175000017500000001740710753435762031716 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.codehaus.plexus.util.DirectoryScanner; /** * Scans source directories for JavaCC grammar files. * * @author Benjamin Bentmann * @version $Id: GrammarDirectoryScanner.java 6282 2008-02-09 23:49:06Z bentmann $ */ class GrammarDirectoryScanner { /** * The directory scanner used to scan the source directory for files. */ private DirectoryScanner scanner; /** * The absolute path to the output directory used to detect stale target files by timestamp checking, may be * null if no stale detection should be performed. */ private File outputDirectory; // TODO: Once the parameter "packageName" from the javacc mojo has been deleted, remove this field, too. /** * The package name for the generated parser, may be null to use the package declaration from the * grammar file. */ private String parserPackage; /** * The granularity in milliseconds of the last modification date for testing whether a grammar file needs * recompilation because its corresponding target file is stale. */ private int staleMillis; /** * A set of grammar infos describing the included grammar files, must never be null. */ private List includedGrammars; /** * Creates a new grammar directory scanner. */ public GrammarDirectoryScanner() { this.scanner = new DirectoryScanner(); this.scanner.setFollowSymlinks( true ); this.includedGrammars = new ArrayList(); } /** * Sets the absolute path to the source directory to scan for grammar files. This directory must exist or the * scanner will report an error. * * @param directory The absolute path to the source directory to scan, must not be null. */ public void setSourceDirectory( File directory ) { if ( !directory.isAbsolute() ) { throw new IllegalArgumentException( "source directory is not absolute: " + directory ); } this.scanner.setBasedir( directory ); } /** * Sets the package name for the generated parser. * * @param packageName The package name for the generated parser, may be null to use the package * declaration from the grammar file. */ public void setParserPackage( String packageName ) { this.parserPackage = packageName; } /** * Sets the Ant-like inclusion patterns. * * @param includes The set of Ant-like inclusion patterns, may be null to include all files. */ public void setIncludes( String[] includes ) { this.scanner.setIncludes( includes ); } /** * Sets the Ant-like exclusion patterns. * * @param excludes The set of Ant-like exclusion patterns, may be null to exclude no files. */ public void setExcludes( String[] excludes ) { this.scanner.setExcludes( excludes ); this.scanner.addDefaultExcludes(); } /** * Sets the absolute path to the output directory used to detect stale target files. * * @param directory The absolute path to the output directory used to detect stale target files by timestamp * checking, may be null if no stale detection should be performed. */ public void setOutputDirectory( File directory ) { if ( directory != null && !directory.isAbsolute() ) { throw new IllegalArgumentException( "output directory is not absolute: " + directory ); } this.outputDirectory = directory; } /** * Sets the granularity in milliseconds of the last modification date for stale file detection. * * @param milliseconds The granularity in milliseconds of the last modification date for testing whether a grammar * file needs recompilation because its corresponding target file is stale. */ public void setStaleMillis( int milliseconds ) { this.staleMillis = milliseconds; } /** * Scans the source directory for grammar files that match at least one inclusion pattern but no exclusion pattern, * optionally performing timestamp checking to exclude grammars whose corresponding parser files are up to date. * * @throws IOException If a grammar file could not be analyzed for metadata. */ public void scan() throws IOException { this.includedGrammars.clear(); this.scanner.scan(); String[] includedFiles = this.scanner.getIncludedFiles(); for ( int i = 0; i < includedFiles.length; i++ ) { String includedFile = includedFiles[i]; GrammarInfo grammarInfo = new GrammarInfo( this.scanner.getBasedir(), includedFile, this.parserPackage ); if ( this.outputDirectory != null ) { File sourceFile = grammarInfo.getGrammarFile(); File[] targetFiles = getTargetFiles( this.outputDirectory, includedFile, grammarInfo ); for ( int j = 0; j < targetFiles.length; j++ ) { File targetFile = targetFiles[j]; if ( !targetFile.exists() || targetFile.lastModified() + this.staleMillis < sourceFile.lastModified() ) { this.includedGrammars.add( grammarInfo ); break; } } } else { this.includedGrammars.add( grammarInfo ); } } } /** * Determines the output files corresponding to the specified grammar file. * * @param targetDirectory The absolute path to the output directory for the target files, must not be * null. * @param grammarFile The path to the grammar file, relative to the scanned source directory, must not be * null. * @param grammarInfo The grammar info describing the grammar file, must not be null * @return A file array with target files, never null. */ protected File[] getTargetFiles( File targetDirectory, String grammarFile, GrammarInfo grammarInfo ) { File parserFile = new File( targetDirectory, grammarInfo.getParserFile() ); return new File[] { parserFile }; } /** * Gets the grammar files that were included by the scanner during the last invocation of {@link #scan()}. * * @return An array of grammar infos describing the included grammar files, will be empty if no files were included * but is never null. */ public GrammarInfo[] getIncludedGrammars() { return (GrammarInfo[]) this.includedGrammars.toArray( new GrammarInfo[this.includedGrammars.size()] ); } } javacc-maven-plugin-2.6/src/main/java/org/codehaus/mojo/javacc/GrammarInfo.java0000644000175000017500000002403311113311543027301 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.codehaus.plexus.util.FileUtils; /** * This bean holds some output related information about a JavaCC grammar file. It assists in determining the exact * output location for the generated parser file. * * @author Benjamin Bentmann * @version $Id: GrammarInfo.java 8156 2008-11-26 18:20:19Z bentmann $ */ class GrammarInfo { /** * The absolute path to the base directory in which the grammar file resides. */ private final File sourceDirectory; /** * The path to the grammar file (relative to its source directory, e.g. "grammars/MyParser.jj"). */ private final String grammarFile; /** * The declared package for the generated parser (e.g. "org.apache"). */ private final String parserPackage; /** * The path to the directory of the parser package (relative to a source root directory, e.g. "org/apache"). */ private final String parserDirectory; /** * The simple name of the generated parser (e.g. "MyParser"). */ private final String parserName; /** * The path to the generated parser file (relative to a source root directory, e.g. "org/apache/MyParser.java"). */ private final String parserFile; /** * Creates a new info from the specified grammar file. * * @param sourceDir The absolute path to the base directory in which the grammar file resides, must not be * null. * @param inputFile The path to the grammar file (relative to the source directory), must not be null. * @throws IOException If reading the grammar file failed. */ public GrammarInfo( File sourceDir, String inputFile ) throws IOException { this( sourceDir, inputFile, null ); } /** * Creates a new info from the specified grammar file. * * @param sourceDir The absolute path to the base directory in which the grammar file resides, must not be * null. * @param inputFile The path to the grammar file (relative to the source directory), must not be null. * @param packageName The package name for the generated parser, may be null to use the package * declaration from the grammar file. * @throws IOException If reading the grammar file failed. */ public GrammarInfo( File sourceDir, String inputFile, String packageName ) throws IOException { if ( !sourceDir.isAbsolute() ) { throw new IllegalArgumentException( "source directory is not absolute: " + sourceDir ); } this.sourceDirectory = sourceDir; File inFile = new File( inputFile ); if ( !inFile.isAbsolute() ) { this.grammarFile = inFile.getPath(); } else if ( inFile.getPath().startsWith( sourceDir.getPath() ) ) { this.grammarFile = inFile.getPath().substring( sourceDir.getPath().length() + 1 ); } else { throw new IllegalArgumentException( "input file is not relative to source directory:" + inputFile ); } // NOTE: JavaCC uses the platform default encoding to read files, so must we String grammar = FileUtils.fileRead( getGrammarFile() ); // TODO: Once the parameter "packageName" from the javacc mojo has been deleted, remove our parameter, too. if ( packageName == null ) { this.parserPackage = findPackageName( grammar ); } else { this.parserPackage = packageName; } this.parserDirectory = this.parserPackage.replace( '.', File.separatorChar ); String name = findParserName( grammar ); if ( name.length() <= 0 ) { this.parserName = FileUtils.removeExtension( inFile.getName() ); } else { this.parserName = name; } if ( this.parserDirectory.length() > 0 ) { this.parserFile = new File( this.parserDirectory, this.parserName + ".java" ).getPath(); } else { this.parserFile = this.parserName + ".java"; } } /** * Extracts the declared package name from the specified grammar file. * * @param grammar The contents of the grammar file, must not be null. * @return The declared package name or an empty string if not found. */ private String findPackageName( String grammar ) { final String packageDeclaration = "package\\s+([^\\s.;]+(\\.[^\\s.;]+)*)\\s*;"; Matcher matcher = Pattern.compile( packageDeclaration ).matcher( grammar ); if ( matcher.find() ) { return matcher.group( 1 ); } return ""; } /** * Extracts the simple parser name from the specified grammar file. * * @param grammar The contents of the grammar file, must not be null. * @return The parser name or an empty string if not found. */ private String findParserName( String grammar ) { final String parserBegin = "PARSER_BEGIN\\s*\\(\\s*([^\\s\\)]+)\\s*\\)"; Matcher matcher = Pattern.compile( parserBegin ).matcher( grammar ); if ( matcher.find() ) { return matcher.group( 1 ); } return ""; } /** * Gets the absolute path to the base directory in which the grammar file resides. Note that this is not necessarily * the parent directory of the grammar file. * * @return The absolute path to the base directory in which the grammar file resides, never null. */ public File getSourceDirectory() { return this.sourceDirectory; } /** * Gets the absolute path to the grammar file. * * @return The absolute path to the grammar file, never null. */ public File getGrammarFile() { return new File( this.sourceDirectory, this.grammarFile ); } /** * Gets the path to the grammar file (relative to its source directory). * * @return The path to the grammar file (relative to its source directory), never null. */ public String getRelativeGrammarFile() { return this.grammarFile; } /** * Resolves the specified package name against the package name of the parser generated from this grammar. To * reference the parser package, the input string may use the prefix "*". For example, if the package for the parser * is "org.apache" and the input string is "*.node", the resolved package is "org.apache.node". The period after the * asterisk is significant, i.e. in the previous example the input string "*node" would resolve to "org.apachenode". * * @param packageName The package name to resolve, may be null. * @return The resolved package name or null if the input string was null. */ public String resolvePackageName( String packageName ) { String resolvedPackageName = packageName; if ( resolvedPackageName != null && resolvedPackageName.startsWith( "*" ) ) { resolvedPackageName = getParserPackage() + resolvedPackageName.substring( 1 ); if ( resolvedPackageName.startsWith( "." ) ) { resolvedPackageName = resolvedPackageName.substring( 1 ); } } return resolvedPackageName; } /** * Gets the declared package for the generated parser (e.g. "org.apache"). * * @return The declared package for the generated parser (e.g. "org.apache") or an empty string if no package * declaration was found, never null. */ public String getParserPackage() { return this.parserPackage; } /** * Gets the path to the directory of the parser package (relative to a source root directory, e.g. "org/apache"). * * @return The path to the directory of the parser package (relative to a source root directory, e.g. "org/apache") * or an empty string if no package declaration was found, never null. */ public String getParserDirectory() { return this.parserDirectory; } /** * Gets the simple name of the generated parser (e.g. "MyParser") * * @return The simple name of the generated parser (e.g. "MyParser"), never null. */ public String getParserName() { return this.parserName; } /** * Gets the path to the parser file (relative to a source root directory, e.g. "org/apache/MyParser.java"). * * @return The path to the parser file (relative to a source root directory, e.g. "org/apache/MyParser.java"), never * null. */ public String getParserFile() { return this.parserFile; } /** * Gets a string representation of this bean. This value is for debugging purposes only. * * @return A string representation of this bean. */ public String toString() { return getGrammarFile() + " -> " + getParserFile(); } } javacc-maven-plugin-2.6/src/main/java/org/codehaus/mojo/javacc/JJTree.java0000644000175000017500000003205311250747644026244 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.StringUtils; /** * Provides a facade for the mojos to invoke JJTree. * * @author Benjamin Bentmann * @version $Id: JJTree.java 10603 2009-09-06 15:05:08Z bentmann $ * @see JJTree Reference */ class JJTree extends ToolFacade { /** * The input grammar. */ private File inputFile; /** * The option OUTPUT_DIRECTORY. */ private File outputDirectory; /** * The option GRAMMAR_ENCODING. */ private String grammarEncoding; /** * The option JDK_VERSION. */ private String jdkVersion; /** * The option STATIC. */ private Boolean isStatic; /** * The option BUILD_NODE_FILES. */ private Boolean buildNodeFiles; /** * The option MULTI. */ private Boolean multi; /** * The option NODE_DEFAULT_VOID. */ private Boolean nodeDefaultVoid; /** * The option NODE_CLASS. */ private String nodeClass; /** * The option NODE_FACTORY. */ private String nodeFactory; /** * The option NODE_PACKAGE. */ private String nodePackage; /** * The option NODE_PREFIX. */ private String nodePrefix; /** * The option NODE_SCOPE_HOOK. */ private Boolean nodeScopeHook; /** * The option NODE_USES_PARSER. */ private Boolean nodeUsesParser; /** * The option TRACK_TOKENS. */ private Boolean trackTokens; /** * The option VISITOR. */ private Boolean visitor; /** * The option VISITOR_DATA_TYPE. */ private String visitorDataType; /** * The option VISITOR_RETURN_TYPE. */ private String visitorReturnType; /** * The option VISITOR_EXCEPTION. */ private String visitorException; /** * Sets the absolute path to the grammar file to pass into JJTree for preprocessing. * * @param value The absolute path to the grammar file to pass into JJTree for preprocessing. */ public void setInputFile( File value ) { if ( value != null && !value.isAbsolute() ) { throw new IllegalArgumentException( "path is not absolute: " + value ); } this.inputFile = value; } /** * Sets the absolute path to the output directory. * * @param value The absolute path to the output directory for the generated grammar file. If this directory does not * exist yet, it is created. Note that this path should already include the desired package hierarchy * because JJTree will not append the required sub directories automatically. */ public void setOutputDirectory( File value ) { if ( value != null && !value.isAbsolute() ) { throw new IllegalArgumentException( "path is not absolute: " + value ); } this.outputDirectory = value; } /** * Gets the absolute path to the enhanced grammar file generated by JJTree. * * @return The absolute path to the enhanced grammar file generated by JJTree or null if either the * input file or the output directory have not been set. */ public File getOutputFile() { File outputFile = null; if ( this.outputDirectory != null && this.inputFile != null ) { String fileName = FileUtils.removeExtension( this.inputFile.getName() ) + ".jj"; outputFile = new File( this.outputDirectory, fileName ); } return outputFile; } /** * Sets the option GRAMMAR_ENCODING. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setGrammarEncoding( String value ) { this.grammarEncoding = value; } /** * Sets the option JDK_VERSION. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setJdkVersion( String value ) { this.jdkVersion = value; } /** * Sets the option STATIC. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setStatic( Boolean value ) { this.isStatic = value; } /** * Sets the option value BUILD_NODE_FILES. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setBuildNodeFiles( Boolean value ) { this.buildNodeFiles = value; } /** * Sets the option value MULTI. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setMulti( Boolean value ) { this.multi = value; } /** * Sets the option value NODE_DEFAULT_VOID. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setNodeDefaultVoid( Boolean value ) { this.nodeDefaultVoid = value; } /** * Sets the option value NODE_CLASS. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setNodeClass( String value ) { this.nodeClass = value; } /** * Sets the option value NODE_FACTORY. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setNodeFactory( String value ) { this.nodeFactory = value; } /** * Sets the option value NODE_PACKAGE. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setNodePackage( String value ) { this.nodePackage = value; } /** * Sets the option value NODE_PREFIX. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setNodePrefix( String value ) { this.nodePrefix = value; } /** * Sets the option value NODE_SCOPE_HOOK. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setNodeScopeHook( Boolean value ) { this.nodeScopeHook = value; } /** * Sets the option value NODE_USES_PARSER. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setNodeUsesParser( Boolean value ) { this.nodeUsesParser = value; } /** * Sets the option value TRACK_TOKENS. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setTrackTokens( Boolean value ) { this.trackTokens = value; } /** * Sets the option value VISITOR. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setVisitor( Boolean value ) { this.visitor = value; } /** * Sets the option value VISITOR_DATA_TYPE. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setVisitorDataType( String value ) { this.visitorDataType = value; } /** * Sets the option value VISITOR_RETURN_TYPE. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setVisitorReturnType( String value ) { this.visitorReturnType = value; } /** * Sets the option value VISITOR_EXCEPTION. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setVisitorException( String value ) { this.visitorException = value; } /** * {@inheritDoc} */ protected int execute() throws Exception { String[] args = generateArguments(); if ( this.outputDirectory != null && !this.outputDirectory.exists() ) { this.outputDirectory.mkdirs(); } org.javacc.jjtree.JJTree jjtree = new org.javacc.jjtree.JJTree(); return jjtree.main( args ); } /** * Assembles the command line arguments for the invocation of JJTree according to the configuration.

* Note: To prevent conflicts with JavaCC options that might be set directly in the grammar file, * only those parameters that have been explicitly set are passed on the command line. * * @return A string array that represents the arguments to use for JJTree. */ private String[] generateArguments() { List argsList = new ArrayList(); if ( StringUtils.isNotEmpty( this.grammarEncoding ) ) { argsList.add( "-GRAMMAR_ENCODING=" + this.grammarEncoding ); } if ( StringUtils.isNotEmpty( jdkVersion ) ) { argsList.add( "-JDK_VERSION=" + this.jdkVersion ); } if ( this.buildNodeFiles != null ) { argsList.add( "-BUILD_NODE_FILES=" + this.buildNodeFiles ); } if ( this.multi != null ) { argsList.add( "-MULTI=" + this.multi ); } if ( this.nodeDefaultVoid != null ) { argsList.add( "-NODE_DEFAULT_VOID=" + this.nodeDefaultVoid ); } if ( StringUtils.isNotEmpty( this.nodeClass ) ) { argsList.add( "-NODE_CLASS=" + this.nodeClass ); } if ( StringUtils.isNotEmpty( this.nodeFactory ) ) { argsList.add( "-NODE_FACTORY=" + this.nodeFactory ); } if ( StringUtils.isNotEmpty( this.nodePackage ) ) { argsList.add( "-NODE_PACKAGE=" + this.nodePackage ); } if ( StringUtils.isNotEmpty( this.nodePrefix ) ) { argsList.add( "-NODE_PREFIX=" + this.nodePrefix ); } if ( this.nodeScopeHook != null ) { argsList.add( "-NODE_SCOPE_HOOK=" + this.nodeScopeHook ); } if ( this.nodeUsesParser != null ) { argsList.add( "-NODE_USES_PARSER=" + this.nodeUsesParser ); } if ( this.isStatic != null ) { argsList.add( "-STATIC=" + this.isStatic ); } if ( this.trackTokens != null ) { argsList.add( "-TRACK_TOKENS=" + this.trackTokens ); } if ( this.visitor != null ) { argsList.add( "-VISITOR=" + this.visitor ); } if ( StringUtils.isNotEmpty( this.visitorDataType ) ) { argsList.add( "-VISITOR_DATA_TYPE=" + this.visitorDataType ); } if ( StringUtils.isNotEmpty( this.visitorReturnType ) ) { argsList.add( "-VISITOR_RETURN_TYPE=" + this.visitorReturnType ); } if ( StringUtils.isNotEmpty( this.visitorException ) ) { argsList.add( "-VISITOR_EXCEPTION=" + this.visitorException ); } if ( this.outputDirectory != null ) { argsList.add( "-OUTPUT_DIRECTORY=" + this.outputDirectory.getAbsolutePath() ); } if ( this.inputFile != null ) { argsList.add( this.inputFile.getAbsolutePath() ); } return (String[]) argsList.toArray( new String[argsList.size()] ); } /** * Gets a string representation of the command line arguments. * * @return A string representation of the command line arguments. */ public String toString() { return Arrays.asList( generateArguments() ).toString(); } } javacc-maven-plugin-2.6/src/main/java/org/codehaus/mojo/javacc/ToolFacade.java0000644000175000017500000000643511070232511027105 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugin.logging.SystemStreamLog; /** * Provides a facade for the mojos to invoke JavaCC related tools. * * @author Benjamin Bentmann * @version $Id: ToolFacade.java 7758 2008-09-29 20:06:33Z bentmann $ */ abstract class ToolFacade { /** * The logger used to output diagnostic messages. */ private Log log; /** * Sets the logger used to output diagnostic messages. * * @param logger The logger used to output diagnostic messages, may be null. */ public void setLog( Log logger ) { this.log = logger; } /** * Gets the logger used to output diagnostic messages. * * @return The logger used to output diagnostic messages, never null. */ protected Log getLog() { if ( this.log == null ) { this.log = new SystemStreamLog(); } return this.log; } /** * Gets the name of the tool. * * @return The name of the tool, never null. */ protected String getToolName() { String name = getClass().getName(); return name.substring( name.lastIndexOf( '.' ) + 1 ); } /** * Runs the tool using the previously set parameters. * * @throws MojoExecutionException If the tool could not be invoked. * @throws MojoFailureException If the tool reported a non-zero exit code. */ public void run() throws MojoExecutionException, MojoFailureException { int exitCode; try { if ( getLog().isDebugEnabled() ) { getLog().debug( "Running " + getToolName() + ": " + this ); } exitCode = execute(); } catch ( Exception e ) { throw new MojoExecutionException( "Failed to execute " + getToolName(), e ); } if ( exitCode != 0 ) { throw new MojoFailureException( getToolName() + " reported exit code " + exitCode + ": " + this ); } } /** * Runs the tool using the previously set parameters. * * @return The exit code of the tool, non-zero means failure. * @throws Exception If the tool could not be invoked. */ protected abstract int execute() throws Exception; } javacc-maven-plugin-2.6/src/main/java/org/codehaus/mojo/javacc/UrlUtils.java0000644000175000017500000001302011017732160026661 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.nio.ByteBuffer; import java.nio.charset.Charset; /** * Assists in handling of URLs. * * @author Benjamin Bentmann * @version $Id: UrlUtils.java 7084 2008-05-30 08:01:52Z bentmann $ */ class UrlUtils { /** * The UTF-8 character set, used to decode octets in URLs. */ private static final Charset UTF8 = Charset.forName( "UTF-8" ); /** * The protocol prefix for "jar:" URLs. */ private static final String JAR = "jar:"; /** * The protocol prefix for "file:" URLs. */ private static final String FILE = "file:"; /** * The protocol prefix for "jar:file:" URLs. */ private static final String JAR_FILE = JAR + FILE; /** * Gets the absolute filesystem path to the class path root for the specified resource. The root is either a JAR * file or a directory with loose class files. If the URL does not use a supported protocol, an exception will be * thrown. * * @param url The URL to the resource, may be null. * @param resource The name of the resource, must not be null. * @return The absolute filesystem path to the class path root of the resource or null if the input * URL was null. */ public static File getResourceRoot( URL url, String resource ) { String path = null; if ( url != null ) { String spec = url.toExternalForm(); if ( ( JAR_FILE ).regionMatches( true, 0, spec, 0, JAR_FILE.length() ) ) { URL jar; try { jar = new URL( spec.substring( JAR.length(), spec.lastIndexOf( "!/" ) ) ); } catch ( MalformedURLException e ) { throw new IllegalArgumentException( "Invalid JAR URL: " + url + ", " + e.getMessage() ); } path = decodeUrl( jar.getPath() ); } else if ( FILE.regionMatches( true, 0, spec, 0, FILE.length() ) ) { path = decodeUrl( url.getPath() ); path = path.substring( 0, path.length() - resource.length() ); } else { throw new IllegalArgumentException( "Invalid class path URL: " + url ); } } return ( path != null ) ? new File( path ) : null; } /** * Decodes the specified URL as per RFC 3986, i.e. transforms percent-encoded octets to characters by decoding with * the UTF-8 character set. This function is primarily intended for usage with {@link java.net.URL} which * unfortunately does not enforce proper URLs. As such, this method will leniently accept invalid characters or * malformed percent-encoded octets and simply pass them literally through to the result string. Except for rare * edge cases, this will make unencoded URLs pass through unaltered. * * @param url The URL to decode, may be null. * @return The decoded URL or null if the input was null. */ public static String decodeUrl( String url ) { String decoded = url; if ( url != null && url.indexOf( '%' ) >= 0 ) { int n = url.length(); StringBuffer buffer = new StringBuffer(); ByteBuffer bytes = ByteBuffer.allocate( n ); for ( int i = 0; i < n; ) { if ( url.charAt( i ) == '%' ) { try { do { byte octet = (byte) Integer.parseInt( url.substring( i + 1, i + 3 ), 16 ); bytes.put( octet ); i += 3; } while ( i < n && url.charAt( i ) == '%' ); continue; } catch ( RuntimeException e ) { // malformed percent-encoded octet, fall through and append characters literally } finally { if ( bytes.position() > 0 ) { bytes.flip(); buffer.append( UTF8.decode( bytes ).toString() ); bytes.clear(); } } } buffer.append( url.charAt( i++ ) ); } decoded = buffer.toString(); } return decoded; } } javacc-maven-plugin-2.6/src/main/java/org/codehaus/mojo/javacc/JJDoc.java0000644000175000017500000001733611250747644026061 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.cli.StreamConsumer; /** * Provides a facade for the mojos to invoke JJDoc. * * @author Paul Gier, Benjamin Bentmann * @version $Id: JJDoc.java 10603 2009-09-06 15:05:08Z bentmann $ * @see JJDoc Reference */ class JJDoc extends ToolFacade { /** * The input grammar. */ private File inputFile; /** * The option OUTPUT_FILE. */ private File outputFile; /** * The option GRAMMAR_ENCODING. */ private String grammarEncoding; /** * The option CSS. */ private String cssHref; /** * The option TEXT. */ private Boolean text; /** * The option BNF. */ private Boolean bnf; /** * The option ONE_TABLE. */ private Boolean oneTable; /** * Sets the absolute path to the grammar file to pass into JJDoc for documentation. * * @param value The absolute path to the grammar file to pass into JJDoc for documentation. */ public void setInputFile( File value ) { if ( value != null && !value.isAbsolute() ) { throw new IllegalArgumentException( "path is not absolute: " + value ); } this.inputFile = value; } /** * Sets the absolute path to the output file. * * @param value The absolute path to the HTML/text file to generate. */ public void setOutputFile( File value ) { if ( value != null && !value.isAbsolute() ) { throw new IllegalArgumentException( "path is not absolute: " + value ); } this.outputFile = value; } /** * Sets the option GRAMMAR_ENCODING. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setGrammarEncoding( String value ) { this.grammarEncoding = value; } /** * Sets the option CSS, i.e the hypertext reference to a CSS file for the generated HTML output. * * @param value The option value, may be null to use the default style. */ public void setCssHref( String value ) { this.cssHref = value; } /** * Sets the option TEXT. * * @param value The option value, may be null to use the default value. */ public void setText( Boolean value ) { this.text = value; } /** * Sets the option BNF. * * @param value The option value, may be null to use the default value. */ public void setBnf( Boolean value ) { this.bnf = value; } /** * Sets the option value ONE_TABLE. * * @param value The option value, may be null to use the default value. */ public void setOneTable( Boolean value ) { this.oneTable = value; } /** * {@inheritDoc} */ protected int execute() throws Exception { String[] args = generateArguments(); File outputDirectory = ( this.outputFile != null ) ? this.outputFile.getParentFile() : null; if ( outputDirectory != null && !outputDirectory.exists() ) { outputDirectory.mkdirs(); } // fork jjdoc because of calls to System.exit() ForkedJvm jvm = new ForkedJvm(); jvm.setMainClass( org.javacc.jjdoc.JJDocMain.class ); jvm.addArguments( args ); jvm.setSystemOut( new MojoLogStreamConsumer( false ) ); jvm.setSystemErr( new MojoLogStreamConsumer( true ) ); if ( getLog().isDebugEnabled() ) { getLog().debug( "Forking: " + jvm ); } return jvm.run(); } /** * Assembles the command line arguments for the invocation of JJDoc according to the configuration. * * @return A string array that represents the arguments to use for JJDoc. */ private String[] generateArguments() { List argsList = new ArrayList(); if ( StringUtils.isNotEmpty( this.grammarEncoding ) ) { argsList.add( "-GRAMMAR_ENCODING=" + this.grammarEncoding ); } if ( this.text != null ) { argsList.add( "-TEXT=" + this.text ); } if ( this.bnf != null ) { argsList.add( "-BNF=" + this.bnf ); } if ( this.oneTable != null ) { argsList.add( "-ONE_TABLE=" + this.oneTable ); } if ( this.outputFile != null ) { argsList.add( "-OUTPUT_FILE=" + this.outputFile.getAbsolutePath() ); } if ( StringUtils.isNotEmpty( this.cssHref ) ) { argsList.add( "-CSS=" + this.cssHref ); } if ( this.inputFile != null ) { argsList.add( this.inputFile.getAbsolutePath() ); } return (String[]) argsList.toArray( new String[argsList.size()] ); } /** * Gets a string representation of the command line arguments. * * @return A string representation of the command line arguments. */ public String toString() { return Arrays.asList( generateArguments() ).toString(); } /** * Consume and log command line output from the JJDoc process. */ class MojoLogStreamConsumer implements StreamConsumer { /** * The line prefix used by JJDoc to report errors. */ private static final String ERROR_PREFIX = "Error: "; /** * The line prefix used by JJDoc to report warnings. */ private static final String WARN_PREFIX = "Warning: "; /** * Determines if the stream consumer is being used for System.out or System.err. */ private boolean err; /** * Single param constructor. * * @param error If set to true, all consumed lines will be logged at the error level. */ public MojoLogStreamConsumer( boolean error ) { this.err = error; } /** * Consume a line of text. * * @param line The line to consume. */ public void consumeLine( String line ) { if ( line.startsWith( ERROR_PREFIX ) ) { getLog().error( line.substring( ERROR_PREFIX.length() ) ); } else if ( line.startsWith( WARN_PREFIX ) ) { getLog().warn( line.substring( WARN_PREFIX.length() ) ); } else if ( this.err ) { getLog().error( line ); } else { getLog().debug( line ); } } } } javacc-maven-plugin-2.6/src/main/java/org/codehaus/mojo/javacc/LegacyGrammarDirectoryScanner.java0000644000175000017500000000327310753057643033035 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; /** * Scans source directories for JavaCC grammar files. This scanner supports {@link JJTreeMojo} and {@link JTBMojo} which * perform timestamp checking against copies of the input grammars rather than against the generated parser files. * Hence, the directory configured by {@link #setOutputDirectory(File)} is taken to be the output directory for the * timestamp files. * * @author Benjamin Bentmann * @version $Id: LegacyGrammarDirectoryScanner.java 6251 2008-02-08 13:56:51Z bentmann $ */ class LegacyGrammarDirectoryScanner extends GrammarDirectoryScanner { /** * {@inheritDoc} */ protected File[] getTargetFiles( File targetDirectory, String grammarFile, GrammarInfo grammarInfo ) { File timestampFile = new File( targetDirectory, grammarFile ); return new File[] { timestampFile }; } } javacc-maven-plugin-2.6/src/main/java/org/codehaus/mojo/javacc/JavaCCMojo.java0000644000175000017500000001303211113311543027010 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; /** * Parses a JavaCC grammar file (*.jj) and transforms it to Java source files. Detailed information * about the JavaCC options can be found on the JavaCC website. * * @goal javacc * @phase generate-sources * @since 2.0 * @author jruiz@exist.com * @author jesse * @version $Id: JavaCCMojo.java 8156 2008-11-26 18:20:19Z bentmann $ */ public class JavaCCMojo extends AbstractJavaCCMojo { /** * Package into which the generated classes will be put. Note that this will also be used to create the directory * structure where sources will be generated. Defaults to the package name specified in a grammar file. * * @parameter expression="${packageName}" * @deprecated As of version 2.4 because the plugin extracts the package name from each grammar file. */ private String packageName; /** * The directory where the JavaCC grammar files (*.jj) are located. * * @parameter expression="${sourceDirectory}" default-value="${basedir}/src/main/javacc" */ private File sourceDirectory; /** * The directory where the parser files generated by JavaCC will be stored. The directory will be registered as a * compile source root of the project such that the generated files will participate in later build phases like * compiling and packaging. * * @parameter expression="${outputDirectory}" default-value="${project.build.directory}/generated-sources/javacc" */ private File outputDirectory; /** * The granularity in milliseconds of the last modification date for testing whether a source needs recompilation. * * @parameter expression="${lastModGranularityMs}" default-value="0" */ private int staleMillis; /** * A set of Ant-like inclusion patterns used to select files from the source directory for processing. By default, * the patterns **/*.jj and **/*.JJ are used to select grammar files. * * @parameter */ private String[] includes; /** * A set of Ant-like exclusion patterns used to prevent certain files from being processed. By default, this set is * empty such that no files are excluded. * * @parameter */ private String[] excludes; /** * {@inheritDoc} */ protected File getSourceDirectory() { return this.sourceDirectory; } /** * {@inheritDoc} */ protected String[] getIncludes() { if ( this.includes != null ) { return this.includes; } else { return new String[] { "**/*.jj", "**/*.JJ" }; } } /** * {@inheritDoc} */ protected String[] getExcludes() { return this.excludes; } /** * {@inheritDoc} */ protected File getOutputDirectory() { return this.outputDirectory; } /** * {@inheritDoc} */ protected int getStaleMillis() { return this.staleMillis; } /** * {@inheritDoc} */ protected File[] getCompileSourceRoots() { return new File[] { getOutputDirectory() }; } /** * {@inheritDoc} */ protected String getParserPackage() { return this.packageName; } /** * {@inheritDoc} */ protected void processGrammar( GrammarInfo grammarInfo ) throws MojoExecutionException, MojoFailureException { File jjFile = grammarInfo.getGrammarFile(); File jjDirectory = jjFile.getParentFile(); File tempDirectory = getTempDirectory(); // setup output directory of parser file (*.java) generated by JavaCC File parserDirectory = new File( tempDirectory, "parser" ); // generate parser files JavaCC javacc = newJavaCC(); javacc.setInputFile( jjFile ); javacc.setOutputDirectory( parserDirectory ); javacc.run(); // copy parser files from JavaCC copyGrammarOutput( getOutputDirectory(), grammarInfo.getParserPackage(), parserDirectory, grammarInfo.getParserName() + "*" ); // copy source files which are next to grammar unless the grammar resides in an ordinary source root // (legacy support for custom sources) if ( !isSourceRoot( grammarInfo.getSourceDirectory() ) ) { copyGrammarOutput( getOutputDirectory(), grammarInfo.getParserPackage(), jjDirectory, "*" ); } deleteTempDirectory( tempDirectory ); } } javacc-maven-plugin-2.6/src/main/java/org/codehaus/mojo/javacc/JavaCC.java0000644000175000017500000004205211250747644026210 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.codehaus.plexus.util.StringUtils; /** * Provides a facade for the mojos to invoke JavaCC. * * @author Benjamin Bentmann * @version $Id: JavaCC.java 10603 2009-09-06 15:05:08Z bentmann $ * @see JavaCC Command Line Syntax */ class JavaCC extends ToolFacade { /** * The input grammar. */ private File inputFile; /** * The option OUTPUT_DIRECTORY. */ private File outputDirectory; /** * The option GRAMMAR_ENCODING. */ private String grammarEncoding; /** * The option JDK_VERSION. */ private String jdkVersion; /** * The option STATIC. */ private Boolean isStatic; /** * The option LOOK_AHEAD. */ private Integer lookAhead; /** * The option CHOICE_AMBIGUITY_CHECK. */ private Integer choiceAmbiguityCheck; /** * The option OTHER_AMBIGUITY_CHECK. */ private Integer otherAmbiguityCheck; /** * The option DEBUG_PARSER. */ private Boolean debugParser; /** * The option DEBUG_LOOK_AHEAD. */ private Boolean debugLookAhead; /** * The option DEBUG_TOKEN_MANAGER. */ private Boolean debugTokenManager; /** * The option ERROR_REPORTING. */ private Boolean errorReporting; /** * The option JAVA_UNICODE_ESCAPE. */ private Boolean javaUnicodeEscape; /** * The option UNICODE_INPUT. */ private Boolean unicodeInput; /** * The option IGNORE_CASE. */ private Boolean ignoreCase; /** * The option COMMON_TOKEN_ACTION. */ private Boolean commonTokenAction; /** * The option USER_TOKEN_MANAGER. */ private Boolean userTokenManager; /** * The option USER_CHAR_STREAM. */ private Boolean userCharStream; /** * The option BUILD_PARSER. */ private Boolean buildParser; /** * The option BUILD_TOKEN_MANAGER. */ private Boolean buildTokenManager; /** * The option TOKEN_MANAGER_USES_PARSER. */ private Boolean tokenManagerUsesParser; /** * The option TOKEN_EXTENDS. */ private String tokenExtends; /** * The option TOKEN_FACTORY. */ private String tokenFactory; /** * The option SANITY_CHECK. */ private Boolean sanityCheck; /** * The option FORCE_LA_CHECK. */ private Boolean forceLaCheck; /** * The option CACHE_TOKENS. */ private Boolean cacheTokens; /** * The option KEEP_LINE_COLUMN. */ private Boolean keepLineColumn; /** * The option SUPPORT_CLASS_VISIBILITY_PUBLIC. */ private Boolean supportClassVisibilityPublic; /** * Sets the absolute path to the grammar file to pass into JavaCC for compilation. * * @param value The absolute path to the grammar file to pass into JavaCC for compilation. */ public void setInputFile( File value ) { if ( value != null && !value.isAbsolute() ) { throw new IllegalArgumentException( "path is not absolute: " + value ); } this.inputFile = value; } /** * Sets the absolute path to the output directory. * * @param value The absolute path to the output directory for the generated parser file. If this directory does not * exist yet, it is created. Note that this path should already include the desired package hierarchy * because JavaCC will not append the required sub directories automatically. */ public void setOutputDirectory( File value ) { if ( value != null && !value.isAbsolute() ) { throw new IllegalArgumentException( "path is not absolute: " + value ); } this.outputDirectory = value; } /** * Sets the option GRAMMAR_ENCODING. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setGrammarEncoding( String value ) { this.grammarEncoding = value; } /** * Sets the option JDK_VERSION. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setJdkVersion( String value ) { this.jdkVersion = value; } /** * Sets the option STATIC. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setStatic( Boolean value ) { this.isStatic = value; } /** * Sets the option LOOK_AHEAD. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setLookAhead( Integer value ) { this.lookAhead = value; } /** * Sets the option CHOICE_AMBIGUITY_CHECK. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setChoiceAmbiguityCheck( Integer value ) { this.choiceAmbiguityCheck = value; } /** * Sets the option OTHER_AMBIGUITY_CHECK. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setOtherAmbiguityCheck( Integer value ) { this.otherAmbiguityCheck = value; } /** * Sets the option DEBUG_PARSER. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setDebugParser( Boolean value ) { this.debugParser = value; } /** * Sets the option DEBUG_LOOK_AHEAD. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setDebugLookAhead( Boolean value ) { this.debugLookAhead = value; } /** * Sets the option DEBUG_TOKEN_MANAGER. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setDebugTokenManager( Boolean value ) { this.debugTokenManager = value; } /** * Sets the option ERROR_REPORTING. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setErrorReporting( Boolean value ) { this.errorReporting = value; } /** * Sets the option JAVA_UNICODE_ESCAPE. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setJavaUnicodeEscape( Boolean value ) { this.javaUnicodeEscape = value; } /** * Sets the option UNICODE_INPUT. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setUnicodeInput( Boolean value ) { this.unicodeInput = value; } /** * Sets the option IGNORE_CASE. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setIgnoreCase( Boolean value ) { this.ignoreCase = value; } /** * Sets the option COMMON_TOKEN_ACTION. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setCommonTokenAction( Boolean value ) { this.commonTokenAction = value; } /** * Sets the option USER_TOKEN_MANAGER. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setUserTokenManager( Boolean value ) { this.userTokenManager = value; } /** * Sets the option USER_CHAR_STREAM. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setUserCharStream( Boolean value ) { this.userCharStream = value; } /** * Sets the option BUILD_PARSER. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setBuildParser( Boolean value ) { this.buildParser = value; } /** * Sets the option BUILD_TOKEN_MANAGER. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setBuildTokenManager( Boolean value ) { this.buildTokenManager = value; } /** * Sets the option TOKEN_MANAGER_USES_PARSER. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setTokenManagerUsesParser( Boolean value ) { this.tokenManagerUsesParser = value; } /** * Sets the option TOKEN_EXTENDS. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setTokenExtends( String value ) { this.tokenExtends = value; } /** * Sets the option TOKEN_FACTORY. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setTokenFactory( String value ) { this.tokenFactory = value; } /** * Sets the option SANITY_CHECK. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setSanityCheck( Boolean value ) { this.sanityCheck = value; } /** * Sets the option FORCE_LA_CHECK. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setForceLaCheck( Boolean value ) { this.forceLaCheck = value; } /** * Sets the option CACHE_TOKENS. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setCacheTokens( Boolean value ) { this.cacheTokens = value; } /** * Sets the option KEEP_LINE_COLUMN. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setKeepLineColumn( Boolean value ) { this.keepLineColumn = value; } /** * Sets the option SUPPORT_CLASS_VISIBILITY_PUBLIC. * * @param value The option value, may be null to use the value provided in the grammar or the default. */ public void setSupportClassVisibilityPublic( Boolean value ) { this.supportClassVisibilityPublic = value; } /** * {@inheritDoc} */ protected int execute() throws Exception { String[] args = generateArguments(); if ( this.outputDirectory != null && !this.outputDirectory.exists() ) { this.outputDirectory.mkdirs(); } return org.javacc.parser.Main.mainProgram( args ); } /** * Assembles the command line arguments for the invocation of JavaCC according to the configuration.

* Note: To prevent conflicts with JavaCC options that might be set directly in the grammar file, * only those parameters that have been explicitly set are passed on the command line. * * @return A string array that represents the command line arguments to use for JavaCC. */ private String[] generateArguments() { List argsList = new ArrayList(); if ( StringUtils.isNotEmpty( this.grammarEncoding ) ) { argsList.add( "-GRAMMAR_ENCODING=" + this.grammarEncoding ); } if ( StringUtils.isNotEmpty( this.jdkVersion ) ) { argsList.add( "-JDK_VERSION=" + this.jdkVersion ); } if ( this.lookAhead != null ) { argsList.add( "-LOOKAHEAD=" + this.lookAhead ); } if ( this.choiceAmbiguityCheck != null ) { argsList.add( "-CHOICE_AMBIGUITY_CHECK=" + this.choiceAmbiguityCheck ); } if ( this.otherAmbiguityCheck != null ) { argsList.add( "-OTHER_AMBIGUITY_CHECK=" + this.otherAmbiguityCheck ); } if ( this.isStatic != null ) { argsList.add( "-STATIC=" + this.isStatic ); } if ( this.debugParser != null ) { argsList.add( "-DEBUG_PARSER=" + this.debugParser ); } if ( this.debugLookAhead != null ) { argsList.add( "-DEBUG_LOOKAHEAD=" + this.debugLookAhead ); } if ( this.debugTokenManager != null ) { argsList.add( "-DEBUG_TOKEN_MANAGER=" + this.debugTokenManager ); } if ( this.errorReporting != null ) { argsList.add( "-ERROR_REPORTING=" + this.errorReporting ); } if ( this.javaUnicodeEscape != null ) { argsList.add( "-JAVA_UNICODE_ESCAPE=" + this.javaUnicodeEscape ); } if ( this.unicodeInput != null ) { argsList.add( "-UNICODE_INPUT=" + this.unicodeInput ); } if ( this.ignoreCase != null ) { argsList.add( "-IGNORE_CASE=" + this.ignoreCase ); } if ( this.commonTokenAction != null ) { argsList.add( "-COMMON_TOKEN_ACTION=" + this.commonTokenAction ); } if ( this.userTokenManager != null ) { argsList.add( "-USER_TOKEN_MANAGER=" + this.userTokenManager ); } if ( this.userCharStream != null ) { argsList.add( "-USER_CHAR_STREAM=" + this.userCharStream ); } if ( this.buildParser != null ) { argsList.add( "-BUILD_PARSER=" + this.buildParser ); } if ( this.buildTokenManager != null ) { argsList.add( "-BUILD_TOKEN_MANAGER=" + this.buildTokenManager ); } if ( this.tokenManagerUsesParser != null ) { argsList.add( "-TOKEN_MANAGER_USES_PARSER=" + this.tokenManagerUsesParser ); } if ( StringUtils.isNotEmpty( this.tokenExtends ) ) { argsList.add( "-TOKEN_EXTENDS=" + this.tokenExtends ); } if ( StringUtils.isNotEmpty( this.tokenFactory ) ) { argsList.add( "-TOKEN_FACTORY=" + this.tokenFactory ); } if ( this.sanityCheck != null ) { argsList.add( "-SANITY_CHECK=" + this.sanityCheck ); } if ( this.forceLaCheck != null ) { argsList.add( "-FORCE_LA_CHECK=" + this.forceLaCheck ); } if ( this.cacheTokens != null ) { argsList.add( "-CACHE_TOKENS=" + this.cacheTokens ); } if ( this.keepLineColumn != null ) { argsList.add( "-KEEP_LINE_COLUMN=" + this.keepLineColumn ); } if ( this.supportClassVisibilityPublic != null ) { argsList.add( "-SUPPORT_CLASS_VISIBILITY_PUBLIC=" + this.supportClassVisibilityPublic ); } if ( this.outputDirectory != null ) { argsList.add( "-OUTPUT_DIRECTORY=" + this.outputDirectory.getAbsolutePath() ); } if ( this.inputFile != null ) { argsList.add( this.inputFile.getAbsolutePath() ); } return (String[]) argsList.toArray( new String[argsList.size()] ); } /** * Gets a string representation of the command line arguments. * * @return A string representation of the command line arguments. */ public String toString() { return Arrays.asList( generateArguments() ).toString(); } } javacc-maven-plugin-2.6/src/main/java/org/codehaus/mojo/javacc/JTB.java0000644000175000017500000004645710767045631025554 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.cli.StreamConsumer; /** * Provides a facade for the mojos to invoke JTB. * * @author Benjamin Bentmann * @version $Id: JTB.java 6463 2008-03-15 22:20:09Z bentmann $ * @see Java Tree Builder */ class JTB extends ToolFacade { /** * The default package name for syntax tree files. */ private static final String SYNTAX_TREE = "syntaxtree"; /** * The default package name for visitor files. */ private static final String VISITOR = "visitor"; /** * The input grammar. */ private File inputFile; /** * The base directory for the option "-o". */ private File outputDirectory; /** * The output directory for the syntax tree files. */ private File nodeDirectory; /** * The output directory for the visitor files. */ private File visitorDirectory; /** * The option "-p". */ private String packageName; /** * The option "-np". */ private String nodePackageName; /** * The option "-vp". */ private String visitorPackageName; /** * The option "-e". */ private Boolean supressErrorChecking; /** * The option "-jd". */ private Boolean javadocFriendlyComments; /** * The option "-f". */ private Boolean descriptiveFieldNames; /** * The option "-ns". */ private String nodeParentClass; /** * The option "-pp". */ private Boolean parentPointers; /** * The option "-tk". */ private Boolean specialTokens; /** * The toolkit option "-scheme". */ private Boolean scheme; /** * The toolkit option "-printer". */ private Boolean printer; /** * Sets the absolute path to the grammar file to pass into JTB for preprocessing. * * @param value The absolute path to the grammar file to pass into JTB for preprocessing. */ public void setInputFile( File value ) { if ( value != null && !value.isAbsolute() ) { throw new IllegalArgumentException( "path is not absolute: " + value ); } this.inputFile = value; } /** * Sets the absolute path to the output directory for the generated grammar file. * * @param value The absolute path to the output directory for the generated grammar file. If this directory does not * exist yet, it is created. Note that this path should already include the desired package hierarchy * because JTB will not append the required sub directories automatically. */ public void setOutputDirectory( File value ) { if ( value != null && !value.isAbsolute() ) { throw new IllegalArgumentException( "path is not absolute: " + value ); } this.outputDirectory = value; } /** * Gets the absolute path to the enhanced grammar file generated by JTB. * * @return The absolute path to the enhanced grammar file generated by JTB or null if either the * input file or the output directory have not been set. */ public File getOutputFile() { File outputFile = null; if ( this.outputDirectory != null && this.inputFile != null ) { String fileName = FileUtils.removeExtension( this.inputFile.getName() ) + ".jj"; outputFile = new File( this.outputDirectory, fileName ); } return outputFile; } /** * Sets the absolute path to the output directory for the syntax tree files. * * @param value The absolute path to the output directory for the generated syntax tree files, may be * null to use a sub directory in the output directory of the grammar file. If this * directory does not exist yet, it is created. Note that this path should already include the desired * package hierarchy because JTB will not append the required sub directories automatically. */ public void setNodeDirectory( File value ) { if ( value != null && !value.isAbsolute() ) { throw new IllegalArgumentException( "path is not absolute: " + value ); } this.nodeDirectory = value; } /** * Gets the absolute path to the output directory for the syntax tree files. * * @return The absolute path to the output directory for the syntax tree files, only null if neither * {@link #outputDirectory} nor {@link #nodeDirectory} have been set. */ private File getEffectiveNodeDirectory() { if ( this.nodeDirectory != null ) { return this.nodeDirectory; } else if ( this.outputDirectory != null ) { return new File( this.outputDirectory, getLastPackageName( getEffectiveNodePackageName() ) ); } return null; } /** * Sets the absolute path to the output directory for the visitor files. * * @param value The absolute path to the output directory for the generated visitor files, may be null * to use a sub directory in the output directory of the grammar file. If this directory does not exist * yet, it is created. Note that this path should already include the desired package hierarchy because * JTB will not append the required sub directories automatically. */ public void setVisitorDirectory( File value ) { if ( value != null && !value.isAbsolute() ) { throw new IllegalArgumentException( "path is not absolute: " + value ); } this.visitorDirectory = value; } /** * Gets the absolute path to the output directory for the visitor files. * * @return The absolute path to the output directory for the visitor, only null if neither * {@link #outputDirectory} nor {@link #visitorDirectory} have been set. */ private File getEffectiveVisitorDirectory() { if ( this.visitorDirectory != null ) { return this.visitorDirectory; } else if ( this.outputDirectory != null ) { return new File( this.outputDirectory, getLastPackageName( getEffectiveVisitorPackageName() ) ); } return null; } /** * Sets the option "-p". Will overwrite the options "-np" and "-vp" if specified. * * @param value The option value, may be null. */ public void setPackageName( String value ) { this.packageName = value; } /** * Sets the option "-np". * * @param value The option value, may be null. */ public void setNodePackageName( String value ) { this.nodePackageName = value; } /** * Gets the effective package name for the syntax tree files. * * @return The effective package name for the syntax tree files, never null. */ private String getEffectiveNodePackageName() { if ( this.packageName != null ) { return ( this.packageName.length() <= 0 ) ? SYNTAX_TREE : this.packageName + '.' + SYNTAX_TREE; } else if ( this.nodePackageName != null ) { return this.nodePackageName; } else { return SYNTAX_TREE; } } /** * Sets the option "-vp". * * @param value The option value, may be null. */ public void setVisitorPackageName( String value ) { this.visitorPackageName = value; } /** * Gets the effective package name for the visitor files. * * @return The effective package name for the visitor files, never null. */ private String getEffectiveVisitorPackageName() { if ( this.packageName != null ) { return ( this.packageName.length() <= 0 ) ? VISITOR : this.packageName + '.' + VISITOR; } else if ( this.visitorPackageName != null ) { return this.visitorPackageName; } else { return VISITOR; } } /** * Sets the option "-e". * * @param value The option value, may be null. */ public void setSupressErrorChecking( Boolean value ) { this.supressErrorChecking = value; } /** * Sets the option "-jd". * * @param value The option value, may be null. */ public void setJavadocFriendlyComments( Boolean value ) { this.javadocFriendlyComments = value; } /** * Sets the option "-f". * * @param value The option value, may be null. */ public void setDescriptiveFieldNames( Boolean value ) { this.descriptiveFieldNames = value; } /** * Sets the option "-ns". * * @param value The option value, may be null. */ public void setNodeParentClass( String value ) { this.nodeParentClass = value; } /** * Sets the option "-pp". * * @param value The option value, may be null. */ public void setParentPointers( Boolean value ) { this.parentPointers = value; } /** * Sets the option "-tk". * * @param value The option value, may be null. */ public void setSpecialTokens( Boolean value ) { this.specialTokens = value; } /** * Sets the toolkit option "-scheme". * * @param value The option value, may be null. */ public void setScheme( Boolean value ) { this.scheme = value; } /** * Sets the toolkit option "-printer". * * @param value The option value, may be null. */ public void setPrinter( Boolean value ) { this.printer = value; } /** * {@inheritDoc} */ protected int execute() throws Exception { String[] args = generateArguments(); if ( this.outputDirectory != null && !this.outputDirectory.exists() ) { this.outputDirectory.mkdirs(); } // fork JTB because of its lack to re-initialize its static parser ForkedJvm jvm = new ForkedJvm(); jvm.setMainClass( "EDU.purdue.jtb.JTB" ); jvm.addArguments( args ); jvm.setSystemOut( new MojoLogStreamConsumer( false ) ); jvm.setSystemErr( new MojoLogStreamConsumer( true ) ); if ( getLog().isDebugEnabled() ) { getLog().debug( "Forking: " + jvm ); } int exitcode = jvm.run(); moveJavaFiles(); return exitcode; } /** * Assembles the command line arguments for the invocation of JTB according to the configuration. * * @return A string array that represents the command line arguments to use for JTB. */ private String[] generateArguments() { List argsList = new ArrayList(); argsList.add( "-np" ); argsList.add( getEffectiveNodePackageName() ); argsList.add( "-vp" ); argsList.add( getEffectiveVisitorPackageName() ); if ( this.supressErrorChecking != null && this.supressErrorChecking.booleanValue() ) { argsList.add( "-e" ); } if ( this.javadocFriendlyComments != null && this.javadocFriendlyComments.booleanValue() ) { argsList.add( "-jd" ); } if ( this.descriptiveFieldNames != null && this.descriptiveFieldNames.booleanValue() ) { argsList.add( "-f" ); } if ( this.nodeParentClass != null ) { argsList.add( "-ns" ); argsList.add( this.nodeParentClass ); } if ( this.parentPointers != null && this.parentPointers.booleanValue() ) { argsList.add( "-pp" ); } if ( this.specialTokens != null && this.specialTokens.booleanValue() ) { argsList.add( "-tk" ); } if ( this.scheme != null && this.scheme.booleanValue() ) { argsList.add( "-scheme" ); } if ( this.printer != null && this.printer.booleanValue() ) { argsList.add( "-printer" ); } File outputFile = getOutputFile(); if ( outputFile != null ) { argsList.add( "-o" ); argsList.add( outputFile.getAbsolutePath() ); } if ( this.inputFile != null ) { argsList.add( this.inputFile.getAbsolutePath() ); } return (String[]) argsList.toArray( new String[argsList.size()] ); } /** * Gets the last identifier from the specified package name. For example, returns "apache" upon input of * "org.apache". JTB uses this approach to derive the output directories for the visitor and syntax tree files. * * @param name The package name from which to retrieve the last sub package, may be null. * @return The name of the last sub package or null if the input was null */ private String getLastPackageName( String name ) { if ( name != null ) { return name.substring( name.lastIndexOf( '.' ) + 1 ); } return null; } /** * Moves the previously generated Java files to their proper target directories. JTB simply assumes that the current * working directory represents the parent package of the configured node/visitor packages which does not meet our * needs. * * @throws IOException If the move failed. */ private void moveJavaFiles() throws IOException { File nodeSrcDir = new File( getLastPackageName( getEffectiveNodePackageName() ) ).getAbsoluteFile(); File nodeDstDir = getEffectiveNodeDirectory(); moveDirectory( nodeSrcDir, nodeDstDir ); File visitorSrcDir = new File( getLastPackageName( getEffectiveVisitorPackageName() ) ).getAbsoluteFile(); File visitorDstDir = getEffectiveVisitorDirectory(); moveDirectory( visitorSrcDir, visitorDstDir ); } /** * Moves all Java files generated by JTB from the specified source directory to the given target directory. Existing * files in the target directory will be overwritten. Note that this move assumes a flat source directory, i.e. * copying of sub directories is not supported.

This method must be used instead of * {@link java.io.File#renameTo(java.io.File)} which would fail if the target directory already existed (at least on * Windows). * * @param sourceDir The absolute path to the source directory, must not be null. * @param targetDir The absolute path to the target directory, must not be null. * @throws IOException If the move failed. */ private void moveDirectory( File sourceDir, File targetDir ) throws IOException { getLog().debug( "Moving JTB output files: " + sourceDir + " -> " + targetDir ); /* * NOTE: The source directory might be the current working directory if JTB was told to output into the default * package. The current working directory might be quite anything and will likely contain sub directories not * created by JTB. Therefore, we do a defensive move and only delete the expected Java source files. */ File[] sourceFiles = sourceDir.listFiles(); if ( sourceFiles == null ) { return; } for ( int i = 0; i < sourceFiles.length; i++ ) { File sourceFile = sourceFiles[i]; if ( sourceFile.isFile() && sourceFile.getName().endsWith( ".java" ) ) { try { FileUtils.copyFileToDirectory( sourceFile, targetDir ); if ( !sourceFile.delete() ) { getLog().error( "Failed to delete original JTB output file: " + sourceFile ); } } catch ( Exception e ) { throw new IOException( "Failed to move JTB output file: " + sourceFile + " -> " + targetDir ); } } } if ( sourceDir.list().length <= 0 ) { if ( !sourceDir.delete() ) { getLog().error( "Failed to delete original JTB output directory: " + sourceDir ); } } else { getLog().debug( "Keeping non empty JTB output directory: " + sourceDir ); } } /** * Gets a string representation of the command line arguments. * * @return A string representation of the command line arguments. */ public String toString() { return Arrays.asList( generateArguments() ).toString(); } /** * Consume and log command line output from the JJDoc process. */ class MojoLogStreamConsumer implements StreamConsumer { /** * The line prefix used by JTB to report infos. */ private static final String INFO_PREFIX = "JTB: "; /** * Determines if the stream consumer is being used for System.out or System.err. */ private boolean err; /** * Single param constructor. * * @param error If set to true, all consumed lines will be logged at the error level. */ public MojoLogStreamConsumer( boolean error ) { this.err = error; } /** * Consume a line of text. * * @param line The line to consume. */ public void consumeLine( String line ) { if ( line.startsWith( "JTB version" ) ) { getLog().debug( line ); } else if ( line.startsWith( INFO_PREFIX ) ) { getLog().debug( line.substring( INFO_PREFIX.length() ) ); } else if ( this.err && line.length() > 0 ) { getLog().error( line ); } else { getLog().debug( line ); } } } } javacc-maven-plugin-2.6/src/main/resources/0000755000175000017500000000000011411772440020556 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/main/resources/NOTICE0000644000175000017500000000025510756563055021477 0ustar cavedoncavedonCodehaus Mojo javacc-maven-plugin Copyright 2001-2008 (C) The original author or authors. This product includes software developed at The Codehaus (http://codehaus.org/). javacc-maven-plugin-2.6/src/main/resources/jjdoc-report_de.properties0000644000175000017500000000211010741176350025743 0ustar cavedoncavedon# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # report.jjdoc.name=JJDoc Bericht report.jjdoc.title=JJDoc Bericht report.jjdoc.short.description=Dokumentation der JavaCC Grammatiken. report.jjdoc.description=Diese Seite bietet eine Übersicht der JJDoc Dokumentation zu den von JavaCC verarbeiteten Grammatiken. report.jjdoc.table.heading=Grammatikdatei javacc-maven-plugin-2.6/src/main/resources/jjdoc-report_en.properties0000644000175000017500000000230410741176350025762 0ustar cavedoncavedon# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # # NOTE: # This bundle is intentionally empty because English strings are provided by the base bundle via the parent chain. It # must be provided nevertheless such that a request for locale "en" will not errorneously pick up the bundle for the # JVM's default locale (which need not be "en"). See the method javadoc about # ResourceBundle.getBundle(String, Locale, ClassLoader) # for a full description of the lookup strategy. javacc-maven-plugin-2.6/src/main/resources/jjdoc-report.properties0000644000175000017500000000206710740505605025304 0ustar cavedoncavedon# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # report.jjdoc.name=JJDoc Report report.jjdoc.title=JJDoc Reports report.jjdoc.short.description=JavaCC grammar documentation. report.jjdoc.description=This page provides a list of the JJDoc reports that were generated for the JavaCC grammar files. report.jjdoc.table.heading=Grammar File javacc-maven-plugin-2.6/src/site/0000755000175000017500000000000011411772440016564 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/site/apt/0000755000175000017500000000000011411772440017350 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/site/apt/index.apt.vm0000644000175000017500000001126211113552622021605 0ustar cavedoncavedon ------ Introduction ------ Jesse McConnell Tim Pizey Paul Gier ------ February 09 2008 ------ ${project.name} This plugin uses the JavaCC parser generator to process JavaCC grammar files and generate the appropriate Java source files. For general information about JavaCC, see the {{{http://javacc.dev.java.net/} JavaCC}} web site. JavaCC grammar files use the extension <<<.jj>>>. This plugin can be used to locate and process all grammar files within a specified directory. Java source files will be written to a common generated-sources output directory, typically located in the build output directory. By default, the plugin will run during the <<>> phase, but it can be configured to run in other phases as well. The plugin can also be be used to call the JJTree and JTB tools. JJTree is a preprocessor for JavaCC that inserts parse tree building actions at various places in the JavaCC source. More information about JJTree can be found on the {{{https://javacc.dev.java.net/doc/JJTree.html} JJTree}} site. JTB (Java Tree Builder) is another syntax tree builder. Just like JJTree, it works as a preprocessor for JavaCC grammar files and inserts code to build syntax trees from a parsed input stream. More information about JTB in general and a feature comparison with JJTree can be found on the {{{http://compilers.cs.ucla.edu/jtb/} JTB}} web site. Finally, this plugin contains a goal for running JJDoc. JJDoc is a simple tool that generates {{{http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form} BNF}} documentation for the JavaCC grammar files. This can be used to generate a report for your project site using the Maven reporting tools. * {Goals} Overview The following goals are meant to participate in the default build lifecycle: * <<<{{{./javacc-mojo.html}javacc:javacc}}>>>\ Runs JavaCC on grammar files (<<<*.jj>>>) to generate a Java parser. * <<<{{{./jjtree-javacc-mojo.html}javacc:jjtree-javacc}}>>>\ Runs JJTree and JavaCC in a pipeline to process annotated grammar files (<<<*.jjt>>>). * <<<{{{./jjtree-mojo.html}javacc:jjtree}}>>>\ <> Preprocesses annotated grammar files (<<<*.jjt>>>) with JJTree. * <<<{{{./jtb-javacc-mojo.html}javacc:jtb-javacc}}>>>\ Runs JTB and JavaCC in a pipeline to process ordinary grammar files (<<<*.jtb>>>). * <<<{{{./jtb-mojo.html}javacc:jtb}}>>>\ <> Preprocesses ordinary grammar files (<<<*.jtb>>>) with JTB. [] This last goal is intended for usage with the site lifecycle: * <<<{{{./jjdoc-mojo.html}javacc:jjdoc}}>>>\ Generates BNF documentation from the grammar files for usage as a site report. * {Usage} General instructions on how to use the JavaCC Plugin can be found on the {{{usage.html}usage page}}. Some more specific use cases are described in the examples given below. Last but not least, users occasionally contribute additional examples, tips or errata to the {{{http://docs.codehaus.org/display/MAVENUSER/JavaCC+Plugin}plugin's wiki page}}. In case you still have questions regarding the plugin's usage, please have a look at the {{{faq.html}FAQ}} and feel free to contact the {{{mail-lists.html}user mailing list}}. The posts to the mailing list are archived and could already contain the answer to your question as part of an older thread. Hence, it is also worth browsing/searching the {{{mail-lists.html}mail archive}}. If you feel like the plugin is missing a feature or has a defect, you can fill a feature request or bug report in our {{{issue-tracking.html}issue tracker}}. When creating a new issue, please provide a comprehensive description of your concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem. For this reason, entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. Of course, patches are welcome, too. Contributors can check out the project from our {{{source-repository.html}source repository}} and will find supplementary information in the {{{http://mojo.codehaus.org/development/guidelines.html}development guidelines}}. * {Examples} To provide you with better understanding of some usages of the JavaCC Plugin, you can take a look into the following examples: * {{{./examples/example-javacc.html}Basic JavaCC Invocation}} * {{{./examples/example-jjtree.html}Preprocessing Grammars with JJTree}} * {{{./examples/example-jtb.html}Preprocessing Grammars with JTB}} * {{{./examples/example-jjdoc.html}Generating BNF Documentation using JJDoc}} javacc-maven-plugin-2.6/src/site/apt/usage.apt.vm0000644000175000017500000000622711113547772021621 0ustar cavedoncavedon ------ Usage ------ Paul Gier ------ January 04 2008 ------ Usage The JavaCC Plugin can both generate parsers from grammars and output a textual documentation of the grammars. The sections below should help you to get started. If you have problems using the plugin, please feel free to post your question to the {{{./mail-lists.html}user mailing list}}. * {Compiling Grammars into Parsers} By default, the <<<{{{./javacc-mojo.html}javacc}}>>> goal will search for grammar files in the directory <<<$\{basedir\}/src/main/javacc>>>. The <<<{{{./jjtree-javacc-mojo.html}jjtree-javacc}}>>> goal will expect to find <<<*.jjt>>> files in <<<$\{basedir\}/src/main/jjtree>>> and the <<<{{{./jtb-javacc-mojo.html}jtb-javacc}}>>> goal will expect to find <<<*.jtb>>> files in <<<$\{basedir\}/src/main/jtb>>>. Each of these can be configured to search other directories using the plugin configuration parameters as described in the respective goal documentation. The next step is to configure your POM to call the plugin. The goals will normally run during the <<>> phase of the build. Examples of how to configure your POM can be found on the various examples pages, reachable via the page menu. If you stick with the default values, the snippet below will suffice: ------------------- ... org.codehaus.mojo javacc-maven-plugin ${project.version} javacc javacc ... ... ------------------- Next run your build: +-----+ mvn generate-sources +-----+ For the <<>> goal, Java source files will be generated to the directory <<>> and this path will be added to your build as a source folder and automatically picked up by the next steps of the build (such as compilation). * {Creating BNF Documentation from Grammars} The <<<{{{./jjdoc-mojo.html}jjdoc}}>>> goal is a tool for generating a site report. If the JavaCC Maven Plugin is added to the reporting section of your POM, the <<>> goal will automatically be run when generating the project site. It will run the JJDoc tool once for each grammar file (<<<*.jj>>>) in your source directory. Each of these files, along with an index file containing a list of all the reports, will be created in the directory <<>>. A default configuration looks like this: ------------------- ... org.codehaus.mojo javacc-maven-plugin ${project.version} ... ... ------------------- After the plugin is added to the reporting section of the POM, just run the following command to create the BNF documentation: +-----+ mvn site +-----+ javacc-maven-plugin-2.6/src/site/apt/examples/0000755000175000017500000000000011411772440021166 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/site/apt/examples/example-jtb.apt.vm0000644000175000017500000000366311113547772024544 0ustar cavedoncavedon ------ JTB Examples ------ Paul Gier ------ January 04 2008 ------ JTB Examples If you want to use JavaCC in combination with JTB, simply copy the following snippet into your POM and adjust the goal configuration where the default values do not fit your needs. A list of all configuration options can be seen on the <<<{{{../jtb-javacc-mojo.html}jtb-javacc}}>>> goal page. ------------------- ... org.codehaus.mojo javacc-maven-plugin ${project.version} jtb-javacc jtb-javacc ... ... ... ------------------- If you know older versions of the plugin you might be glad to notice that you no longer need to setup two executions to have JTB and JavaCC run in a pipeline. The <<>> goal automatically runs both tools. Once the plugin is properly configured, you can generate the parser along with the tree nodes files by executing the <<>> lifecycle phase: +-----+ mvn generate-sources +-----+ Alternatively, you can invoke the <<>> goal directly from the command line, i.e. without having any other goals run that might be bound to lifecycle phases of your build: +-----+ mvn javacc:jtb-javacc +-----+ <> If you want to use the later call you need to put the <<<\>>> element directly into the <<<\>>> element. That is because the configuration inside the <<<\>>> element only applies if the goal is run as part of a lifecycle phase. javacc-maven-plugin-2.6/src/site/apt/examples/example-jjdoc.apt.vm0000644000175000017500000000147611113547772025056 0ustar cavedoncavedon ------ JJDoc Examples ------ Paul Gier ------ January 04 2008 ------ JJDoc Examples The following example can be used to create a JJDoc site report. For a list of configuration parameters, consult the <<<{{{../jjdoc-mojo.html}jjdoc}}>>> goal documentation. The <<>> goal does not need to be specified since it will automatically be used during site generation. ------------------- ... org.codehaus.mojo javacc-maven-plugin ${project.version} ... ... ------------------- To generate the BNF documentation, simply execute the site lifecycle phase: +-----+ mvn site +-----+ javacc-maven-plugin-2.6/src/site/apt/examples/example-javacc.apt.vm0000644000175000017500000000450411113547772025207 0ustar cavedoncavedon ------ JavaCC Examples ------ Paul Gier ------ January 04 2008 ------ JavaCC Examples This page provides examples of how to use the <<>> goal. * Basic Example This example shows how to pass parameters to JavaCC. A list of all configuration options can be seen on the <<<{{{../javacc-mojo.html}javacc}}>>> goal page. ------------------- ... org.codehaus.mojo javacc-maven-plugin ${project.version} javacc javacc 2 false ... ... ... ------------------- * Using Excludes and Includes Sometimes you may want to process some grammar files before others. In this case the <<<\>>> and <<<\>>> configuration options can be used. In the example below, all files in the source directory that end with <<<-step-1.jj>>> will be processed by JavaCC, and then all other <<<.jj>>> files will be processed. ------------------- ... org.codehaus.mojo javacc-maven-plugin ${project.version} javacc-step-1 javacc **/*-step-1.jj javacc-step-2 javacc **/*-step-1.jj ... ... ... ------------------- javacc-maven-plugin-2.6/src/site/apt/examples/example-jjtree.apt.vm0000644000175000017500000000373211113547772025245 0ustar cavedoncavedon ------ JJTree Examples ------ Paul Gier ------ January 04 2008 ------ JJTree Examples If you want to use JavaCC in combination with JJTree, simply copy the following snippet into your POM and adjust the goal configuration where the default values do not fit your needs. A list of all configuration options can be seen on the <<<{{{../jjtree-javacc-mojo.html}jjtree-javacc}}>>> goal page. ------------------- ... org.codehaus.mojo javacc-maven-plugin ${project.version} jjtree-javacc jjtree-javacc ... ... ... ------------------- If you know older versions of the plugin you might be glad to notice that you no longer need to setup two executions to have JJTree and JavaCC run in a pipeline. The <<>> goal automatically runs both tools. Once the plugin is properly configured, you can generate the parser along with the tree nodes files by executing the <<>> lifecycle phase: +-----+ mvn generate-sources +-----+ Alternatively, you can invoke the <<>> goal directly from the command line, i.e. without having any other goals run that might be bound to lifecycle phases of your build: +-----+ mvn javacc:jjtree-javacc +-----+ <> If you want to use the later call you need to put the <<<\>>> element directly into the <<<\>>> element. That is because the configuration inside the <<<\>>> element only applies if the goal is run as part of a lifecycle phase. javacc-maven-plugin-2.6/src/site/site.xml0000644000175000017500000000401411252707744020261 0ustar cavedoncavedon javacc-maven-plugin-2.6/src/site/fml/0000755000175000017500000000000011411772441017343 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/site/fml/faq.fml0000644000175000017500000000355711070224210020607 0ustar cavedoncavedon How can I use custom sources for some of the generated parser files?

If you have custom source files like a hand-crafted Token.java and want to use these files instead of the ones generated by JavaCC/JJTree/JTB, simply store your custom sources in the ordinary directory for Java sources, i.e. usually src/main/java. This will prevent the plugin from generating these files.

For plugin versions prior to 2.5, you will need to put any custom source files directly next to the grammar file instead. The plugin will then copy your sources to the output directory of the generated parser file such that they eventually make it onto your class path. This approach is still supported by newer plugin versions but not recommended.

javacc-maven-plugin-2.6/src/test/0000755000175000017500000000000011411772436016604 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/test/java/0000755000175000017500000000000011411772436017525 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/test/java/org/0000755000175000017500000000000011411772436020314 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/test/java/org/codehaus/0000755000175000017500000000000011411772436022107 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/test/java/org/codehaus/mojo/0000755000175000017500000000000011411772436023053 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/test/java/org/codehaus/mojo/javacc/0000755000175000017500000000000011411772436024302 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/test/java/org/codehaus/mojo/javacc/JavaCCTest.java0000644000175000017500000000455710751431357027107 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests JavaCC facade. * * @author Benjamin Bentmann * @version $Id: JavaCCTest.java 6198 2008-02-03 21:32:31Z bentmann $ */ public class JavaCCTest extends TestCase { public void testToStringNullSafe() throws Exception { JavaCC tool = new JavaCC(); String string = tool.toString(); assertNotNull( string ); assertTrue( string.indexOf( "null" ) < 0 ); } public void testSettersNullSafe() throws Exception { JavaCC tool = new JavaCC(); tool.setInputFile( null ); tool.setOutputDirectory( null ); tool.setJdkVersion( null ); tool.setStatic( null ); tool.setBuildParser( null ); tool.setBuildTokenManager( null ); tool.setCacheTokens( null ); tool.setChoiceAmbiguityCheck( null ); tool.setCommonTokenAction( null ); tool.setDebugLookAhead( null ); tool.setDebugParser( null ); tool.setDebugTokenManager( null ); tool.setErrorReporting( null ); tool.setForceLaCheck( null ); tool.setIgnoreCase( null ); tool.setJavaUnicodeEscape( null ); tool.setKeepLineColumn( null ); tool.setLookAhead( null ); tool.setOtherAmbiguityCheck( null ); tool.setSanityCheck( null ); tool.setTokenManagerUsesParser( null ); tool.setUnicodeInput( null ); tool.setUserCharStream( null ); tool.setUserTokenManager( null ); tool.setLog( null ); } } javacc-maven-plugin-2.6/src/test/java/org/codehaus/mojo/javacc/JJDocTest.java0000644000175000017500000000306710751431357026744 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests JJDoc facade. * * @author Benjamin Bentmann * @version $Id: JJDocTest.java 6198 2008-02-03 21:32:31Z bentmann $ */ public class JJDocTest extends TestCase { public void testToStringNullSafe() throws Exception { JJDoc tool = new JJDoc(); String string = tool.toString(); assertNotNull( string ); assertTrue( string.indexOf( "null" ) < 0 ); } public void testSettersNullSafe() throws Exception { JJDoc tool = new JJDoc(); tool.setInputFile( null ); tool.setOutputFile( null ); tool.setOneTable( null ); tool.setText( null ); tool.setLog( null ); } } javacc-maven-plugin-2.6/src/test/java/org/codehaus/mojo/javacc/GrammarInfoTest.java0000644000175000017500000001214410753435762030217 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.io.IOException; import java.net.URI; import junit.framework.TestCase; /** * Tests GrammarInfo. * * @author Benjamin Bentmann * @version $Id: GrammarInfoTest.java 6282 2008-02-09 23:49:06Z bentmann $ */ public class GrammarInfoTest extends TestCase { public void testInvalidFile() throws Exception { try { new GrammarInfo( new File( "" ).getAbsoluteFile(), "bad" ); fail( "Missing IO exception" ); } catch ( IOException e ) { // expected } } public void testGetGrammarFile() throws Exception { File grammarFile = getGrammar( "Parser1.jj" ); GrammarInfo info = new GrammarInfo( grammarFile.getParentFile(), grammarFile.getName() ); assertEquals( grammarFile, info.getGrammarFile() ); } public void testGetRelativeGrammarFile() throws Exception { File grammarFile = getGrammar( "Parser1.jj" ); GrammarInfo info = new GrammarInfo( grammarFile.getParentFile(), grammarFile.getName() ); assertEquals( grammarFile.getName(), info.getRelativeGrammarFile() ); } public void testGetPackageNameDeclaredPackageOverwrite() throws Exception { File grammarFile = getGrammar( "Parser1.jj" ); GrammarInfo info = new GrammarInfo( grammarFile.getParentFile(), grammarFile.getName(), "org.test" ); assertEquals( "org.test", info.getParserPackage() ); } public void testGetPackageNameDeclaredPackage() throws Exception { GrammarInfo info = newGrammarInfo( "Parser1.jj" ); assertEquals( "org.codehaus.mojo.javacc.test", info.getParserPackage() ); } public void testGetPackageNameDefaultPackage() throws Exception { GrammarInfo info = newGrammarInfo( "Parser2.jj" ); assertEquals( "", info.getParserPackage() ); } public void testGetPackageDirectoryDeclaredPackage() throws Exception { GrammarInfo info = newGrammarInfo( "Parser1.jj" ); assertEquals( new File( "org/codehaus/mojo/javacc/test" ).getPath(), info.getParserDirectory() ); } public void testGetPackageDirectoryDefaultPackage() throws Exception { GrammarInfo info = newGrammarInfo( "Parser2.jj" ); assertEquals( new File( "" ).getPath(), info.getParserDirectory() ); } public void testGetParserName() throws Exception { GrammarInfo info = newGrammarInfo( "Parser1.jj" ); assertEquals( "BasicParser", info.getParserName() ); } public void testGetParserFileDeclaredPackage() throws Exception { GrammarInfo info = newGrammarInfo( "Parser1.jj" ); assertEquals( new File( "org/codehaus/mojo/javacc/test/BasicParser.java" ).getPath(), info.getParserFile() ); } public void testGetParserFileDefaultPackage() throws Exception { GrammarInfo info = newGrammarInfo( "Parser2.jj" ); assertEquals( new File( "SimpleParser.java" ).getPath(), info.getParserFile() ); } public void testResolvePackageNameDeclaredPackage() throws Exception { GrammarInfo info = newGrammarInfo( "Parser1.jj" ); assertEquals( "org.codehaus.mojo.javacc.test.node", info.resolvePackageName( "*.node" ) ); assertEquals( "org.codehaus.mojo.javacc.testnode", info.resolvePackageName( "*node" ) ); assertEquals( "node", info.resolvePackageName( "node" ) ); } public void testResolvePackageNameDefaultPackage() throws Exception { GrammarInfo info = newGrammarInfo( "Parser2.jj" ); assertEquals( "node", info.resolvePackageName( "*.node" ) ); assertEquals( "node", info.resolvePackageName( "*node" ) ); assertEquals( "node", info.resolvePackageName( "node" ) ); } private GrammarInfo newGrammarInfo( String resource ) throws Exception { File grammarFile = getGrammar( resource ); File sourceDir = grammarFile.getParentFile(); return new GrammarInfo( sourceDir, grammarFile.getName() ); } private File getGrammar( String resource ) throws Exception { return new File( new URI( getClass().getResource( '/' + resource ).toString() ) ); } } javacc-maven-plugin-2.6/src/test/java/org/codehaus/mojo/javacc/JJTreeTest.java0000644000175000017500000000457110753417337027143 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import junit.framework.TestCase; /** * Tests JJTree facade. * * @author Benjamin Bentmann * @version $Id: JJTreeTest.java 6281 2008-02-09 21:45:03Z bentmann $ */ public class JJTreeTest extends TestCase { public void testToStringNullSafe() throws Exception { JJTree tool = new JJTree(); String string = tool.toString(); assertNotNull( string ); assertTrue( string.indexOf( "null" ) < 0 ); } public void testSettersNullSafe() throws Exception { JJTree tool = new JJTree(); tool.setInputFile( null ); tool.setOutputDirectory( null ); tool.setJdkVersion( null ); tool.setStatic( null ); tool.setBuildNodeFiles( null ); tool.setMulti( null ); tool.setNodeDefaultVoid( null ); tool.setNodeFactory( null ); tool.setNodePackage( null ); tool.setNodePrefix( null ); tool.setNodeScopeHook( null ); tool.setNodeUsesParser( null ); tool.setVisitor( null ); tool.setVisitorException( null ); tool.setLog( null ); } public void testGetOutputFile() throws Exception { File input = new File( "Test.jjt" ).getAbsoluteFile(); File outdir = new File( "dir" ).getAbsoluteFile(); JJTree tool = new JJTree(); tool.setInputFile( input ); tool.setOutputDirectory( outdir ); File output = tool.getOutputFile(); assertEquals( new File( outdir, "Test.jj" ), output ); } } javacc-maven-plugin-2.6/src/test/java/org/codehaus/mojo/javacc/ForkedJvmTest.java0000644000175000017500000000735311134054525027676 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer; import junit.framework.TestCase; /** * Tests ForkedJvm. * * @author Benjamin Bentmann * @version $Id: ForkedJvmTest.java 8698 2009-01-16 09:54:29Z bentmann $ */ public class ForkedJvmTest extends TestCase { public void testToStringNullSafe() throws Exception { ForkedJvm jvm = new ForkedJvm(); String string = jvm.toString(); assertNotNull( string ); assertTrue( string.indexOf( "null" ) < 0 ); } public void testSettersNullSafe() throws Exception { ForkedJvm jvm = new ForkedJvm(); jvm.addArgument( (File) null ); jvm.addArgument( (String) null ); jvm.addArguments( null ); jvm.addArguments( new String[] { null } ); jvm.addClassPathEntry( (Class) null ); jvm.addClassPathEntry( (File) null ); jvm.addClassPathEntry( (String) null ); jvm.setMainClass( (Class) null ); jvm.setMainClass( (String) null ); jvm.setWorkingDirectory( null ); jvm.setSystemOut( null ); jvm.setSystemErr( null ); } public void testSetMainClass() throws Exception { ForkedJvm jvm1 = new ForkedJvm(); jvm1.setMainClass( MainStub.class ); String cmd1 = jvm1.toString(); assertTrue( cmd1.indexOf( MainStub.class.getName() ) >= 0 ); ForkedJvm jvm2 = new ForkedJvm(); jvm2.setMainClass( MainStub.class.getName() ); String cmd2 = jvm2.toString(); assertTrue( cmd2.indexOf( MainStub.class.getName() ) >= 0 ); assertEquals( cmd1, cmd2 ); } public void testFork() throws Exception { File workDir = new File( System.getProperty( "user.home" ) ).getCanonicalFile(); File file = new File( "test" ).getAbsoluteFile(); String nonce = Integer.toString( hashCode() ); StringStreamConsumer stdout = new StringStreamConsumer(); StringStreamConsumer stderr = new StringStreamConsumer(); ForkedJvm jvm = new ForkedJvm(); jvm.setWorkingDirectory( workDir ); jvm.setSystemOut( stdout ); jvm.setSystemErr( stderr ); jvm.setMainClass( MainStub.class ); jvm.addArgument( nonce ); jvm.addArguments( new String[] { "arg1", "arg2" } ); jvm.addArgument( file ); System.out.println( "Forking: " + jvm ); int exitcode = jvm.run(); String out = stdout.getOutput(); String err = stderr.getOutput(); String[] args = out.split( "(\r\n)|(\r)|(\n)" ); assertEquals( 27, exitcode ); assertEquals( workDir, new File( err.trim() ) ); assertEquals( 4, args.length ); assertEquals( nonce, args[0] ); assertEquals( "arg1", args[1] ); assertEquals( "arg2", args[2] ); assertEquals( file, new File( args[3] ) ); } } javacc-maven-plugin-2.6/src/test/java/org/codehaus/mojo/javacc/UrlUtilsTest.java0000644000175000017500000001323411017634224027565 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.net.URL; import junit.framework.TestCase; /** * Tests UrlUtils. * * @author Benjamin Bentmann * @version $Id: UrlUtilsTest.java 7083 2008-05-29 23:13:24Z bentmann $ */ public class UrlUtilsTest extends TestCase { public void testGetResourceRootFileWin() throws Exception { assertMatch( "/C:/a dir", "file:/C:/a%20dir/org/Foo.class", "org/Foo.class" ); assertMatch( "/C:/a dir", "file://localhost/C:/a%20dir/org/Foo.class", "org/Foo.class" ); assertMatch( "/C:/a dir", "file:///C:/a%20dir/org/Foo.class", "org/Foo.class" ); assertMatch( "/C:/a dir", "file:/C:/a%20dir/org/Foo.class", "/org/Foo.class" ); assertMatch( "/C:/a dir", "file:/C:/a dir/org/Foo.class", "org/Foo.class" ); } public void testGetResourceRootJarFileWin() throws Exception { assertMatch( "/C:/a dir/t-1.jar", "jar:file:/C:/a%20dir/t-1.jar!/org/Foo.class", "org/Foo.class" ); assertMatch( "/C:/a dir/t-1.jar", "jar:file://localhost/C:/a%20dir/t-1.jar!/org/Foo.class", "org/Foo.class" ); assertMatch( "/C:/a dir/t-1.jar", "jar:file:///C:/a%20dir/t-1.jar!/org/Foo.class", "org/Foo.class" ); assertMatch( "/C:/a dir/t-1.jar", "jar:file:/C:/a%20dir/t-1.jar!/org/Foo.class", "/org/Foo.class" ); assertMatch( "/C:/a dir/t-1.jar", "jar:file:/C:/a dir/t-1.jar!/org/Foo.class", "org/Foo.class" ); } public void testGetResourceRootFileWinUnc() throws Exception { assertMatch( "//host/a dir", "file:////host/a%20dir/org/Foo.class", "org/Foo.class" ); } public void testGetResourceRootJarFileWinUnc() throws Exception { assertMatch( "//host/a dir/t-1.jar", "jar:file:////host/a%20dir/t-1.jar!/org/Foo.class", "org/Foo.class" ); } public void testGetResourceRootFileUnix() throws Exception { assertMatch( "/home/a dir", "file:/home/a%20dir/org/Foo.class", "org/Foo.class" ); assertMatch( "/home/a dir", "file://localhost/home/a%20dir/org/Foo.class", "org/Foo.class" ); assertMatch( "/home/a dir", "file:///home/a%20dir/org/Foo.class", "org/Foo.class" ); assertMatch( "/home/a dir", "file:/home/a%20dir/org/Foo.class", "/org/Foo.class" ); assertMatch( "/home/a dir", "file:/home/a dir/org/Foo.class", "org/Foo.class" ); } public void testGetResourceRootJarFileUnix() throws Exception { assertMatch( "/home/a dir/t-1.jar", "jar:file:/home/a%20dir/t-1.jar!/org/Foo.class", "org/Foo.class" ); assertMatch( "/home/a dir/t-1.jar", "jar:file://localhost/home/a%20dir/t-1.jar!/org/Foo.class", "org/Foo.class" ); assertMatch( "/home/a dir/t-1.jar", "jar:file:///home/a%20dir/t-1.jar!/org/Foo.class", "org/Foo.class" ); assertMatch( "/home/a dir/t-1.jar", "jar:file:/home/a%20dir/t-1.jar!/org/Foo.class", "/org/Foo.class" ); assertMatch( "/home/a dir/t-1.jar", "jar:file:/home/a dir/t-1.jar!/org/Foo.class", "org/Foo.class" ); } public void testGetResourceRootNullSafe() throws Exception { assertNull( UrlUtils.getResourceRoot( null, "" ) ); } public void testGetResourceRootUnknownProtocal() throws Exception { try { UrlUtils.getResourceRoot( new URL( "http://www.foo.bar/index.html" ), "index.html" ); fail( "Missing runtime exception" ); } catch ( RuntimeException e ) { assertTrue( true ); } } private void assertMatch( String expectedFile, String url, String resource ) throws Exception { assertEquals( new File( expectedFile ), UrlUtils.getResourceRoot( new URL( url ), resource ) ); } public void testDecodeUrl() { assertEquals( "", UrlUtils.decodeUrl( "" ) ); assertEquals( "foo", UrlUtils.decodeUrl( "foo" ) ); assertEquals( "+", UrlUtils.decodeUrl( "+" ) ); assertEquals( "% ", UrlUtils.decodeUrl( "%25%20" ) ); assertEquals( "%20", UrlUtils.decodeUrl( "%2520" ) ); assertEquals( "jar:file:/C:/dir/sub dir/1.0/foo-1.0.jar!/org/Bar.class", UrlUtils.decodeUrl( "jar:file:/C:/dir/sub%20dir/1.0/foo-1.0.jar!/org/Bar.class" ) ); } public void testDecodeUrlLenient() { assertEquals( " ", UrlUtils.decodeUrl( " " ) ); assertEquals( "\u00E4\u00F6\u00FC\u00DF", UrlUtils.decodeUrl( "\u00E4\u00F6\u00FC\u00DF" ) ); assertEquals( "%", UrlUtils.decodeUrl( "%" ) ); assertEquals( "%2", UrlUtils.decodeUrl( "%2" ) ); assertEquals( "%2G", UrlUtils.decodeUrl( "%2G" ) ); } public void testDecodeUrlNullSafe() { assertNull( UrlUtils.decodeUrl( null ) ); } public void testDecodeUrlEncodingUtf8() { assertEquals( "\u00E4\u00F6\u00FC\u00DF", UrlUtils.decodeUrl( "%C3%A4%C3%B6%C3%BC%C3%9F" ) ); } } javacc-maven-plugin-2.6/src/test/java/org/codehaus/mojo/javacc/JTBTest.java0000644000175000017500000000466410753417337026442 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import junit.framework.TestCase; /** * Tests JTB facade. * * @author Benjamin Bentmann * @version $Id: JTBTest.java 6281 2008-02-09 21:45:03Z bentmann $ */ public class JTBTest extends TestCase { public void testToStringNullSafe() throws Exception { JTB tool = new JTB(); String string = tool.toString(); assertNotNull( string ); assertTrue( string.indexOf( "null" ) < 0 ); } public void testSettersNullSafe() throws Exception { JTB tool = new JTB(); tool.setInputFile( null ); tool.setOutputDirectory( null ); tool.setNodeDirectory( null ); tool.setVisitorDirectory( null ); tool.setDescriptiveFieldNames( null ); tool.setJavadocFriendlyComments( null ); tool.setNodePackageName( null ); tool.setNodeParentClass( null ); tool.setPackageName( null ); tool.setParentPointers( null ); tool.setPrinter( null ); tool.setScheme( null ); tool.setSpecialTokens( null ); tool.setSupressErrorChecking( null ); tool.setVisitorPackageName( null ); tool.setLog( null ); } public void testGetOutputFile() throws Exception { File input = new File( "Test.jtb" ).getAbsoluteFile(); File outdir = new File( "dir" ).getAbsoluteFile(); JTB tool = new JTB(); tool.setInputFile( input ); tool.setOutputDirectory( outdir ); File output = tool.getOutputFile(); assertEquals( new File( outdir, "Test.jj" ), output ); } } javacc-maven-plugin-2.6/src/test/java/org/codehaus/mojo/javacc/MainStub.java0000644000175000017500000000240410752135053026662 0ustar cavedoncavedonpackage org.codehaus.mojo.javacc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Supports {@link ForkedJvmTest}. * * @author Benjamin Bentmann * @version $Id: MainStub.java 6212 2008-02-05 19:34:03Z bentmann $ */ public class MainStub { public static void main( String[] args ) { for ( int i = 0; i < args.length; i++ ) { System.out.println( args[i] ); } System.err.println( System.getProperty( "user.dir" ) ); System.exit( 27 ); } } javacc-maven-plugin-2.6/src/test/resources/0000755000175000017500000000000011411772436020616 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/test/resources/Parser2.jj0000644000175000017500000000077210747643633022476 0ustar cavedoncavedon options { LOOKAHEAD = 1; CHOICE_AMBIGUITY_CHECK = 2; OTHER_AMBIGUITY_CHECK = 1; STATIC = true; DEBUG_PARSER = false; } PARSER_BEGIN(SimpleParser) // use default package public class SimpleParser { public static void main(String args[]) throws ParseException { SimpleParser parser = new SimpleParser(System.in); parser.Input(); } } PARSER_END(SimpleParser) void Input() : {} { MatchedBraces() ("\n"|"\r")* } void MatchedBraces() : {} { "{" [ MatchedBraces() ] "}" } javacc-maven-plugin-2.6/src/test/resources/Parser1.jj0000644000175000017500000000100510747643633022463 0ustar cavedoncavedon options { LOOKAHEAD = 1; CHOICE_AMBIGUITY_CHECK = 2; OTHER_AMBIGUITY_CHECK = 1; STATIC = true; DEBUG_PARSER = false; } PARSER_BEGIN(BasicParser) package org.codehaus.mojo.javacc.test; public class BasicParser { public static void main(String args[]) throws ParseException { BasicParser parser = new BasicParser(System.in); parser.Input(); } } PARSER_END(BasicParser) void Input() : {} { MatchedBraces() ("\n"|"\r")* } void MatchedBraces() : {} { "{" [ MatchedBraces() ] "}" } javacc-maven-plugin-2.6/src/it/0000755000175000017500000000000011411772447016243 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-javacc-custom-source-files/0000755000175000017500000000000011411772450024653 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-javacc-custom-source-files/src/0000755000175000017500000000000011411772447025450 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-javacc-custom-source-files/src/main/0000755000175000017500000000000011411772447026374 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-javacc-custom-source-files/src/main/java/0000755000175000017500000000000011411772447027315 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-javacc-custom-source-files/src/main/java/org/0000755000175000017500000000000011411772447030104 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-javacc-custom-source-files/src/main/java/org/Token.java0000644000175000017500000000155711072152564032032 0ustar cavedoncavedon/* CUSTOMIZED PARSER FILE - MUST NOT BE OVERWRITTEN BY JAVACC */ package org; public class Token { public int kind; public int beginLine, beginColumn, endLine, endColumn; public String image; public Token next; public Token specialToken; public Token() { } public Token( int kind ) { this( kind, null ); } public Token( int kind, String image ) { this.kind = kind; this.image = image; } public Object getValue() { return null; } public String toString() { return image; } public static Token newToken( int ofKind, String image ) { switch ( ofKind ) { default : return new Token( ofKind, image ); } } public static Token newToken( int ofKind ) { return newToken( ofKind, null ); } } javacc-maven-plugin-2.6/src/it/jjtree-javacc-custom-source-files/src/main/jjtree/0000755000175000017500000000000011411772447027657 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-javacc-custom-source-files/src/main/jjtree/Simple.jjt0000644000175000017500000000303011070224210031572 0ustar cavedoncavedonPARSER_BEGIN(Simple) package org; class Simple { public static void main(String args[]) { System.out.println("Reading from standard input..."); Simple t = new Simple(System.in); try { SimpleNode n = t.Start(); n.dump(""); System.out.println("Thank you."); } catch (Exception e) { System.out.println("Oops."); System.out.println(e.getMessage()); e.printStackTrace(); } } } PARSER_END(Simple) SKIP : { " " | "\t" | "\n" | "\r" | <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")> | <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/"> } TOKEN : /* LITERALS */ { < INTEGER_LITERAL: (["l","L"])? | (["l","L"])? | (["l","L"])? > | < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* > | < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > | < #OCTAL_LITERAL: "0" (["0"-"7"])* > } TOKEN : /* IDENTIFIERS */ { < IDENTIFIER: (|)* > | < #LETTER: ["_","a"-"z","A"-"Z"] > | < #DIGIT: ["0"-"9"] > } SimpleNode Start() : {} { Expression() ";" { return jjtThis; } } void Expression() : {} { AdditiveExpression() } void AdditiveExpression() : {} { MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )* } void MultiplicativeExpression() : {} { UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )* } void UnaryExpression() : {} { "(" Expression() ")" | Identifier() | Integer() } void Identifier() : {} { } void Integer() : {} { } javacc-maven-plugin-2.6/src/it/jjtree-javacc-custom-source-files/verify.bsh0000644000175000017500000000071111070224210026637 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File file = new File( basedir, "target/generated-sources/javacc/org/codehaus/javacc/simple/Token.java" ); System.out.println( "Checking for absence of customized java file: " + file ); if ( file.exists() ) { System.err.println( "FAILED!" ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/jjtree-javacc-custom-source-files/invoker.properties0000644000175000017500000000003611070224210030430 0ustar cavedoncavedoninvoker.goals = clean compile javacc-maven-plugin-2.6/src/it/jjtree-javacc-custom-source-files/pom.xml0000644000175000017500000000213611250317142026164 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check handling of custom source files in existing compile source roots (MJAVACC-87). org.codehaus.mojo javacc-maven-plugin @pom.version@ 1.4 jjtree-javacc jjtree-javacc javacc-maven-plugin-2.6/src/it/jtb-path-with-spaces/0000755000175000017500000000000011411772442022174 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-path-with-spaces/verify.bsh0000644000175000017500000000137010753140153024173 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File targetDir = new File( basedir, "target" ); if ( !targetDir.isDirectory() ) { System.err.println( "Missing output directory: " + targetDir ); return false; } File outFile = new File( targetDir, "j t b/org/SubScheme.jj" ); if ( !outFile.isFile() ) { System.err.println( "Missing JTB output file: " + outFile ); return false; } File tsFile = new File( targetDir, "j t b ts/SubScheme.jtb" ); if ( !tsFile.isFile() ) { System.err.println( "Missing JTB timestamp file: " + tsFile ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/jtb-path-with-spaces/invoker.properties0000644000175000017500000000007211257375102025766 0ustar cavedoncavedoninvoker.goals = clean compile invoker.java.version = 1.5+ javacc-maven-plugin-2.6/src/it/jtb-path-with-spaces/sour ces/0000755000175000017500000000000011411772442023717 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-path-with-spaces/sour ces/jtb/0000755000175000017500000000000011411772442024476 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-path-with-spaces/sour ces/jtb/SubScheme.jtb0000644000175000017500000000204410753140153027051 0ustar cavedoncavedonPARSER_BEGIN(SubScheme) package org; import org.visitor.DepthFirstVisitor; public class SubScheme { public static void main(String args[]) { SubScheme parser; System.out.println("Reading from standard input. . ."); parser = new SubScheme(System.in); try { Node root = parser.Unit(); System.out.println("Parsed successfully."); root.accept(new DepthFirstVisitor()); } catch (ParseException e) { System.out.println(e.getMessage()); System.out.println("Encountered errors during parse."); } } } PARSER_END(SubScheme) SKIP : /* WHITE SPACE */ { " " | "\t" | "\n" | "\r" | "\f" } TOKEN : { < LAMBDA : "lambda" > | < IDENT : (|)* > | < #LETTER: ["_","a"-"z","A"-"Z"] > | < #DIGIT : ["0"-"9"] > } void Unit() : {} { ( Exp() )+ } void Exp() : {} { | LOOKAHEAD(2) LambdaDecl() | LOOKAHEAD(2) "(" Exp() ( Exp() )* ")" | "0" | "(" "+" Exp() "1" ")" } void LambdaDecl() : {} { "(" "lambda" "(" ( )* ")" Exp() ")" } javacc-maven-plugin-2.6/src/it/jtb-path-with-spaces/pom.xml0000644000175000017500000000276510753140153023517 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check handling of paths with spaces. org.codehaus.mojo javacc-maven-plugin @pom.version@ jtb jtb sour ces/jtb target/j t b target/j t b ts org maven-compiler-plugin 2.0.2 1.5 1.5 javacc-maven-plugin-2.6/src/it/jjtree-path-with-spaces/0000755000175000017500000000000011411772447022705 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-path-with-spaces/verify.bsh0000644000175000017500000000137410753140153024703 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File targetDir = new File( basedir, "target" ); if ( !targetDir.isDirectory() ) { System.err.println( "Missing output directory: " + targetDir ); return false; } File outFile = new File( targetDir, "jj tree/org/Simple.jj" ); if ( !outFile.isFile() ) { System.err.println( "Missing JJTree output file: " + outFile ); return false; } File tsFile = new File( targetDir, "jj tree ts/Simple.jjt" ); if ( !tsFile.isFile() ) { System.err.println( "Missing JJTree timestamp file: " + tsFile ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/jjtree-path-with-spaces/invoker.properties0000644000175000017500000000003611020310351026451 0ustar cavedoncavedoninvoker.goals = clean compile javacc-maven-plugin-2.6/src/it/jjtree-path-with-spaces/sour ces/0000755000175000017500000000000011411772446024427 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-path-with-spaces/sour ces/jjtree/0000755000175000017500000000000011411772447025713 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-path-with-spaces/sour ces/jjtree/Simple.jjt0000644000175000017500000000303010753140153027640 0ustar cavedoncavedonPARSER_BEGIN(Simple) package org; class Simple { public static void main(String args[]) { System.out.println("Reading from standard input..."); Simple t = new Simple(System.in); try { SimpleNode n = t.Start(); n.dump(""); System.out.println("Thank you."); } catch (Exception e) { System.out.println("Oops."); System.out.println(e.getMessage()); e.printStackTrace(); } } } PARSER_END(Simple) SKIP : { " " | "\t" | "\n" | "\r" | <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")> | <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/"> } TOKEN : /* LITERALS */ { < INTEGER_LITERAL: (["l","L"])? | (["l","L"])? | (["l","L"])? > | < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* > | < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > | < #OCTAL_LITERAL: "0" (["0"-"7"])* > } TOKEN : /* IDENTIFIERS */ { < IDENTIFIER: (|)* > | < #LETTER: ["_","a"-"z","A"-"Z"] > | < #DIGIT: ["0"-"9"] > } SimpleNode Start() : {} { Expression() ";" { return jjtThis; } } void Expression() : {} { AdditiveExpression() } void AdditiveExpression() : {} { MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )* } void MultiplicativeExpression() : {} { UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )* } void UnaryExpression() : {} { "(" Expression() ")" | Identifier() | Integer() } void Identifier() : {} { } void Integer() : {} { } javacc-maven-plugin-2.6/src/it/jjtree-path-with-spaces/pom.xml0000644000175000017500000000231310753140153024210 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check handling of paths with spaces. org.codehaus.mojo javacc-maven-plugin @pom.version@ jjtree jjtree sour ces/jjtree target/jj tree target/jj tree ts javacc-maven-plugin-2.6/src/it/javacc-custom-parser-files/0000755000175000017500000000000011411772446023373 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-custom-parser-files/src/0000755000175000017500000000000011411772446024162 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-custom-parser-files/src/main/0000755000175000017500000000000011411772446025106 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-custom-parser-files/src/main/javacc/0000755000175000017500000000000011411772446026335 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-custom-parser-files/src/main/javacc/org/0000755000175000017500000000000011411772446027124 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-custom-parser-files/src/main/javacc/org/codehaus/0000755000175000017500000000000011411772446030717 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-custom-parser-files/src/main/javacc/org/codehaus/javacc/0000755000175000017500000000000011411772446032146 5ustar cavedoncavedon././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootjavacc-maven-plugin-2.6/src/it/javacc-custom-parser-files/src/main/javacc/org/codehaus/javacc/simple/javacc-maven-plugin-2.6/src/it/javacc-custom-parser-files/src/main/javacc/org/codehaus/javacc/simple0000755000175000017500000000000011411772446033360 5ustar cavedoncavedon././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootjavacc-maven-plugin-2.6/src/it/javacc-custom-parser-files/src/main/javacc/org/codehaus/javacc/simple/BasicParser.jjjavacc-maven-plugin-2.6/src/it/javacc-custom-parser-files/src/main/javacc/org/codehaus/javacc/simple0000644000175000017500000000103510745753732033367 0ustar cavedoncavedon options { LOOKAHEAD = 1; CHOICE_AMBIGUITY_CHECK = 2; OTHER_AMBIGUITY_CHECK = 1; STATIC = true; DEBUG_PARSER = false; DEBUG_LOOKAHEAD = false; } PARSER_BEGIN(BasicParser) package org.codehaus.javacc.simple; public class BasicParser { public static void main(String args[]) throws ParseException { BasicParser parser = new BasicParser(System.in); parser.Input(); } } PARSER_END(BasicParser) void Input() : {} { MatchedBraces() ("\n"|"\r")* } void MatchedBraces() : {} { "{" [ MatchedBraces() ] "}" } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootjavacc-maven-plugin-2.6/src/it/javacc-custom-parser-files/src/main/javacc/org/codehaus/javacc/simple/Token.javajavacc-maven-plugin-2.6/src/it/javacc-custom-parser-files/src/main/javacc/org/codehaus/javacc/simple0000644000175000017500000000160611072152564033361 0ustar cavedoncavedon/* CUSTOMIZED PARSER FILE - MUST NOT BE OVERWRITTEN BY JAVACC */ package org.codehaus.javacc.simple; public class Token { public int kind; public int beginLine, beginColumn, endLine, endColumn; public String image; public Token next; public Token specialToken; public Token() { } public Token( int kind ) { this( kind, null ); } public Token( int kind, String image ) { this.kind = kind; this.image = image; } public Object getValue() { return null; } public String toString() { return image; } public static Token newToken( int ofKind, String image ) { switch ( ofKind ) { default : return new Token( ofKind, image ); } } public static Token newToken( int ofKind ) { return newToken( ofKind, null ); } } javacc-maven-plugin-2.6/src/it/javacc-custom-parser-files/verify.bsh0000644000175000017500000000124010750722274025371 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File file = new File( basedir, "target/generated-sources/javacc/org/codehaus/javacc/simple/Token.java" ); if ( !file.isFile() ) { System.err.println( "Could not find generated java file: " + file ); return false; } String contents = FileUtils.fileRead( file, "UTF-8" ); if ( !contents.startsWith( "/* CUSTOMIZED PARSER FILE" ) ) { System.err.println( "Customized Token.java has been ignored or replaced with generated file" ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/javacc-custom-parser-files/invoker.properties0000644000175000017500000000003611020310351027140 0ustar cavedoncavedoninvoker.goals = clean compile javacc-maven-plugin-2.6/src/it/javacc-custom-parser-files/pom.xml0000644000175000017500000000200611250317142024673 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check handling of custom parser files. org.codehaus.mojo javacc-maven-plugin @pom.version@ 1.4 javacc javacc-maven-plugin-2.6/src/it/jjdoc-path-with-spaces/0000755000175000017500000000000011411772447022513 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjdoc-path-with-spaces/verify.bsh0000644000175000017500000000106210753140153024503 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File targetDir = new File( basedir, "target" ); if ( !targetDir.isDirectory() ) { System.err.println( "Missing output directory: " + targetDir ); return false; } File file1 = new File( targetDir, "jj doc/jjdoc/BasicParser.html" ); if ( !file1.isFile() ) { System.err.println( "Missing JJDoc output file: " + file1 ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/jjdoc-path-with-spaces/invoker.properties0000644000175000017500000000003311020310351026254 0ustar cavedoncavedoninvoker.goals = clean site javacc-maven-plugin-2.6/src/it/jjdoc-path-with-spaces/sour ces/0000755000175000017500000000000011411772447024236 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjdoc-path-with-spaces/sour ces/javacc/0000755000175000017500000000000011411772447025465 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjdoc-path-with-spaces/sour ces/javacc/BasicParser.jj0000644000175000017500000000103510753140153030176 0ustar cavedoncavedon options { LOOKAHEAD = 1; CHOICE_AMBIGUITY_CHECK = 2; OTHER_AMBIGUITY_CHECK = 1; STATIC = true; DEBUG_PARSER = false; DEBUG_LOOKAHEAD = false; } PARSER_BEGIN(BasicParser) package org.codehaus.javacc.simple; public class BasicParser { public static void main(String args[]) throws ParseException { BasicParser parser = new BasicParser(System.in); parser.Input(); } } PARSER_END(BasicParser) void Input() : {} { MatchedBraces() ("\n"|"\r")* } void MatchedBraces() : {} { "{" [ MatchedBraces() ] "}" } javacc-maven-plugin-2.6/src/it/jjdoc-path-with-spaces/pom.xml0000644000175000017500000000321011250047556024021 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check handling of paths with spaces. org.codehaus.mojo javacc-maven-plugin @pom.version@ maven-site-plugin @sitePluginVersion@ target/jj doc org.codehaus.mojo javacc-maven-plugin @pom.version@ sour ces/javacc target/jj doc maven-project-info-reports-plugin 2.0.1 javacc-maven-plugin-2.6/src/it/jtb-reactor-build/0000755000175000017500000000000011411772443021550 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-reactor-build/verify.bsh0000644000175000017500000000211210753143026023543 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { { File target = new File( basedir, "target" ); if ( target.exists() ) { System.err.println( "Parent project has unexpected output: " + Arrays.asList( files ) ); return false; } } { File target = new File( basedir, "module/target" ); if ( !target.isDirectory() ) { System.err.println( "Sub module has no output folder: " + target ); return false; } File jtb = new File( target, "jtb/org/SubScheme.jj" ); if ( !jtb.isFile() ) { System.err.println( "Sub module has no JTB output: " + jtb ); return false; } File timestamp = new File( target, "jtb-timestamps/SubScheme.jtb" ); if ( !timestamp.isFile() ) { System.err.println( "Sub module has no JTB timestamp: " + timestamp ); return false; } } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/jtb-reactor-build/invoker.properties0000644000175000017500000000007211257375102025341 0ustar cavedoncavedoninvoker.goals = clean compile invoker.java.version = 1.5+ javacc-maven-plugin-2.6/src/it/jtb-reactor-build/module/0000755000175000017500000000000011411772443023035 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-reactor-build/module/src/0000755000175000017500000000000011411772443023624 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-reactor-build/module/src/jtb/0000755000175000017500000000000011411772443024403 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-reactor-build/module/src/jtb/SubScheme.jtb0000644000175000017500000000204410753143026026757 0ustar cavedoncavedonPARSER_BEGIN(SubScheme) package org; import org.visitor.DepthFirstVisitor; public class SubScheme { public static void main(String args[]) { SubScheme parser; System.out.println("Reading from standard input. . ."); parser = new SubScheme(System.in); try { Node root = parser.Unit(); System.out.println("Parsed successfully."); root.accept(new DepthFirstVisitor()); } catch (ParseException e) { System.out.println(e.getMessage()); System.out.println("Encountered errors during parse."); } } } PARSER_END(SubScheme) SKIP : /* WHITE SPACE */ { " " | "\t" | "\n" | "\r" | "\f" } TOKEN : { < LAMBDA : "lambda" > | < IDENT : (|)* > | < #LETTER: ["_","a"-"z","A"-"Z"] > | < #DIGIT : ["0"-"9"] > } void Unit() : {} { ( Exp() )+ } void Exp() : {} { | LOOKAHEAD(2) LambdaDecl() | LOOKAHEAD(2) "(" Exp() ( Exp() )* ")" | "0" | "(" "+" Exp() "1" ")" } void LambdaDecl() : {} { "(" "lambda" "(" ( )* ")" Exp() ")" } javacc-maven-plugin-2.6/src/it/jtb-reactor-build/module/pom.xml0000644000175000017500000000222010753143026024343 0ustar cavedoncavedon 4.0.0 module Module http://maven.apache.org org.codehaus.mojo.javacc reactor-build 1.0-SNAPSHOT org.codehaus.mojo javacc-maven-plugin jtb src/jtb target/jtb target/jtb-timestamps org javacc-maven-plugin-2.6/src/it/jtb-reactor-build/pom.xml0000644000175000017500000000232310753143026023062 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc reactor-build pom 1.0-SNAPSHOT Integration Test http://maven.apache.org Check handling of output directories during a reactor build. module org.codehaus.mojo javacc-maven-plugin @pom.version@ maven-compiler-plugin 2.0.2 1.5 1.5 javacc-maven-plugin-2.6/src/it/javacc-basic/0000755000175000017500000000000011411772443020545 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-basic/src/0000755000175000017500000000000011411772443021334 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-basic/src/main/0000755000175000017500000000000011411772443022260 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-basic/src/main/javacc/0000755000175000017500000000000011411772443023507 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-basic/src/main/javacc/BasicParser.jj0000644000175000017500000000103510745755013026234 0ustar cavedoncavedon options { LOOKAHEAD = 1; CHOICE_AMBIGUITY_CHECK = 2; OTHER_AMBIGUITY_CHECK = 1; STATIC = true; DEBUG_PARSER = false; DEBUG_LOOKAHEAD = false; } PARSER_BEGIN(BasicParser) package org.codehaus.javacc.simple; public class BasicParser { public static void main(String args[]) throws ParseException { BasicParser parser = new BasicParser(System.in); parser.Input(); } } PARSER_END(BasicParser) void Input() : {} { MatchedBraces() ("\n"|"\r")* } void MatchedBraces() : {} { "{" [ MatchedBraces() ] "}" } javacc-maven-plugin-2.6/src/it/javacc-basic/verify.bsh0000644000175000017500000000062410750722274022553 0ustar cavedoncavedonimport java.io.*; import java.util.*; try { File file = new File( basedir, "target/generated-sources/javacc/org/codehaus/javacc/simple/BasicParser.java" ); if ( !file.exists() || file.isDirectory() ) { System.err.println( "Could not find generated java file: " + file ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/javacc-basic/invoker.properties0000644000175000017500000000003611020310351024315 0ustar cavedoncavedoninvoker.goals = clean compile javacc-maven-plugin-2.6/src/it/javacc-basic/pom.xml0000644000175000017500000000177011250317142022057 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check default execution. org.codehaus.mojo javacc-maven-plugin @pom.version@ 1.4 javacc javacc-maven-plugin-2.6/src/it/jtb-javacc-custom-source-files/0000755000175000017500000000000011411772444024152 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-javacc-custom-source-files/src/0000755000175000017500000000000011411772444024741 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-javacc-custom-source-files/src/main/0000755000175000017500000000000011411772444025665 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-javacc-custom-source-files/src/main/java/0000755000175000017500000000000011411772444026606 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-javacc-custom-source-files/src/main/java/org/0000755000175000017500000000000011411772444027375 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-javacc-custom-source-files/src/main/java/org/Token.java0000644000175000017500000000155711072152564031326 0ustar cavedoncavedon/* CUSTOMIZED PARSER FILE - MUST NOT BE OVERWRITTEN BY JAVACC */ package org; public class Token { public int kind; public int beginLine, beginColumn, endLine, endColumn; public String image; public Token next; public Token specialToken; public Token() { } public Token( int kind ) { this( kind, null ); } public Token( int kind, String image ) { this.kind = kind; this.image = image; } public Object getValue() { return null; } public String toString() { return image; } public static Token newToken( int ofKind, String image ) { switch ( ofKind ) { default : return new Token( ofKind, image ); } } public static Token newToken( int ofKind ) { return newToken( ofKind, null ); } } javacc-maven-plugin-2.6/src/it/jtb-javacc-custom-source-files/src/main/jtb/0000755000175000017500000000000011411772444026444 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-javacc-custom-source-files/src/main/jtb/SubScheme.jtb0000644000175000017500000000204411070224210031003 0ustar cavedoncavedonPARSER_BEGIN(SubScheme) package org; import org.visitor.DepthFirstVisitor; public class SubScheme { public static void main(String args[]) { SubScheme parser; System.out.println("Reading from standard input. . ."); parser = new SubScheme(System.in); try { Node root = parser.Unit(); System.out.println("Parsed successfully."); root.accept(new DepthFirstVisitor()); } catch (ParseException e) { System.out.println(e.getMessage()); System.out.println("Encountered errors during parse."); } } } PARSER_END(SubScheme) SKIP : /* WHITE SPACE */ { " " | "\t" | "\n" | "\r" | "\f" } TOKEN : { < LAMBDA : "lambda" > | < IDENT : (|)* > | < #LETTER: ["_","a"-"z","A"-"Z"] > | < #DIGIT : ["0"-"9"] > } void Unit() : {} { ( Exp() )+ } void Exp() : {} { | LOOKAHEAD(2) LambdaDecl() | LOOKAHEAD(2) "(" Exp() ( Exp() )* ")" | "0" | "(" "+" Exp() "1" ")" } void LambdaDecl() : {} { "(" "lambda" "(" ( )* ")" Exp() ")" } javacc-maven-plugin-2.6/src/it/jtb-javacc-custom-source-files/verify.bsh0000644000175000017500000000071111070224210026133 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File file = new File( basedir, "target/generated-sources/javacc/org/codehaus/javacc/simple/Token.java" ); System.out.println( "Checking for absence of customized java file: " + file ); if ( file.exists() ) { System.err.println( "FAILED!" ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/jtb-javacc-custom-source-files/invoker.properties0000644000175000017500000000007211257375102027742 0ustar cavedoncavedoninvoker.goals = clean compile invoker.java.version = 1.5+ javacc-maven-plugin-2.6/src/it/jtb-javacc-custom-source-files/pom.xml0000644000175000017500000000241211070224210025446 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check handling of custom source files in existing compile source roots (MJAVACC-87). org.codehaus.mojo javacc-maven-plugin @pom.version@ jtb-javacc jtb-javacc maven-compiler-plugin 2.0.2 1.5 1.5 javacc-maven-plugin-2.6/src/it/jjdoc-basic-site/0000755000175000017500000000000011411772445021353 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjdoc-basic-site/src/0000755000175000017500000000000011411772444022141 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjdoc-basic-site/src/main/0000755000175000017500000000000011411772444023065 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjdoc-basic-site/src/main/javacc/0000755000175000017500000000000011411772444024314 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjdoc-basic-site/src/main/javacc/MyParser.jj0000644000175000017500000000051710750717475026416 0ustar cavedoncavedonPARSER_BEGIN(Parser) package org; public class Parser { public static void main(String args[]) throws ParseException { Parser parser = new Parser(System.in); parser.Input(); } } PARSER_END(Parser) void Input() : {} { MatchedBraces() ("\n"|"\r")* } void MatchedBraces() : {} { "{" [ MatchedBraces() ] "}" } javacc-maven-plugin-2.6/src/it/jjdoc-basic-site/verify.bsh0000644000175000017500000000151710753104624023355 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File mojoOutputDir = new File( basedir, "target/it-site" ); if ( mojoOutputDir.exists() ) { System.err.println( "Report was generated into wrong output directory!" ); return false; } File siteOutputDir = new File( basedir, "target/site" ); File indexFile = new File( siteOutputDir, "jjdoc/index.html" ); if ( indexFile.length() <= 0 ) { System.out.println( "File is empty: " + indexFile ); return false; } File jjdocFile = new File( siteOutputDir, "jjdoc/MyParser.html" ); if ( jjdocFile.length() <= 0 ) { System.out.println( "File is empty: " + jjdocFile ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/jjdoc-basic-site/invoker.properties0000644000175000017500000000003311020310351025116 0ustar cavedoncavedoninvoker.goals = clean site javacc-maven-plugin-2.6/src/it/jjdoc-basic-site/pom.xml0000644000175000017500000000306611250047556022674 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check report output during a site generation. org.codehaus.mojo javacc-maven-plugin @pom.version@ maven-site-plugin @sitePluginVersion@ org.codehaus.mojo javacc-maven-plugin @pom.version@ target/it-site maven-project-info-reports-plugin 2.0.1 javacc-maven-plugin-2.6/src/it/jjtree-javacc-pipeline/0000755000175000017500000000000011411772447022556 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-javacc-pipeline/src/0000755000175000017500000000000011411772447023345 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-javacc-pipeline/src/main/0000755000175000017500000000000011411772447024271 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-javacc-pipeline/src/main/jjtree/0000755000175000017500000000000011411772447025554 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-javacc-pipeline/src/main/jjtree/Simple.jjt0000644000175000017500000000301510746620005027505 0ustar cavedoncavedon PARSER_BEGIN(Simple) class Simple { public static void main(String args[]) { System.out.println("Reading from standard input..."); Simple t = new Simple(System.in); try { SimpleNode n = t.Start(); n.dump(""); System.out.println("Thank you."); } catch (Exception e) { System.out.println("Oops."); System.out.println(e.getMessage()); e.printStackTrace(); } } } PARSER_END(Simple) SKIP : { " " | "\t" | "\n" | "\r" | <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")> | <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/"> } TOKEN : /* LITERALS */ { < INTEGER_LITERAL: (["l","L"])? | (["l","L"])? | (["l","L"])? > | < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* > | < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > | < #OCTAL_LITERAL: "0" (["0"-"7"])* > } TOKEN : /* IDENTIFIERS */ { < IDENTIFIER: (|)* > | < #LETTER: ["_","a"-"z","A"-"Z"] > | < #DIGIT: ["0"-"9"] > } SimpleNode Start() : {} { Expression() ";" { return jjtThis; } } void Expression() : {} { AdditiveExpression() } void AdditiveExpression() : {} { MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )* } void MultiplicativeExpression() : {} { UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )* } void UnaryExpression() : {} { "(" Expression() ")" | Identifier() | Integer() } void Identifier() : {} { } void Integer() : {} { } javacc-maven-plugin-2.6/src/it/jjtree-javacc-pipeline/verify.bsh0000644000175000017500000000123410747720646024565 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File outputFolder = new File( basedir, "target/generated-sources/javacc" ); File nodeFile = new File( outputFolder, "Node.java"); if ( !nodeFile.isFile() ) { System.err.println( "Could not find generated java file: " + nodeFile ); return false; } File parserFile = new File( outputFolder, "Simple.java"); if ( !parserFile.isFile() ) { System.err.println( "Could not find generated java file: " + parserFile ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/jjtree-javacc-pipeline/invoker.properties0000644000175000017500000000003611020310351026322 0ustar cavedoncavedoninvoker.goals = clean compile javacc-maven-plugin-2.6/src/it/jjtree-javacc-pipeline/pom.xml0000644000175000017500000000257411250317142024067 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc jjtree-javacc-pipeline jar 1.0-SNAPSHOT Integration Test http://maven.apache.org org.codehaus.mojo javacc-maven-plugin @pom.version@ 1.4 jjtree jjtree target/generated-sources/jjtree javacc javacc target/generated-sources/jjtree javacc-maven-plugin-2.6/src/it/jjtree-static-node-package/0000755000175000017500000000000011411772446023326 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-static-node-package/src/0000755000175000017500000000000011411772445024114 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-static-node-package/src/main/0000755000175000017500000000000011411772445025040 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-static-node-package/src/main/java/0000755000175000017500000000000011411772445025761 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-static-node-package/src/main/java/it/0000755000175000017500000000000011411772445026375 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-static-node-package/src/main/java/it/nodes/0000755000175000017500000000000011411772445027505 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-static-node-package/src/main/java/it/nodes/Simple.java0000644000175000017500000000017510747730522031605 0ustar cavedoncavedonpackage it.nodes; /** * Workaround for https://javacc.dev.java.net/issues/show_bug.cgi?id=149. */ public class Simple { } javacc-maven-plugin-2.6/src/it/jjtree-static-node-package/src/main/jjtree/0000755000175000017500000000000011411772446026324 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-static-node-package/src/main/jjtree/Simple.jjt0000644000175000017500000000311010747730522030261 0ustar cavedoncavedonPARSER_BEGIN(Simple) package it; // should be different from NODE_PACKAGE setting class Simple { public static void main(String args[]) { System.out.println("Reading from standard input..."); Simple t = new Simple(System.in); try { SimpleNode n = t.Start(); n.dump(""); System.out.println("Thank you."); } catch (Exception e) { System.out.println("Oops."); System.out.println(e.getMessage()); e.printStackTrace(); } } } PARSER_END(Simple) SKIP : { " " | "\t" | "\n" | "\r" | <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")> | <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/"> } TOKEN : /* LITERALS */ { < INTEGER_LITERAL: (["l","L"])? | (["l","L"])? | (["l","L"])? > | < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* > | < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > | < #OCTAL_LITERAL: "0" (["0"-"7"])* > } TOKEN : /* IDENTIFIERS */ { < IDENTIFIER: (|)* > | < #LETTER: ["_","a"-"z","A"-"Z"] > | < #DIGIT: ["0"-"9"] > } SimpleNode Start() : {} { Expression() ";" { return jjtThis; } } void Expression() : {} { AdditiveExpression() } void AdditiveExpression() : {} { MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )* } void MultiplicativeExpression() : {} { UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )* } void UnaryExpression() : {} { "(" Expression() ")" | Identifier() | Integer() } void Identifier() : {} { } void Integer() : {} { } javacc-maven-plugin-2.6/src/it/jjtree-static-node-package/verify.bsh0000644000175000017500000000146110750721311025320 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File classesDir = new File( basedir, "target/classes" ); if ( !classesDir.isDirectory() ) { System.err.println( "Could not find classes directory: " + classesDir ); return false; } File nodeClass = new File( classesDir, "it/SimpleNode.class"); if ( nodeClass.isFile() ) { System.err.println( "Found unexpected compiled class file: " + nodeClass ); return false; } nodeClass = new File( classesDir, "it/nodes/SimpleNode.class"); if ( !nodeClass.isFile() ) { System.err.println( "Could not find compiled class file: " + nodeClass ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/jjtree-static-node-package/invoker.properties0000644000175000017500000000003611020310351027073 0ustar cavedoncavedoninvoker.goals = clean compile javacc-maven-plugin-2.6/src/it/jjtree-static-node-package/pom.xml0000644000175000017500000000324711250317142024636 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check handling of custom node package with static value. org.codehaus.mojo javacc-maven-plugin @pom.version@ jjtree-exec jjtree target/generated-sources/jjtree it.nodes 1.4 maven-antrun-plugin 1.1 prepare-it generate-sources run target/generated-sources/jjtree javacc-maven-plugin-2.6/src/it/jjtree-dynamic-node-package/0000755000175000017500000000000011411772441023456 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-dynamic-node-package/src/0000755000175000017500000000000011411772441024245 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-dynamic-node-package/src/main/0000755000175000017500000000000011411772441025171 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-dynamic-node-package/src/main/java/0000755000175000017500000000000011411772441026112 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-dynamic-node-package/src/main/java/it/0000755000175000017500000000000011411772441026526 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-dynamic-node-package/src/main/java/it/parser1/0000755000175000017500000000000011411772441030103 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-dynamic-node-package/src/main/java/it/parser1/node/0000755000175000017500000000000011411772441031030 5ustar cavedoncavedon././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootjavacc-maven-plugin-2.6/src/it/jjtree-dynamic-node-package/src/main/java/it/parser1/node/Simple.javajavacc-maven-plugin-2.6/src/it/jjtree-dynamic-node-package/src/main/java/it/parser1/node/Simple.java0000644000175000017500000000020410750663536033131 0ustar cavedoncavedonpackage it.parser1.node; /** * Workaround for https://javacc.dev.java.net/issues/show_bug.cgi?id=149. */ public class Simple { } javacc-maven-plugin-2.6/src/it/jjtree-dynamic-node-package/src/main/java/it/parser2/0000755000175000017500000000000011411772441030104 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-dynamic-node-package/src/main/java/it/parser2/node/0000755000175000017500000000000011411772441031031 5ustar cavedoncavedon././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootjavacc-maven-plugin-2.6/src/it/jjtree-dynamic-node-package/src/main/java/it/parser2/node/Simple.javajavacc-maven-plugin-2.6/src/it/jjtree-dynamic-node-package/src/main/java/it/parser2/node/Simple.java0000644000175000017500000000020410750663536033132 0ustar cavedoncavedonpackage it.parser2.node; /** * Workaround for https://javacc.dev.java.net/issues/show_bug.cgi?id=149. */ public class Simple { } javacc-maven-plugin-2.6/src/it/jjtree-dynamic-node-package/src/main/jjtree/0000755000175000017500000000000011411772441026454 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-dynamic-node-package/src/main/jjtree/Parser1.jjt0000644000175000017500000000320010750663536030506 0ustar cavedoncavedonPARSER_BEGIN(Simple) package it.parser1; class Simple { public static void main(String args[]) { System.out.println("Reading from standard input..."); Simple t = new Simple(System.in); try { SimpleNode n = t.Start(); n.dump(""); System.out.println("Thank you."); } catch (Exception e) { System.out.println("Oops."); System.out.println(e.getMessage()); e.printStackTrace(); } } public void jjtreeOpenNodeScope(Node n) { } public void jjtreeCloseNodeScope(Node n) { } } PARSER_END(Simple) SKIP : { " " | "\t" | "\n" | "\r" | <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")> | <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/"> } TOKEN : /* LITERALS */ { < INTEGER_LITERAL: (["l","L"])? | (["l","L"])? | (["l","L"])? > | < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* > | < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > | < #OCTAL_LITERAL: "0" (["0"-"7"])* > } TOKEN : /* IDENTIFIERS */ { < IDENTIFIER: (|)* > | < #LETTER: ["_","a"-"z","A"-"Z"] > | < #DIGIT: ["0"-"9"] > } SimpleNode Start() : {} { Expression() ";" { return jjtThis; } } void Expression() : {} { AdditiveExpression() } void AdditiveExpression() : {} { MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )* } void MultiplicativeExpression() : {} { UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )* } void UnaryExpression() : {} { "(" Expression() ")" | Identifier() | Integer() } void Identifier() : {} { } void Integer() : {} { } javacc-maven-plugin-2.6/src/it/jjtree-dynamic-node-package/src/main/jjtree/Parser2.jjt0000644000175000017500000000320010750663536030507 0ustar cavedoncavedonPARSER_BEGIN(Simple) package it.parser2; class Simple { public static void main(String args[]) { System.out.println("Reading from standard input..."); Simple t = new Simple(System.in); try { SimpleNode n = t.Start(); n.dump(""); System.out.println("Thank you."); } catch (Exception e) { System.out.println("Oops."); System.out.println(e.getMessage()); e.printStackTrace(); } } public void jjtreeOpenNodeScope(Node n) { } public void jjtreeCloseNodeScope(Node n) { } } PARSER_END(Simple) SKIP : { " " | "\t" | "\n" | "\r" | <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")> | <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/"> } TOKEN : /* LITERALS */ { < INTEGER_LITERAL: (["l","L"])? | (["l","L"])? | (["l","L"])? > | < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* > | < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > | < #OCTAL_LITERAL: "0" (["0"-"7"])* > } TOKEN : /* IDENTIFIERS */ { < IDENTIFIER: (|)* > | < #LETTER: ["_","a"-"z","A"-"Z"] > | < #DIGIT: ["0"-"9"] > } SimpleNode Start() : {} { Expression() ";" { return jjtThis; } } void Expression() : {} { AdditiveExpression() } void AdditiveExpression() : {} { MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )* } void MultiplicativeExpression() : {} { UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )* } void UnaryExpression() : {} { "(" Expression() ")" | Identifier() | Integer() } void Identifier() : {} { } void Integer() : {} { } javacc-maven-plugin-2.6/src/it/jjtree-dynamic-node-package/verify.bsh0000644000175000017500000000151710750663536025475 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File classesDir = new File( basedir, "target/classes" ); if ( !classesDir.isDirectory() ) { System.err.println( "Could not find classes directory: " + classesDir ); return false; } File nodeClass1 = new File( classesDir, "it/parser1/node/SimpleNode.class"); if ( !nodeClass1.isFile() ) { System.err.println( "Could not find compiled class file: " + nodeClass1 ); return false; } File nodeClass2 = new File( classesDir, "it/parser2/node/SimpleNode.class"); if ( !nodeClass2.isFile() ) { System.err.println( "Could not find compiled class file: " + nodeClass2 ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/jjtree-dynamic-node-package/invoker.properties0000644000175000017500000000003611020310351027230 0ustar cavedoncavedoninvoker.goals = clean compile javacc-maven-plugin-2.6/src/it/jjtree-dynamic-node-package/pom.xml0000644000175000017500000000324611250317142024772 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check handling of custom node package with dynamic value. org.codehaus.mojo javacc-maven-plugin @pom.version@ jjtree-exec jjtree target/generated-sources/jjtree *.node 1.4 maven-antrun-plugin 1.1 prepare-it generate-sources run target/generated-sources/jjtree javacc-maven-plugin-2.6/src/it/javacc-custom-source-files/0000755000175000017500000000000011411772446023377 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-custom-source-files/src/0000755000175000017500000000000011411772446024166 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-custom-source-files/src/main/0000755000175000017500000000000011411772446025112 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-custom-source-files/src/main/javacc/0000755000175000017500000000000011411772446026341 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-custom-source-files/src/main/javacc/BasicParser.jj0000644000175000017500000000100611070224210031037 0ustar cavedoncavedon options { LOOKAHEAD = 1; CHOICE_AMBIGUITY_CHECK = 2; OTHER_AMBIGUITY_CHECK = 1; STATIC = true; DEBUG_PARSER = false; DEBUG_LOOKAHEAD = false; } PARSER_BEGIN(BasicParser) package org; public class BasicParser { public static void main(String args[]) throws ParseException { BasicParser parser = new BasicParser(System.in); parser.Input(); } } PARSER_END(BasicParser) void Input() : {} { MatchedBraces() ("\n"|"\r")* } void MatchedBraces() : {} { "{" [ MatchedBraces() ] "}" } javacc-maven-plugin-2.6/src/it/javacc-custom-source-files/src/main/java/0000755000175000017500000000000011411772446026033 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-custom-source-files/src/main/java/org/0000755000175000017500000000000011411772446026622 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-custom-source-files/src/main/java/org/Token.java0000644000175000017500000000155711072152564030551 0ustar cavedoncavedon/* CUSTOMIZED PARSER FILE - MUST NOT BE OVERWRITTEN BY JAVACC */ package org; public class Token { public int kind; public int beginLine, beginColumn, endLine, endColumn; public String image; public Token next; public Token specialToken; public Token() { } public Token( int kind ) { this( kind, null ); } public Token( int kind, String image ) { this.kind = kind; this.image = image; } public Object getValue() { return null; } public String toString() { return image; } public static Token newToken( int ofKind, String image ) { switch ( ofKind ) { default : return new Token( ofKind, image ); } } public static Token newToken( int ofKind ) { return newToken( ofKind, null ); } } javacc-maven-plugin-2.6/src/it/javacc-custom-source-files/verify.bsh0000644000175000017500000000071111070224210025356 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File file = new File( basedir, "target/generated-sources/javacc/org/codehaus/javacc/simple/Token.java" ); System.out.println( "Checking for absence of customized java file: " + file ); if ( file.exists() ) { System.err.println( "FAILED!" ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/javacc-custom-source-files/invoker.properties0000644000175000017500000000003611070224210027147 0ustar cavedoncavedoninvoker.goals = clean compile javacc-maven-plugin-2.6/src/it/javacc-custom-source-files/pom.xml0000644000175000017500000000206411250317142024703 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check handling of custom source files in existing compile source roots (MJAVACC-87). org.codehaus.mojo javacc-maven-plugin @pom.version@ 1.4 javacc javacc-maven-plugin-2.6/src/it/jtb-javacc-basic/0000755000175000017500000000000011411772441021320 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-javacc-basic/src/0000755000175000017500000000000011411772441022107 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-javacc-basic/src/main/0000755000175000017500000000000011411772441023033 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-javacc-basic/src/main/jtb/0000755000175000017500000000000011411772441023612 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-javacc-basic/src/main/jtb/SubScheme.jtb0000644000175000017500000000204410753161035026170 0ustar cavedoncavedonPARSER_BEGIN(SubScheme) package org; import org.visitor.DepthFirstVisitor; public class SubScheme { public static void main(String args[]) { SubScheme parser; System.out.println("Reading from standard input. . ."); parser = new SubScheme(System.in); try { Node root = parser.Unit(); System.out.println("Parsed successfully."); root.accept(new DepthFirstVisitor()); } catch (ParseException e) { System.out.println(e.getMessage()); System.out.println("Encountered errors during parse."); } } } PARSER_END(SubScheme) SKIP : /* WHITE SPACE */ { " " | "\t" | "\n" | "\r" | "\f" } TOKEN : { < LAMBDA : "lambda" > | < IDENT : (|)* > | < #LETTER: ["_","a"-"z","A"-"Z"] > | < #DIGIT : ["0"-"9"] > } void Unit() : {} { ( Exp() )+ } void Exp() : {} { | LOOKAHEAD(2) LambdaDecl() | LOOKAHEAD(2) "(" Exp() ( Exp() )* ")" | "0" | "(" "+" Exp() "1" ")" } void LambdaDecl() : {} { "(" "lambda" "(" ( )* ")" Exp() ")" } javacc-maven-plugin-2.6/src/it/jtb-javacc-basic/src/main/jtb/Token.java0000644000175000017500000000155711105415044025536 0ustar cavedoncavedon/* CUSTOMIZED PARSER FILE - MUST NOT BE OVERWRITTEN BY JAVACC */ package org; public class Token { public int kind; public int beginLine, beginColumn, endLine, endColumn; public String image; public Token next; public Token specialToken; public Token() { } public Token( int kind ) { this( kind, null ); } public Token( int kind, String image ) { this.kind = kind; this.image = image; } public Object getValue() { return null; } public String toString() { return image; } public static Token newToken( int ofKind, String image ) { switch ( ofKind ) { default : return new Token( ofKind, image ); } } public static Token newToken( int ofKind ) { return newToken( ofKind, null ); } } javacc-maven-plugin-2.6/src/it/jtb-javacc-basic/verify.bsh0000644000175000017500000000266411105412131023315 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File javaccDir = new File( basedir, "target/generated-sources/javacc" ); File jtbDir = new File( basedir, "target/generated-sources/jtb" ); File nodeFile = new File( jtbDir, "org/syntaxtree/Node.java"); if ( nodeFile.length() <= 0 ) { System.err.println( "Could not find generated java file: " + nodeFile ); return false; } File visitorFile = new File( jtbDir, "org/visitor/Visitor.java"); if ( visitorFile.length() <= 0 ) { System.err.println( "Could not find generated java file: " + visitorFile ); return false; } File parserFile = new File( javaccDir, "org/SubScheme.java"); if ( parserFile.length() <= 0 ) { System.err.println( "Could not find generated java file: " + parserFile ); return false; } File customFile = new File( javaccDir, "org/Token.java" ); if ( customFile.length() <= 0 ) { System.err.println( "Could not find generated java file: " + file ); return false; } String contents = FileUtils.fileRead( customFile, "UTF-8" ); if ( !contents.startsWith( "/* CUSTOMIZED PARSER FILE" ) ) { System.err.println( "Custom java file has been ignored or replaced with generated file" ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/jtb-javacc-basic/invoker.properties0000644000175000017500000000007211257375102025113 0ustar cavedoncavedoninvoker.goals = clean compile invoker.java.version = 1.5+ javacc-maven-plugin-2.6/src/it/jtb-javacc-basic/pom.xml0000644000175000017500000000234110753161035022634 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check combined execution of JTB and JavaCC. org.codehaus.mojo javacc-maven-plugin @pom.version@ jtb-javacc jtb-javacc maven-compiler-plugin 2.0.2 1.5 1.5 javacc-maven-plugin-2.6/src/it/javacc-equal-input-output-directory/0000755000175000017500000000000011411772442025267 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-equal-input-output-directory/src/0000755000175000017500000000000011411772442026056 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-equal-input-output-directory/src/main/0000755000175000017500000000000011411772442027002 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-equal-input-output-directory/src/main/javacc/0000755000175000017500000000000011411772442030231 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-equal-input-output-directory/src/main/javacc/MyParser.jj0000644000175000017500000000050210745747503032326 0ustar cavedoncavedon PARSER_BEGIN(Parser) public class Parser { public static void main(String args[]) throws ParseException { Parser parser = new Parser(System.in); parser.Input(); } } PARSER_END(Parser) void Input() : {} { MatchedBraces() ("\n"|"\r")* } void MatchedBraces() : {} { "{" [ MatchedBraces() ] "}" } javacc-maven-plugin-2.6/src/it/javacc-equal-input-output-directory/src/main/javacc/Token.java0000644000175000017500000000512010742466660032162 0ustar cavedoncavedon/** * This is a user-provided source file that must not be overwritten. */ /** * Describes the input token stream. */ public class Token { /** * An integer that describes the kind of this token. This numbering * system is determined by JavaCCParser, and a table of these numbers is * stored in the file ...Constants.java. */ public int kind; /** * beginLine and beginColumn describe the position of the first character * of this token; endLine and endColumn describe the position of the * last character of this token. */ public int beginLine, beginColumn, endLine, endColumn; /** * The string image of the token. */ public String image; /** * A reference to the next regular (non-special) token from the input * stream. If this is the last token from the input stream, or if the * token manager has not read tokens beyond this one, this field is * set to null. This is true only if this token is also a regular * token. Otherwise, see below for a description of the contents of * this field. */ public Token next; /** * This field is used to access special tokens that occur prior to this * token, but after the immediately preceding regular (non-special) token. * If there are no such special tokens, this field is set to null. * When there are more than one such special token, this field refers * to the last of these special tokens, which in turn refers to the next * previous special token through its specialToken field, and so on * until the first special token (whose specialToken field is null). * The next fields of special tokens refer to other special tokens that * immediately follow it (without an intervening regular token). If there * is no such token, this field is null. */ public Token specialToken; /** * Returns the image. */ public String toString() { return image; } /** * Returns a new Token object, by default. However, if you want, you * can create and return subclass objects based on the value of ofKind. * Simply add the cases to the switch for all those special cases. * For example, if you have a subclass of Token called IDToken that * you want to create if ofKind is ID, simlpy add something like : * * case MyParserConstants.ID : return new IDToken(); * * to the following switch statement. Then you can cast matchedToken * variable to the appropriate type and use it in your lexical actions. */ public static final Token newToken(int ofKind) { switch(ofKind) { default : return new Token(); } } } javacc-maven-plugin-2.6/src/it/javacc-equal-input-output-directory/verify.bsh0000644000175000017500000000113710750722274027276 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File tokenFile = new File( basedir, "target/generated-sources/javacc/Token.java" ); if ( !tokenFile.exists() || tokenFile.isDirectory() ) { System.err.println( "Could not find generated Token.java file: " + tokenFile ); return false; } if ( tokenFile.length() == 0 ) { System.out.println("File is empty: " + tokenFile); System.out.println("It is being overwritten by javacc"); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/javacc-equal-input-output-directory/invoker.properties0000644000175000017500000000003611020310351031040 0ustar cavedoncavedoninvoker.goals = clean compile javacc-maven-plugin-2.6/src/it/javacc-equal-input-output-directory/pom.xml0000644000175000017500000000377411250317142026610 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check handling of equal input and output directory. maven-antrun-plugin 1.1 prepare-it generate-sources run org.codehaus.mojo javacc-maven-plugin @pom.version@ it javacc ${project.build.directory}/generated-sources/javacc ${project.build.directory}/generated-sources/javacc 1.4 javacc-maven-plugin-2.6/src/it/explicit-parameter-values/0000755000175000017500000000000011411772446023336 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/explicit-parameter-values/src/0000755000175000017500000000000011411772446024125 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/explicit-parameter-values/src/javacc/0000755000175000017500000000000011411772446025354 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/explicit-parameter-values/src/javacc/BasicParser.jj0000644000175000017500000000103510747213774030103 0ustar cavedoncavedon options { LOOKAHEAD = 1; CHOICE_AMBIGUITY_CHECK = 2; OTHER_AMBIGUITY_CHECK = 1; STATIC = true; DEBUG_PARSER = false; DEBUG_LOOKAHEAD = false; } PARSER_BEGIN(BasicParser) package org.codehaus.javacc.simple; public class BasicParser { public static void main(String args[]) throws ParseException { BasicParser parser = new BasicParser(System.in); parser.Input(); } } PARSER_END(BasicParser) void Input() : {} { MatchedBraces() ("\n"|"\r")* } void MatchedBraces() : {} { "{" [ MatchedBraces() ] "}" } javacc-maven-plugin-2.6/src/it/explicit-parameter-values/src/jjtree/0000755000175000017500000000000011411772446025410 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/explicit-parameter-values/src/jjtree/Simple.jjt0000644000175000017500000000317110750606661027354 0ustar cavedoncavedonPARSER_BEGIN(Simple) package org; class Simple { public static void main(String args[]) { System.out.println("Reading from standard input..."); Simple t = new Simple(System.in); try { SimpleNode n = t.Start(); n.dump(""); System.out.println("Thank you."); } catch (Exception e) { System.out.println("Oops."); System.out.println(e.getMessage()); e.printStackTrace(); } } public void jjtreeOpenNodeScope(Node n) { } public void jjtreeCloseNodeScope(Node n) { } } PARSER_END(Simple) SKIP : { " " | "\t" | "\n" | "\r" | <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")> | <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/"> } TOKEN : /* LITERALS */ { < INTEGER_LITERAL: (["l","L"])? | (["l","L"])? | (["l","L"])? > | < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* > | < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > | < #OCTAL_LITERAL: "0" (["0"-"7"])* > } TOKEN : /* IDENTIFIERS */ { < IDENTIFIER: (|)* > | < #LETTER: ["_","a"-"z","A"-"Z"] > | < #DIGIT: ["0"-"9"] > } SimpleNode Start() : {} { Expression() ";" { return jjtThis; } } void Expression() : {} { AdditiveExpression() } void AdditiveExpression() : {} { MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )* } void MultiplicativeExpression() : {} { UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )* } void UnaryExpression() : {} { "(" Expression() ")" | Identifier() | Integer() } void Identifier() : {} { } void Integer() : {} { } javacc-maven-plugin-2.6/src/it/explicit-parameter-values/verify.bsh0000644000175000017500000000103610747720646025346 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File logFile = new File( basedir, "build.log" ); if ( !logFile.isFile() ) { System.err.println( "Missing log file: " + logFile ); return false; } String log = FileUtils.fileRead( logFile ); if ( log.indexOf( "Bad option" ) >= 0 ) { System.err.println( "JavaCC/JJTree/JJDoc reported bad option" ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/explicit-parameter-values/invoker.properties0000644000175000017500000000004311020310351027101 0ustar cavedoncavedoninvoker.goals = clean compile site javacc-maven-plugin-2.6/src/it/explicit-parameter-values/pom.xml0000644000175000017500000001136411255144735024660 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check assembling of command lines. org.codehaus.mojo javacc-maven-plugin @pom.version@ javacc javacc UTF-8 src/javacc target/javacc target/javacc-ts 1.4 2 3 2 false true true true true true false true false false false true true true true true true true false jjtree jjtree src/jjtree target/jjtree target/jjtree-ts 1.4 true true false SimpleNode org Ast true true false true java.lang.Exception post-jjtree-javacc javacc target/jjtree target/javacc target/javacc-ts false 1.4 maven-site-plugin 2.0-beta-7 org.codehaus.mojo javacc-maven-plugin @pom.version@ src/javacc target/jjtree bnf false false maven-project-info-reports-plugin 2.0.1 javacc-maven-plugin-2.6/src/it/jtb-basic/0000755000175000017500000000000011411772442020074 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-basic/src/0000755000175000017500000000000011411772442020663 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-basic/src/main/0000755000175000017500000000000011411772442021607 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-basic/src/main/jtb/0000755000175000017500000000000011411772442022366 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-basic/src/main/jtb/SubScheme.jtb0000644000175000017500000000204410750714571024751 0ustar cavedoncavedonPARSER_BEGIN(SubScheme) package org; import org.visitor.DepthFirstVisitor; public class SubScheme { public static void main(String args[]) { SubScheme parser; System.out.println("Reading from standard input. . ."); parser = new SubScheme(System.in); try { Node root = parser.Unit(); System.out.println("Parsed successfully."); root.accept(new DepthFirstVisitor()); } catch (ParseException e) { System.out.println(e.getMessage()); System.out.println("Encountered errors during parse."); } } } PARSER_END(SubScheme) SKIP : /* WHITE SPACE */ { " " | "\t" | "\n" | "\r" | "\f" } TOKEN : { < LAMBDA : "lambda" > | < IDENT : (|)* > | < #LETTER: ["_","a"-"z","A"-"Z"] > | < #DIGIT : ["0"-"9"] > } void Unit() : {} { ( Exp() )+ } void Exp() : {} { | LOOKAHEAD(2) LambdaDecl() | LOOKAHEAD(2) "(" Exp() ( Exp() )* ")" | "0" | "(" "+" Exp() "1" ")" } void LambdaDecl() : {} { "(" "lambda" "(" ( )* ")" Exp() ")" } javacc-maven-plugin-2.6/src/it/jtb-basic/verify.bsh0000644000175000017500000000174610750714571022112 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File outputFolder = new File( basedir, "target/generated-sources/jtb" ); File nodeFile = new File( outputFolder, "org/syntaxtree/Node.java"); if ( !nodeFile.exists() || nodeFile.isDirectory() ) { System.err.println( "Could not find generated node file: " + nodeFile ); return false; } File visitorFile = new File( outputFolder, "org/visitor/Visitor.java"); if ( !visitorFile.exists() || nodeFile.isDirectory() ) { System.err.println( "Could not find generated visitor file: " + visitorFile ); return false; } File parserFile = new File( outputFolder, "org/SubScheme.jj"); if ( !parserFile.exists() || parserFile.isDirectory() ) { System.err.println( "Could not find generated jj file: " + parserFile ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/jtb-basic/invoker.properties0000644000175000017500000000007211257375102023666 0ustar cavedoncavedoninvoker.goals = clean compile invoker.java.version = 1.5+ javacc-maven-plugin-2.6/src/it/jtb-basic/pom.xml0000644000175000017500000000216310751446444021421 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc jtb-basic jar 1.0-SNAPSHOT Integration Test http://maven.apache.org org.codehaus.mojo javacc-maven-plugin @pom.version@ jtb jtb maven-compiler-plugin 2.0.2 1.5 1.5 javacc-maven-plugin-2.6/src/it/jjdoc-absent-source-directory/0000755000175000017500000000000011411772443024102 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjdoc-absent-source-directory/verify.bsh0000644000175000017500000000126610753140053026103 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File target = new File( basedir, "target" ); if ( target.exists() ) { String[] files = target.list(); if ( files != null && ( files.length > 1 || !"site".equals( files[0] ) ) ) { System.err.println( "Found unexpected output: " + Arrays.asList( files ) ); return false; } } File jjdoc = new File( target, "site/jjdoc" ); if ( jjdoc.exists() ) { System.err.println( "Found unexpected JJDoc output: " + jjdoc ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/jjdoc-absent-source-directory/invoker.properties0000644000175000017500000000003311020310351027647 0ustar cavedoncavedoninvoker.goals = clean site javacc-maven-plugin-2.6/src/it/jjdoc-absent-source-directory/pom.xml0000644000175000017500000000247711113315665025427 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check behavior when the source directory does not exist. org.codehaus.mojo javacc-maven-plugin @pom.version@ maven-site-plugin 2.0-beta-7 javacc-maven-plugin org.codehaus.mojo @pom.version@ maven-project-info-reports-plugin 2.0.1 javacc-maven-plugin-2.6/src/it/jjdoc-default-source-roots/0000755000175000017500000000000011411772445023416 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjdoc-default-source-roots/src/0000755000175000017500000000000011411772445024205 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjdoc-default-source-roots/src/main/0000755000175000017500000000000011411772445025131 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjdoc-default-source-roots/src/main/javacc/0000755000175000017500000000000011411772445026360 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjdoc-default-source-roots/src/main/javacc/BasicParser.jj0000644000175000017500000000062110745747503031110 0ustar cavedoncavedon PARSER_BEGIN(BasicParser) package org.codehaus.javacc.test; public class BasicParser { public static void main(String args[]) throws ParseException { Simple2 parser = new Simple2(System.in); parser.Input(); } } PARSER_END(BasicParser) SKIP : { " " | "\t" | "\n" | "\r" } void Input() : {} { MatchedBraces() } void MatchedBraces() : {} { "{" [ MatchedBraces() ] "}" } javacc-maven-plugin-2.6/src/it/jjdoc-default-source-roots/src/main/jjtree/0000755000175000017500000000000011411772445026414 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjdoc-default-source-roots/src/main/jjtree/Simple.jjt0000644000175000017500000000301210750714571030353 0ustar cavedoncavedonPARSER_BEGIN(Simple) class Simple { public static void main(String args[]) { System.out.println("Reading from standard input..."); Simple t = new Simple(System.in); try { SimpleNode n = t.Start(); n.dump(""); System.out.println("Thank you."); } catch (Exception e) { System.out.println("Oops."); System.out.println(e.getMessage()); e.printStackTrace(); } } } PARSER_END(Simple) SKIP : { " " | "\t" | "\n" | "\r" | <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")> | <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/"> } TOKEN : /* LITERALS */ { < INTEGER_LITERAL: (["l","L"])? | (["l","L"])? | (["l","L"])? > | < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* > | < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > | < #OCTAL_LITERAL: "0" (["0"-"7"])* > } TOKEN : /* IDENTIFIERS */ { < IDENTIFIER: (|)* > | < #LETTER: ["_","a"-"z","A"-"Z"] > | < #DIGIT: ["0"-"9"] > } SimpleNode Start() : {} { Expression() ";" { return jjtThis; } } void Expression() : {} { AdditiveExpression() } void AdditiveExpression() : {} { MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )* } void MultiplicativeExpression() : {} { UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )* } void UnaryExpression() : {} { "(" Expression() ")" | Identifier() | Integer() } void Identifier() : {} { } void Integer() : {} { } javacc-maven-plugin-2.6/src/it/jjdoc-default-source-roots/src/main/jtb/0000755000175000017500000000000011411772445025710 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjdoc-default-source-roots/src/main/jtb/SubScheme.jtb0000644000175000017500000000202210750562313030257 0ustar cavedoncavedonPARSER_BEGIN(SubScheme) import visitor.DepthFirstVisitor; public class SubScheme { public static void main(String args[]) { SubScheme parser; System.out.println("Reading from standard input. . ."); parser = new SubScheme(System.in); try { Node root = parser.Unit(); System.out.println("Parsed successfully."); root.accept(new DepthFirstVisitor()); } catch (ParseException e) { System.out.println(e.getMessage()); System.out.println("Encountered errors during parse."); } } } PARSER_END(SubScheme) SKIP : /* WHITE SPACE */ { " " | "\t" | "\n" | "\r" | "\f" } TOKEN : { < LAMBDA : "lambda" > | < IDENT : (|)* > | < #LETTER: ["_","a"-"z","A"-"Z"] > | < #DIGIT : ["0"-"9"] > } void Unit() : {} { ( Exp() )+ } void Exp() : {} { | LOOKAHEAD(2) LambdaDecl() | LOOKAHEAD(2) "(" Exp() ( Exp() )* ")" | "0" | "(" "+" Exp() "1" ")" } void LambdaDecl() : {} { "(" "lambda" "(" ( )* ")" Exp() ")" } javacc-maven-plugin-2.6/src/it/jjdoc-default-source-roots/verify.bsh0000644000175000017500000000147410750717475025435 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File file1 = new File( basedir, "target/site/jjdoc/BasicParser.html" ); if ( file1.length() <= 0 ) { System.err.println( "Could not find generated jjdoc file: " + file1 ); return false; } File file2 = new File( basedir, "target/site/jjdoc/Simple.html" ); if ( file2.length() <= 0 ) { System.err.println( "Could not find generated jjdoc file: " + file2 ); return false; } File file3 = new File( basedir, "target/site/jjdoc/SubScheme.html" ); if ( file3.length() <= 0 ) { System.err.println( "Could not find generated jjdoc file: " + file3 ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/jjdoc-default-source-roots/invoker.properties0000644000175000017500000000003311020310351027161 0ustar cavedoncavedoninvoker.goals = clean site javacc-maven-plugin-2.6/src/it/jjdoc-default-source-roots/pom.xml0000644000175000017500000000441511250047556024736 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check detection of grammar files via default source directories. maven-antrun-plugin 1.1 prepare-it generate-sources run org.codehaus.mojo javacc-maven-plugin @pom.version@ maven-site-plugin @sitePluginVersion@ org.codehaus.mojo javacc-maven-plugin @pom.version@ maven-project-info-reports-plugin 2.0.1 javacc-maven-plugin-2.6/src/it/jjtree-basic/0000755000175000017500000000000011411772447020605 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-basic/src/0000755000175000017500000000000011411772447021374 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-basic/src/main/0000755000175000017500000000000011411772447022320 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-basic/src/main/jjtree/0000755000175000017500000000000011411772447023603 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-basic/src/main/jjtree/Simple.jjt0000644000175000017500000000301510750714571025543 0ustar cavedoncavedon PARSER_BEGIN(Simple) class Simple { public static void main(String args[]) { System.out.println("Reading from standard input..."); Simple t = new Simple(System.in); try { SimpleNode n = t.Start(); n.dump(""); System.out.println("Thank you."); } catch (Exception e) { System.out.println("Oops."); System.out.println(e.getMessage()); e.printStackTrace(); } } } PARSER_END(Simple) SKIP : { " " | "\t" | "\n" | "\r" | <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")> | <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/"> } TOKEN : /* LITERALS */ { < INTEGER_LITERAL: (["l","L"])? | (["l","L"])? | (["l","L"])? > | < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* > | < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > | < #OCTAL_LITERAL: "0" (["0"-"7"])* > } TOKEN : /* IDENTIFIERS */ { < IDENTIFIER: (|)* > | < #LETTER: ["_","a"-"z","A"-"Z"] > | < #DIGIT: ["0"-"9"] > } SimpleNode Start() : {} { Expression() ";" { return jjtThis; } } void Expression() : {} { AdditiveExpression() } void AdditiveExpression() : {} { MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )* } void MultiplicativeExpression() : {} { UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )* } void UnaryExpression() : {} { "(" Expression() ")" | Identifier() | Integer() } void Identifier() : {} { } void Integer() : {} { } javacc-maven-plugin-2.6/src/it/jjtree-basic/verify.bsh0000644000175000017500000000124010750721311022571 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File outputFolder = new File( basedir, "target/generated-sources/jjtree" ); File nodeFile = new File( outputFolder, "Node.java"); if ( nodeFile.length() <= 0 ) { System.err.println( "Could not find generated java file: " + nodeFile ); return false; } File parserFile = new File( outputFolder, "Simple.jj"); if ( parserFile.length() <= 0 ) { System.err.println( "Could not find generated jj file: " + parserFile ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/jjtree-basic/invoker.properties0000644000175000017500000000004711020310351024353 0ustar cavedoncavedoninvoker.goals = clean generate-sources javacc-maven-plugin-2.6/src/it/jjtree-basic/pom.xml0000644000175000017500000000170110750721311022106 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check default execution. org.codehaus.mojo javacc-maven-plugin @pom.version@ jjtree-exec jjtree javacc-maven-plugin-2.6/src/it/jtb-dynamic-packages/0000755000175000017500000000000011411772445022216 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-dynamic-packages/src/0000755000175000017500000000000011411772445023005 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-dynamic-packages/src/main/0000755000175000017500000000000011411772445023731 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-dynamic-packages/src/main/jtb/0000755000175000017500000000000011411772445024510 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-dynamic-packages/src/main/jtb/Parser1.jtb0000644000175000017500000000205210751446444026530 0ustar cavedoncavedonPARSER_BEGIN(SubScheme) package parser1; import parser1.visit.DepthFirstVisitor; public class SubScheme { public static void main(String args[]) { SubScheme parser; System.out.println("Reading from standard input. . ."); parser = new SubScheme(System.in); try { Node root = parser.Unit(); System.out.println("Parsed successfully."); root.accept(new DepthFirstVisitor()); } catch (ParseException e) { System.out.println(e.getMessage()); System.out.println("Encountered errors during parse."); } } } PARSER_END(SubScheme) SKIP : /* WHITE SPACE */ { " " | "\t" | "\n" | "\r" | "\f" } TOKEN : { < LAMBDA : "lambda" > | < IDENT : (|)* > | < #LETTER: ["_","a"-"z","A"-"Z"] > | < #DIGIT : ["0"-"9"] > } void Unit() : {} { ( Exp() )+ } void Exp() : {} { | LOOKAHEAD(2) LambdaDecl() | LOOKAHEAD(2) "(" Exp() ( Exp() )* ")" | "0" | "(" "+" Exp() "1" ")" } void LambdaDecl() : {} { "(" "lambda" "(" ( )* ")" Exp() ")" } javacc-maven-plugin-2.6/src/it/jtb-dynamic-packages/src/main/jtb/Parser2.jtb0000644000175000017500000000205210751446444026531 0ustar cavedoncavedonPARSER_BEGIN(SubScheme) package parser2; import parser2.visit.DepthFirstVisitor; public class SubScheme { public static void main(String args[]) { SubScheme parser; System.out.println("Reading from standard input. . ."); parser = new SubScheme(System.in); try { Node root = parser.Unit(); System.out.println("Parsed successfully."); root.accept(new DepthFirstVisitor()); } catch (ParseException e) { System.out.println(e.getMessage()); System.out.println("Encountered errors during parse."); } } } PARSER_END(SubScheme) SKIP : /* WHITE SPACE */ { " " | "\t" | "\n" | "\r" | "\f" } TOKEN : { < LAMBDA : "lambda" > | < IDENT : (|)* > | < #LETTER: ["_","a"-"z","A"-"Z"] > | < #DIGIT : ["0"-"9"] > } void Unit() : {} { ( Exp() )+ } void Exp() : {} { | LOOKAHEAD(2) LambdaDecl() | LOOKAHEAD(2) "(" Exp() ( Exp() )* ")" | "0" | "(" "+" Exp() "1" ")" } void LambdaDecl() : {} { "(" "lambda" "(" ( )* ")" Exp() ")" } javacc-maven-plugin-2.6/src/it/jtb-dynamic-packages/verify.bsh0000644000175000017500000000362510751446444024231 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File outputFolder = new File( basedir, "target/generated-sources/jtb" ); { File nodeFile = new File( outputFolder, "parser1/ast/Node.java"); if ( !nodeFile.exists() || nodeFile.isDirectory() ) { System.err.println( "Could not find generated node file: " + nodeFile ); return false; } File visitorFile = new File( outputFolder, "parser1/visit/Visitor.java"); if ( !visitorFile.exists() || nodeFile.isDirectory() ) { System.err.println( "Could not find generated visitor file: " + visitorFile ); return false; } File parserFile = new File( outputFolder, "parser1/Parser1.jj"); if ( !parserFile.exists() || parserFile.isDirectory() ) { System.err.println( "Could not find generated jj file: " + parserFile ); return false; } } { File nodeFile = new File( outputFolder, "parser2/ast/Node.java"); if ( !nodeFile.exists() || nodeFile.isDirectory() ) { System.err.println( "Could not find generated node file: " + nodeFile ); return false; } File visitorFile = new File( outputFolder, "parser2/visit/Visitor.java"); if ( !visitorFile.exists() || nodeFile.isDirectory() ) { System.err.println( "Could not find generated visitor file: " + visitorFile ); return false; } File parserFile = new File( outputFolder, "parser2/Parser2.jj"); if ( !parserFile.exists() || parserFile.isDirectory() ) { System.err.println( "Could not find generated jj file: " + parserFile ); return false; } } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/jtb-dynamic-packages/invoker.properties0000644000175000017500000000007211257375102026005 0ustar cavedoncavedoninvoker.goals = clean compile invoker.java.version = 1.5+ javacc-maven-plugin-2.6/src/it/jtb-dynamic-packages/pom.xml0000644000175000017500000000244210751446444023540 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc jtb-basic jar 1.0-SNAPSHOT Integration Test http://maven.apache.org org.codehaus.mojo javacc-maven-plugin @pom.version@ jtb jtb *.ast *.visit maven-compiler-plugin 2.0.2 1.5 1.5 javacc-maven-plugin-2.6/src/it/jjtree-absent-source-directory/0000755000175000017500000000000011411772442024273 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-absent-source-directory/verify.bsh0000644000175000017500000000055710753140053026277 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File outputFolder = new File( basedir, "target" ); if ( outputFolder.exists() ) { System.err.println( "Found unexpected output folder: " + outputFolder ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/jjtree-absent-source-directory/invoker.properties0000644000175000017500000000004411020310351030043 0ustar cavedoncavedoninvoker.goals = clean javacc:jjtree javacc-maven-plugin-2.6/src/it/jjtree-absent-source-directory/pom.xml0000644000175000017500000000143510753140053025606 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check behavior when the source directory does not exist. org.codehaus.mojo javacc-maven-plugin @pom.version@ javacc-maven-plugin-2.6/src/it/jjdoc-basic-standalone/0000755000175000017500000000000011411772446022540 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjdoc-basic-standalone/src/0000755000175000017500000000000011411772446023327 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjdoc-basic-standalone/src/main/0000755000175000017500000000000011411772446024253 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjdoc-basic-standalone/src/main/javacc/0000755000175000017500000000000011411772446025502 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjdoc-basic-standalone/src/main/javacc/MyParser.jj0000644000175000017500000000051710750717475027602 0ustar cavedoncavedonPARSER_BEGIN(Parser) package org; public class Parser { public static void main(String args[]) throws ParseException { Parser parser = new Parser(System.in); parser.Input(); } } PARSER_END(Parser) void Input() : {} { MatchedBraces() ("\n"|"\r")* } void MatchedBraces() : {} { "{" [ MatchedBraces() ] "}" } javacc-maven-plugin-2.6/src/it/jjdoc-basic-standalone/verify.bsh0000644000175000017500000000164110753104624024537 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File siteOutputDir = new File( basedir, "target/site" ); if ( siteOutputDir.exists() ) { System.err.println( "Report was generated into wrong output directory!" ); return false; } File mojoOutputDir = new File( basedir, "target/it-site" ); /* FIXME: maven-reporting-impl:2.0.4 fails to output the sink contents File indexFile = new File( siteOutputDir, "jjdoc/index.html" ); if ( indexFile.length() <= 0 ) { System.out.println( "File is empty: " + indexFile ); return false; } */ File jjdocFile = new File( mojoOutputDir, "jjdoc/MyParser.html" ); if ( jjdocFile.length() <= 0 ) { System.out.println( "File is empty: " + jjdocFile ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/jjdoc-basic-standalone/invoker.properties0000644000175000017500000000004311020310351026303 0ustar cavedoncavedoninvoker.goals = clean javacc:jjdoc javacc-maven-plugin-2.6/src/it/jjdoc-basic-standalone/pom.xml0000644000175000017500000000253111250047556024054 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check report output during a standalone generation. org.codehaus.mojo javacc-maven-plugin @pom.version@ target/it-site maven-site-plugin @sitePluginVersion@ javacc-maven-plugin org.codehaus.mojo @pom.version@ target/it-site javacc-maven-plugin-2.6/src/it/settings.xml0000644000175000017500000000157611070224210020613 0ustar cavedoncavedon it-repo true local.central @localRepositoryUrl@ true true local.central @localRepositoryUrl@ true true javacc-maven-plugin-2.6/src/it/javacc-stale-detection/0000755000175000017500000000000011411772444022551 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-stale-detection/src/0000755000175000017500000000000011411772443023337 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-stale-detection/src/main/0000755000175000017500000000000011411772443024263 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-stale-detection/src/main/javacc/0000755000175000017500000000000011411772443025512 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-stale-detection/src/main/javacc/BasicParser.jj0000644000175000017500000000101110752663500030226 0ustar cavedoncavedon options { LOOKAHEAD = 1; CHOICE_AMBIGUITY_CHECK = 2; OTHER_AMBIGUITY_CHECK = 1; STATIC = true; DEBUG_PARSER = false; DEBUG_LOOKAHEAD = false; } PARSER_BEGIN(BasicParser) package parser; public class BasicParser { public static void main(String args[]) throws ParseException { BasicParser parser = new BasicParser(System.in); parser.Input(); } } PARSER_END(BasicParser) void Input() : {} { MatchedBraces() ("\n"|"\r")* } void MatchedBraces() : {} { "{" [ MatchedBraces() ] "}" } javacc-maven-plugin-2.6/src/it/javacc-stale-detection/src/main/java-base/0000755000175000017500000000000011411772443026114 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-stale-detection/src/main/java-base/parser/0000755000175000017500000000000011411772443027410 5ustar cavedoncavedon././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootjavacc-maven-plugin-2.6/src/it/javacc-stale-detection/src/main/java-base/parser/BasicParserConstants.javajavacc-maven-plugin-2.6/src/it/javacc-stale-detection/src/main/java-base/parser/BasicParserConstants0000644000175000017500000000042110752663500033423 0ustar cavedoncavedon/* Generated By:JavaCC: Do not edit this line. BasicParserConstants.java */ package parser; public interface BasicParserConstants { int EOF = 0; int DEFAULT = 0; String[] tokenImage = { "", "\"\\n\"", "\"\\r\"", "\"{\"", "\"}\"", }; } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootjavacc-maven-plugin-2.6/src/it/javacc-stale-detection/src/main/java-base/parser/SimpleCharStream.javajavacc-maven-plugin-2.6/src/it/javacc-stale-detection/src/main/java-base/parser/SimpleCharStream.jav0000644000175000017500000002661610752663500033330 0ustar cavedoncavedon/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 4.0 */ package parser; /** * An implementation of interface CharStream, where the stream is assumed to * contain only ASCII characters (without unicode processing). */ public class SimpleCharStream { public static final boolean staticFlag = true; static int bufsize; static int available; static int tokenBegin; static public int bufpos = -1; static protected int bufline[]; static protected int bufcolumn[]; static protected int column = 0; static protected int line = 1; static protected boolean prevCharIsCR = false; static protected boolean prevCharIsLF = false; static protected java.io.Reader inputStream; static protected char[] buffer; static protected int maxNextCharInd = 0; static protected int inBuf = 0; static protected int tabSize = 8; static protected void setTabSize(int i) { tabSize = i; } static protected int getTabSize(int i) { return tabSize; } static protected void ExpandBuff(boolean wrapAround) { char[] newbuffer = new char[bufsize + 2048]; int newbufline[] = new int[bufsize + 2048]; int newbufcolumn[] = new int[bufsize + 2048]; try { if (wrapAround) { System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); buffer = newbuffer; System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); bufline = newbufline; System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); bufcolumn = newbufcolumn; maxNextCharInd = (bufpos += (bufsize - tokenBegin)); } else { System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); buffer = newbuffer; System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); bufline = newbufline; System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); bufcolumn = newbufcolumn; maxNextCharInd = (bufpos -= tokenBegin); } } catch (Throwable t) { throw new Error(t.getMessage()); } bufsize += 2048; available = bufsize; tokenBegin = 0; } static protected void FillBuff() throws java.io.IOException { if (maxNextCharInd == available) { if (available == bufsize) { if (tokenBegin > 2048) { bufpos = maxNextCharInd = 0; available = tokenBegin; } else if (tokenBegin < 0) bufpos = maxNextCharInd = 0; else ExpandBuff(false); } else if (available > tokenBegin) available = bufsize; else if ((tokenBegin - available) < 2048) ExpandBuff(true); else available = tokenBegin; } int i; try { if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1) { inputStream.close(); throw new java.io.IOException(); } else maxNextCharInd += i; return; } catch(java.io.IOException e) { --bufpos; backup(0); if (tokenBegin == -1) tokenBegin = bufpos; throw e; } } static public char BeginToken() throws java.io.IOException { tokenBegin = -1; char c = readChar(); tokenBegin = bufpos; return c; } static protected void UpdateLineColumn(char c) { column++; if (prevCharIsLF) { prevCharIsLF = false; line += (column = 1); } else if (prevCharIsCR) { prevCharIsCR = false; if (c == '\n') { prevCharIsLF = true; } else line += (column = 1); } switch (c) { case '\r' : prevCharIsCR = true; break; case '\n' : prevCharIsLF = true; break; case '\t' : column--; column += (tabSize - (column % tabSize)); break; default : break; } bufline[bufpos] = line; bufcolumn[bufpos] = column; } static public char readChar() throws java.io.IOException { if (inBuf > 0) { --inBuf; if (++bufpos == bufsize) bufpos = 0; return buffer[bufpos]; } if (++bufpos >= maxNextCharInd) FillBuff(); char c = buffer[bufpos]; UpdateLineColumn(c); return (c); } /** * @deprecated * @see #getEndColumn */ static public int getColumn() { return bufcolumn[bufpos]; } /** * @deprecated * @see #getEndLine */ static public int getLine() { return bufline[bufpos]; } static public int getEndColumn() { return bufcolumn[bufpos]; } static public int getEndLine() { return bufline[bufpos]; } static public int getBeginColumn() { return bufcolumn[tokenBegin]; } static public int getBeginLine() { return bufline[tokenBegin]; } static public void backup(int amount) { inBuf += amount; if ((bufpos -= amount) < 0) bufpos += bufsize; } public SimpleCharStream(java.io.Reader dstream, int startline, int startcolumn, int buffersize) { if (inputStream != null) throw new Error("\n ERROR: Second call to the constructor of a static SimpleCharStream. You must\n" + " either use ReInit() or set the JavaCC option STATIC to false\n" + " during the generation of this class."); inputStream = dstream; line = startline; column = startcolumn - 1; available = bufsize = buffersize; buffer = new char[buffersize]; bufline = new int[buffersize]; bufcolumn = new int[buffersize]; } public SimpleCharStream(java.io.Reader dstream, int startline, int startcolumn) { this(dstream, startline, startcolumn, 4096); } public SimpleCharStream(java.io.Reader dstream) { this(dstream, 1, 1, 4096); } public void ReInit(java.io.Reader dstream, int startline, int startcolumn, int buffersize) { inputStream = dstream; line = startline; column = startcolumn - 1; if (buffer == null || buffersize != buffer.length) { available = bufsize = buffersize; buffer = new char[buffersize]; bufline = new int[buffersize]; bufcolumn = new int[buffersize]; } prevCharIsLF = prevCharIsCR = false; tokenBegin = inBuf = maxNextCharInd = 0; bufpos = -1; } public void ReInit(java.io.Reader dstream, int startline, int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } public void ReInit(java.io.Reader dstream) { ReInit(dstream, 1, 1, 4096); } public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException { this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); } public SimpleCharStream(java.io.InputStream dstream, int startline, int startcolumn, int buffersize) { this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); } public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, int startcolumn) throws java.io.UnsupportedEncodingException { this(dstream, encoding, startline, startcolumn, 4096); } public SimpleCharStream(java.io.InputStream dstream, int startline, int startcolumn) { this(dstream, startline, startcolumn, 4096); } public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { this(dstream, encoding, 1, 1, 4096); } public SimpleCharStream(java.io.InputStream dstream) { this(dstream, 1, 1, 4096); } public void ReInit(java.io.InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException { ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); } public void ReInit(java.io.InputStream dstream, int startline, int startcolumn, int buffersize) { ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); } public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { ReInit(dstream, encoding, 1, 1, 4096); } public void ReInit(java.io.InputStream dstream) { ReInit(dstream, 1, 1, 4096); } public void ReInit(java.io.InputStream dstream, String encoding, int startline, int startcolumn) throws java.io.UnsupportedEncodingException { ReInit(dstream, encoding, startline, startcolumn, 4096); } public void ReInit(java.io.InputStream dstream, int startline, int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } static public String GetImage() { if (bufpos >= tokenBegin) return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); else return new String(buffer, tokenBegin, bufsize - tokenBegin) + new String(buffer, 0, bufpos + 1); } static public char[] GetSuffix(int len) { char[] ret = new char[len]; if ((bufpos + 1) >= len) System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); else { System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, len - bufpos - 1); System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); } return ret; } static public void Done() { buffer = null; bufline = null; bufcolumn = null; } /** * Method to adjust line and column numbers for the start of a token. */ static public void adjustBeginLineColumn(int newLine, int newCol) { int start = tokenBegin; int len; if (bufpos >= tokenBegin) { len = bufpos - tokenBegin + inBuf + 1; } else { len = bufsize - tokenBegin + bufpos + 1 + inBuf; } int i = 0, j = 0, k = 0; int nextColDiff = 0, columnDiff = 0; while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) { bufline[j] = newLine; nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; bufcolumn[j] = newCol + columnDiff; columnDiff = nextColDiff; i++; } if (i < len) { bufline[j] = newLine++; bufcolumn[j] = newCol + columnDiff; while (i++ < len) { if (bufline[j = start % bufsize] != bufline[++start % bufsize]) bufline[j] = newLine++; else bufline[j] = newLine; } } line = bufline[j]; column = bufcolumn[j]; } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootjavacc-maven-plugin-2.6/src/it/javacc-stale-detection/src/main/java-base/parser/BasicParserTokenManager.javajavacc-maven-plugin-2.6/src/it/javacc-stale-detection/src/main/java-base/parser/BasicParserTokenMana0000644000175000017500000001016010752663500033325 0ustar cavedoncavedon/* Generated By:JavaCC: Do not edit this line. BasicParserTokenManager.java */ package parser; public class BasicParserTokenManager implements BasicParserConstants { public static java.io.PrintStream debugStream = System.out; public static void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } static private final int jjStopAtPos(int pos, int kind) { jjmatchedKind = kind; jjmatchedPos = pos; return pos + 1; } static private final int jjMoveStringLiteralDfa0_0() { switch(curChar) { case 10: return jjStopAtPos(0, 1); case 13: return jjStopAtPos(0, 2); case 123: return jjStopAtPos(0, 3); case 125: return jjStopAtPos(0, 4); default : return 1; } } static final int[] jjnextStates = { }; public static final String[] jjstrLiteralImages = { "", "\12", "\15", "\173", "\175", }; public static final String[] lexStateNames = { "DEFAULT", }; static protected SimpleCharStream input_stream; static private final int[] jjrounds = new int[0]; static private final int[] jjstateSet = new int[0]; static protected char curChar; public BasicParserTokenManager(SimpleCharStream stream){ if (input_stream != null) throw new TokenMgrError("ERROR: Second call to constructor of static lexer. You must use ReInit() to initialize the static variables.", TokenMgrError.STATIC_LEXER_ERROR); input_stream = stream; } public BasicParserTokenManager(SimpleCharStream stream, int lexState){ this(stream); SwitchTo(lexState); } static public void ReInit(SimpleCharStream stream) { jjmatchedPos = jjnewStateCnt = 0; curLexState = defaultLexState; input_stream = stream; ReInitRounds(); } static private final void ReInitRounds() { int i; jjround = 0x80000001; for (i = 0; i-- > 0;) jjrounds[i] = 0x80000000; } static public void ReInit(SimpleCharStream stream, int lexState) { ReInit(stream); SwitchTo(lexState); } static public void SwitchTo(int lexState) { if (lexState >= 1 || lexState < 0) throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); else curLexState = lexState; } static protected Token jjFillToken() { Token t = Token.newToken(jjmatchedKind); t.kind = jjmatchedKind; String im = jjstrLiteralImages[jjmatchedKind]; t.image = (im == null) ? input_stream.GetImage() : im; t.beginLine = input_stream.getBeginLine(); t.beginColumn = input_stream.getBeginColumn(); t.endLine = input_stream.getEndLine(); t.endColumn = input_stream.getEndColumn(); return t; } static int curLexState = 0; static int defaultLexState = 0; static int jjnewStateCnt; static int jjround; static int jjmatchedPos; static int jjmatchedKind; public static Token getNextToken() { int kind; Token specialToken = null; Token matchedToken; int curPos = 0; EOFLoop : for (;;) { try { curChar = input_stream.BeginToken(); } catch(java.io.IOException e) { jjmatchedKind = 0; matchedToken = jjFillToken(); return matchedToken; } jjmatchedKind = 0x7fffffff; jjmatchedPos = 0; curPos = jjMoveStringLiteralDfa0_0(); if (jjmatchedKind != 0x7fffffff) { if (jjmatchedPos + 1 < curPos) input_stream.backup(curPos - jjmatchedPos - 1); matchedToken = jjFillToken(); return matchedToken; } int error_line = input_stream.getEndLine(); int error_column = input_stream.getEndColumn(); String error_after = null; boolean EOFSeen = false; try { input_stream.readChar(); input_stream.backup(1); } catch (java.io.IOException e1) { EOFSeen = true; error_after = curPos <= 1 ? "" : input_stream.GetImage(); if (curChar == '\n' || curChar == '\r') { error_line++; error_column = 0; } else error_column++; } if (!EOFSeen) { input_stream.backup(1); error_after = curPos <= 1 ? "" : input_stream.GetImage(); } throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); } } } javacc-maven-plugin-2.6/src/it/javacc-stale-detection/src/main/java-base/parser/BasicParser.java0000644000175000017500000001501410752663500032452 0ustar cavedoncavedon/* UP-TO-DATE PARSER FILE - MUST NOT BE OVERWRITTEN BY JAVACC */ package parser; public class BasicParser implements BasicParserConstants { public static void main(String args[]) throws ParseException { BasicParser parser = new BasicParser(System.in); parser.Input(); } static final public void Input() throws ParseException { MatchedBraces(); label_1: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 1: case 2: ; break; default: jj_la1[0] = jj_gen; break label_1; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 1: jj_consume_token(1); break; case 2: jj_consume_token(2); break; default: jj_la1[1] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } jj_consume_token(0); } static final public void MatchedBraces() throws ParseException { jj_consume_token(3); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 3: MatchedBraces(); break; default: jj_la1[2] = jj_gen; ; } jj_consume_token(4); } static private boolean jj_initialized_once = false; static public BasicParserTokenManager token_source; static SimpleCharStream jj_input_stream; static public Token token, jj_nt; static private int jj_ntk; static private int jj_gen; static final private int[] jj_la1 = new int[3]; static private int[] jj_la1_0; static { jj_la1_0(); } private static void jj_la1_0() { jj_la1_0 = new int[] {0x6,0x6,0x8,}; } public BasicParser(java.io.InputStream stream) { this(stream, null); } public BasicParser(java.io.InputStream stream, String encoding) { if (jj_initialized_once) { System.out.println("ERROR: Second call to constructor of static parser. You must"); System.out.println(" either use ReInit() or set the JavaCC option STATIC to false"); System.out.println(" during parser generation."); throw new Error(); } jj_initialized_once = true; try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } token_source = new BasicParserTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 3; i++) jj_la1[i] = -1; } static public void ReInit(java.io.InputStream stream) { ReInit(stream, null); } static public void ReInit(java.io.InputStream stream, String encoding) { try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } token_source.ReInit(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 3; i++) jj_la1[i] = -1; } public BasicParser(java.io.Reader stream) { if (jj_initialized_once) { System.out.println("ERROR: Second call to constructor of static parser. You must"); System.out.println(" either use ReInit() or set the JavaCC option STATIC to false"); System.out.println(" during parser generation."); throw new Error(); } jj_initialized_once = true; jj_input_stream = new SimpleCharStream(stream, 1, 1); token_source = new BasicParserTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 3; i++) jj_la1[i] = -1; } static public void ReInit(java.io.Reader stream) { jj_input_stream.ReInit(stream, 1, 1); token_source.ReInit(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 3; i++) jj_la1[i] = -1; } public BasicParser(BasicParserTokenManager tm) { if (jj_initialized_once) { System.out.println("ERROR: Second call to constructor of static parser. You must"); System.out.println(" either use ReInit() or set the JavaCC option STATIC to false"); System.out.println(" during parser generation."); throw new Error(); } jj_initialized_once = true; token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 3; i++) jj_la1[i] = -1; } public void ReInit(BasicParserTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 3; i++) jj_la1[i] = -1; } static final private Token jj_consume_token(int kind) throws ParseException { Token oldToken; if ((oldToken = token).next != null) token = token.next; else token = token.next = token_source.getNextToken(); jj_ntk = -1; if (token.kind == kind) { jj_gen++; return token; } token = oldToken; jj_kind = kind; throw generateParseException(); } static final public Token getNextToken() { if (token.next != null) token = token.next; else token = token.next = token_source.getNextToken(); jj_ntk = -1; jj_gen++; return token; } static final public Token getToken(int index) { Token t = token; for (int i = 0; i < index; i++) { if (t.next != null) t = t.next; else t = t.next = token_source.getNextToken(); } return t; } static final private int jj_ntk() { if ((jj_nt=token.next) == null) return (jj_ntk = (token.next=token_source.getNextToken()).kind); else return (jj_ntk = jj_nt.kind); } static private java.util.Vector jj_expentries = new java.util.Vector(); static private int[] jj_expentry; static private int jj_kind = -1; static public ParseException generateParseException() { jj_expentries.removeAllElements(); boolean[] la1tokens = new boolean[5]; for (int i = 0; i < 5; i++) { la1tokens[i] = false; } if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 3; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1< */ public ParseException(Token currentTokenVal, int[][] expectedTokenSequencesVal, String[] tokenImageVal ) { super(""); specialConstructor = true; currentToken = currentTokenVal; expectedTokenSequences = expectedTokenSequencesVal; tokenImage = tokenImageVal; } /** * The following constructors are for use by you for whatever * purpose you can think of. Constructing the exception in this * manner makes the exception behave in the normal way - i.e., as * documented in the class "Throwable". The fields "errorToken", * "expectedTokenSequences", and "tokenImage" do not contain * relevant information. The JavaCC generated code does not use * these constructors. */ public ParseException() { super(); specialConstructor = false; } public ParseException(String message) { super(message); specialConstructor = false; } /** * This variable determines which constructor was used to create * this object and thereby affects the semantics of the * "getMessage" method (see below). */ protected boolean specialConstructor; /** * This is the last token that has been consumed successfully. If * this object has been created due to a parse error, the token * followng this token will (therefore) be the first error token. */ public Token currentToken; /** * Each entry in this array is an array of integers. Each array * of integers represents a sequence of tokens (by their ordinal * values) that is expected at this point of the parse. */ public int[][] expectedTokenSequences; /** * This is a reference to the "tokenImage" array of the generated * parser within which the parse error occurred. This array is * defined in the generated ...Constants interface. */ public String[] tokenImage; /** * This method has the standard behavior when this object has been * created using the standard constructors. Otherwise, it uses * "currentToken" and "expectedTokenSequences" to generate a parse * error message and returns it. If this object has been created * due to a parse error, and you do not catch it (it gets thrown * from the parser), then this method is called during the printing * of the final stack trace, and hence the correct error message * gets displayed. */ public String getMessage() { if (!specialConstructor) { return super.getMessage(); } StringBuffer expected = new StringBuffer(); int maxSize = 0; for (int i = 0; i < expectedTokenSequences.length; i++) { if (maxSize < expectedTokenSequences[i].length) { maxSize = expectedTokenSequences[i].length; } for (int j = 0; j < expectedTokenSequences[i].length; j++) { expected.append(tokenImage[expectedTokenSequences[i][j]]).append(" "); } if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { expected.append("..."); } expected.append(eol).append(" "); } String retval = "Encountered \""; Token tok = currentToken.next; for (int i = 0; i < maxSize; i++) { if (i != 0) retval += " "; if (tok.kind == 0) { retval += tokenImage[0]; break; } retval += add_escapes(tok.image); tok = tok.next; } retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; retval += "." + eol; if (expectedTokenSequences.length == 1) { retval += "Was expecting:" + eol + " "; } else { retval += "Was expecting one of:" + eol + " "; } retval += expected.toString(); return retval; } /** * The end of line string for this machine. */ protected String eol = System.getProperty("line.separator", "\n"); /** * Used to convert raw characters to their escaped version * when these raw version cannot be used as part of an ASCII * string literal. */ protected String add_escapes(String str) { StringBuffer retval = new StringBuffer(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { case 0 : continue; case '\b': retval.append("\\b"); continue; case '\t': retval.append("\\t"); continue; case '\n': retval.append("\\n"); continue; case '\f': retval.append("\\f"); continue; case '\r': retval.append("\\r"); continue; case '\"': retval.append("\\\""); continue; case '\'': retval.append("\\\'"); continue; case '\\': retval.append("\\\\"); continue; default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); retval.append("\\u" + s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } continue; } } return retval.toString(); } } javacc-maven-plugin-2.6/src/it/javacc-stale-detection/src/main/java-base/parser/Token.java0000644000175000017500000000513510752663500031337 0ustar cavedoncavedon/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */ package parser; /** * Describes the input token stream. */ public class Token { /** * An integer that describes the kind of this token. This numbering * system is determined by JavaCCParser, and a table of these numbers is * stored in the file ...Constants.java. */ public int kind; /** * beginLine and beginColumn describe the position of the first character * of this token; endLine and endColumn describe the position of the * last character of this token. */ public int beginLine, beginColumn, endLine, endColumn; /** * The string image of the token. */ public String image; /** * A reference to the next regular (non-special) token from the input * stream. If this is the last token from the input stream, or if the * token manager has not read tokens beyond this one, this field is * set to null. This is true only if this token is also a regular * token. Otherwise, see below for a description of the contents of * this field. */ public Token next; /** * This field is used to access special tokens that occur prior to this * token, but after the immediately preceding regular (non-special) token. * If there are no such special tokens, this field is set to null. * When there are more than one such special token, this field refers * to the last of these special tokens, which in turn refers to the next * previous special token through its specialToken field, and so on * until the first special token (whose specialToken field is null). * The next fields of special tokens refer to other special tokens that * immediately follow it (without an intervening regular token). If there * is no such token, this field is null. */ public Token specialToken; /** * Returns the image. */ public String toString() { return image; } /** * Returns a new Token object, by default. However, if you want, you * can create and return subclass objects based on the value of ofKind. * Simply add the cases to the switch for all those special cases. * For example, if you have a subclass of Token called IDToken that * you want to create if ofKind is ID, simlpy add something like : * * case MyParserConstants.ID : return new IDToken(); * * to the following switch statement. Then you can cast matchedToken * variable to the appropriate type and use it in your lexical actions. */ public static final Token newToken(int ofKind) { switch(ofKind) { default : return new Token(); } } } javacc-maven-plugin-2.6/src/it/javacc-stale-detection/src/main/java-base/parser/TokenMgrError.java0000644000175000017500000001014510752663500033014 0ustar cavedoncavedon/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */ package parser; public class TokenMgrError extends Error { /* * Ordinals for various reasons why an Error of this type can be thrown. */ /** * Lexical error occured. */ static final int LEXICAL_ERROR = 0; /** * An attempt wass made to create a second instance of a static token manager. */ static final int STATIC_LEXER_ERROR = 1; /** * Tried to change to an invalid lexical state. */ static final int INVALID_LEXICAL_STATE = 2; /** * Detected (and bailed out of) an infinite loop in the token manager. */ static final int LOOP_DETECTED = 3; /** * Indicates the reason why the exception is thrown. It will have * one of the above 4 values. */ int errorCode; /** * Replaces unprintable characters by their espaced (or unicode escaped) * equivalents in the given string */ protected static final String addEscapes(String str) { StringBuffer retval = new StringBuffer(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { case 0 : continue; case '\b': retval.append("\\b"); continue; case '\t': retval.append("\\t"); continue; case '\n': retval.append("\\n"); continue; case '\f': retval.append("\\f"); continue; case '\r': retval.append("\\r"); continue; case '\"': retval.append("\\\""); continue; case '\'': retval.append("\\\'"); continue; case '\\': retval.append("\\\\"); continue; default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); retval.append("\\u" + s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } continue; } } return retval.toString(); } /** * Returns a detailed message for the Error when it is thrown by the * token manager to indicate a lexical error. * Parameters : * EOFSeen : indicates if EOF caused the lexicl error * curLexState : lexical state in which this error occured * errorLine : line number when the error occured * errorColumn : column number when the error occured * errorAfter : prefix that was seen before this error occured * curchar : the offending character * Note: You can customize the lexical error message by modifying this method. */ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { return("Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered: " + (EOFSeen ? " " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + "after : \"" + addEscapes(errorAfter) + "\""); } /** * You can also modify the body of this method to customize your error messages. * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not * of end-users concern, so you can return something like : * * "Internal Error : Please file a bug report .... " * * from this method for such cases in the release version of your parser. */ public String getMessage() { return super.getMessage(); } /* * Constructors of various flavors follow. */ public TokenMgrError() { } public TokenMgrError(String message, int reason) { super(message); errorCode = reason; } public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); } } javacc-maven-plugin-2.6/src/it/javacc-stale-detection/verify.bsh0000644000175000017500000000121610752663500024552 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File file = new File( basedir, "target/generated-sources/javacc/parser/BasicParser.java" ); if ( !file.isFile() ) { System.err.println( "Could not find generated java file: " + file ); return false; } String contents = FileUtils.fileRead( file, "UTF-8" ); if ( !contents.startsWith( "/* UP-TO-DATE PARSER FILE" ) ) { System.err.println( "Parser file was overwritten although it was newer than the grammar" ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/javacc-stale-detection/invoker.properties0000644000175000017500000000003611020310351026320 0ustar cavedoncavedoninvoker.goals = clean compile javacc-maven-plugin-2.6/src/it/javacc-stale-detection/pom.xml0000644000175000017500000000332310752663500024066 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check detection of stale sources without timestamp files. maven-antrun-plugin 1.1 prepare-it generate-sources run org.codehaus.mojo javacc-maven-plugin @pom.version@ javacc javacc-maven-plugin-2.6/src/it/javacc-absent-source-directory/0000755000175000017500000000000011411772446024243 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-absent-source-directory/verify.bsh0000644000175000017500000000055710753140053026243 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File outputFolder = new File( basedir, "target" ); if ( outputFolder.exists() ) { System.err.println( "Found unexpected output folder: " + outputFolder ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/javacc-absent-source-directory/invoker.properties0000644000175000017500000000004411020310351030007 0ustar cavedoncavedoninvoker.goals = clean javacc:javacc javacc-maven-plugin-2.6/src/it/javacc-absent-source-directory/pom.xml0000644000175000017500000000143510753140053025552 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check behavior when the source directory does not exist. org.codehaus.mojo javacc-maven-plugin @pom.version@ javacc-maven-plugin-2.6/src/it/javacc-path-with-spaces/0000755000175000017500000000000011411772443022645 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-path-with-spaces/verify.bsh0000644000175000017500000000111710753140153024642 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File targetDir = new File( basedir, "target" ); if ( !targetDir.isDirectory() ) { System.err.println( "Missing output directory: " + targetDir ); return false; } File outFile = new File( targetDir, "java cc/org/codehaus/javacc/simple/BasicParser.java" ); if ( !outFile.isFile() ) { System.err.println( "Missing JavaCC output file: " + outFile ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/javacc-path-with-spaces/invoker.properties0000644000175000017500000000003611020310351026415 0ustar cavedoncavedoninvoker.goals = clean compile javacc-maven-plugin-2.6/src/it/javacc-path-with-spaces/sour ces/0000755000175000017500000000000011411772443024370 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-path-with-spaces/sour ces/javacc/0000755000175000017500000000000011411772443025617 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-path-with-spaces/sour ces/javacc/BasicParser.jj0000644000175000017500000000103510753140153030334 0ustar cavedoncavedon options { LOOKAHEAD = 1; CHOICE_AMBIGUITY_CHECK = 2; OTHER_AMBIGUITY_CHECK = 1; STATIC = true; DEBUG_PARSER = false; DEBUG_LOOKAHEAD = false; } PARSER_BEGIN(BasicParser) package org.codehaus.javacc.simple; public class BasicParser { public static void main(String args[]) throws ParseException { BasicParser parser = new BasicParser(System.in); parser.Input(); } } PARSER_END(BasicParser) void Input() : {} { MatchedBraces() ("\n"|"\r")* } void MatchedBraces() : {} { "{" [ MatchedBraces() ] "}" } javacc-maven-plugin-2.6/src/it/javacc-path-with-spaces/pom.xml0000644000175000017500000000225511250317142024156 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check handling of paths with spaces. org.codehaus.mojo javacc-maven-plugin @pom.version@ javacc javacc sour ces/javacc target/java cc 1.4 javacc-maven-plugin-2.6/src/it/javacc-reactor-build/0000755000175000017500000000000011411772445022222 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-reactor-build/verify.bsh0000644000175000017500000000160210753143026024216 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { { File target = new File( basedir, "target" ); if ( target.exists() ) { System.err.println( "Parent project has unexpected output: " + Arrays.asList( files ) ); return false; } } { File target = new File( basedir, "module/target" ); if ( !target.isDirectory() ) { System.err.println( "Sub module has no output folder: " + target ); return false; } File javacc = new File( target, "javacc/org/codehaus/javacc/simple/BasicParser.java" ); if ( !javacc.isFile() ) { System.err.println( "Sub module has no JavaCC output: " + javacc ); return false; } } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/javacc-reactor-build/invoker.properties0000644000175000017500000000003611020310351025770 0ustar cavedoncavedoninvoker.goals = clean compile javacc-maven-plugin-2.6/src/it/javacc-reactor-build/module/0000755000175000017500000000000011411772445023507 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-reactor-build/module/src/0000755000175000017500000000000011411772445024276 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-reactor-build/module/src/javacc/0000755000175000017500000000000011411772445025525 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-reactor-build/module/src/javacc/BasicParser.jj0000644000175000017500000000103510753143026030242 0ustar cavedoncavedon options { LOOKAHEAD = 1; CHOICE_AMBIGUITY_CHECK = 2; OTHER_AMBIGUITY_CHECK = 1; STATIC = true; DEBUG_PARSER = false; DEBUG_LOOKAHEAD = false; } PARSER_BEGIN(BasicParser) package org.codehaus.javacc.simple; public class BasicParser { public static void main(String args[]) throws ParseException { BasicParser parser = new BasicParser(System.in); parser.Input(); } } PARSER_END(BasicParser) void Input() : {} { MatchedBraces() ("\n"|"\r")* } void MatchedBraces() : {} { "{" [ MatchedBraces() ] "}" } javacc-maven-plugin-2.6/src/it/javacc-reactor-build/module/pom.xml0000644000175000017500000000203710753143026025021 0ustar cavedoncavedon 4.0.0 module Module http://maven.apache.org org.codehaus.mojo.javacc reactor-build 1.0-SNAPSHOT org.codehaus.mojo javacc-maven-plugin javacc src/javacc target/javacc javacc-maven-plugin-2.6/src/it/javacc-reactor-build/pom.xml0000644000175000017500000000202511250317142023524 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc reactor-build pom 1.0-SNAPSHOT Integration Test http://maven.apache.org Check handling of output directories during a reactor build. module org.codehaus.mojo javacc-maven-plugin @pom.version@ 1.4 javacc-maven-plugin-2.6/src/it/jtb-absent-source-directory/0000755000175000017500000000000011411772446023573 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jtb-absent-source-directory/verify.bsh0000644000175000017500000000055710753140053025573 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File outputFolder = new File( basedir, "target" ); if ( outputFolder.exists() ) { System.err.println( "Found unexpected output folder: " + outputFolder ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/jtb-absent-source-directory/invoker.properties0000644000175000017500000000007511257375102027364 0ustar cavedoncavedoninvoker.goals = clean javacc:jtb invoker.java.version = 1.5+ javacc-maven-plugin-2.6/src/it/jtb-absent-source-directory/pom.xml0000644000175000017500000000143510753140053025102 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check behavior when the source directory does not exist. org.codehaus.mojo javacc-maven-plugin @pom.version@ javacc-maven-plugin-2.6/src/it/javacc-grammar-in-source-root/0000755000175000017500000000000011411772443023775 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-grammar-in-source-root/src/0000755000175000017500000000000011411772442024563 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-grammar-in-source-root/src/main/0000755000175000017500000000000011411772442025507 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-grammar-in-source-root/src/main/java/0000755000175000017500000000000011411772442026430 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-grammar-in-source-root/src/main/java/test/0000755000175000017500000000000011411772442027407 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/javacc-grammar-in-source-root/src/main/java/test/Main.java0000644000175000017500000000017511113311543031127 0ustar cavedoncavedonpackage test; /** * A test class to check that the plugin does not cause duplicate class errors. */ public class Main { } javacc-maven-plugin-2.6/src/it/javacc-grammar-in-source-root/src/main/java/test/BasicParser.jj0000644000175000017500000000114711113311543032123 0ustar cavedoncavedon options { LOOKAHEAD = 1; CHOICE_AMBIGUITY_CHECK = 2; OTHER_AMBIGUITY_CHECK = 1; STATIC = true; DEBUG_PARSER = false; DEBUG_LOOKAHEAD = false; } PARSER_BEGIN(BasicParser) // This deliberately does not match the directory structure in which the grammar resides package test.parser; public class BasicParser { public static void main(String args[]) throws ParseException { BasicParser parser = new BasicParser(System.in); parser.Input(); } } PARSER_END(BasicParser) void Input() : {} { MatchedBraces() ("\n"|"\r")* } void MatchedBraces() : {} { "{" [ MatchedBraces() ] "}" } javacc-maven-plugin-2.6/src/it/javacc-grammar-in-source-root/verify.bsh0000644000175000017500000000060511113311543025765 0ustar cavedoncavedonimport java.io.*; import java.util.*; try { File file = new File( basedir, "target/generated-sources/javacc/test/parser/BasicParser.java" ); if ( !file.exists() || file.isDirectory() ) { System.err.println( "Could not find generated java file: " + file ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/javacc-grammar-in-source-root/invoker.properties0000644000175000017500000000003611113311543027554 0ustar cavedoncavedoninvoker.goals = clean compile javacc-maven-plugin-2.6/src/it/javacc-grammar-in-source-root/pom.xml0000644000175000017500000000221011250317142025275 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check setup where the grammar file resides inside a compile source root (e.g. src/main/java, c.f. MJAVACC-90) org.codehaus.mojo javacc-maven-plugin @pom.version@ src/main/java 1.4 javacc javacc-maven-plugin-2.6/src/it/jjtree-reactor-build/0000755000175000017500000000000011411772447022260 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-reactor-build/verify.bsh0000644000175000017500000000213110753143026024250 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { { File target = new File( basedir, "target" ); if ( target.exists() ) { System.err.println( "Parent project has unexpected output: " + Arrays.asList( files ) ); return false; } } { File target = new File( basedir, "module/target" ); if ( !target.isDirectory() ) { System.err.println( "Sub module has no output folder: " + target ); return false; } File jjtree = new File( target, "jjtree/org/Simple.jj" ); if ( !jjtree.isFile() ) { System.err.println( "Sub module has no JJTree output: " + jjtree ); return false; } File timestamp = new File( target, "jjtree-timestamps/Simple.jjt" ); if ( !timestamp.isFile() ) { System.err.println( "Sub module has no JJTree timestamp: " + timestamp ); return false; } } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/jjtree-reactor-build/invoker.properties0000644000175000017500000000003611020310351026024 0ustar cavedoncavedoninvoker.goals = clean compile javacc-maven-plugin-2.6/src/it/jjtree-reactor-build/module/0000755000175000017500000000000011411772447023545 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-reactor-build/module/src/0000755000175000017500000000000011411772447024334 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-reactor-build/module/src/jjtree/0000755000175000017500000000000011411772447025617 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-reactor-build/module/src/jjtree/Simple.jjt0000644000175000017500000000303010753143026027546 0ustar cavedoncavedonPARSER_BEGIN(Simple) package org; class Simple { public static void main(String args[]) { System.out.println("Reading from standard input..."); Simple t = new Simple(System.in); try { SimpleNode n = t.Start(); n.dump(""); System.out.println("Thank you."); } catch (Exception e) { System.out.println("Oops."); System.out.println(e.getMessage()); e.printStackTrace(); } } } PARSER_END(Simple) SKIP : { " " | "\t" | "\n" | "\r" | <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")> | <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/"> } TOKEN : /* LITERALS */ { < INTEGER_LITERAL: (["l","L"])? | (["l","L"])? | (["l","L"])? > | < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* > | < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > | < #OCTAL_LITERAL: "0" (["0"-"7"])* > } TOKEN : /* IDENTIFIERS */ { < IDENTIFIER: (|)* > | < #LETTER: ["_","a"-"z","A"-"Z"] > | < #DIGIT: ["0"-"9"] > } SimpleNode Start() : {} { Expression() ";" { return jjtThis; } } void Expression() : {} { AdditiveExpression() } void AdditiveExpression() : {} { MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )* } void MultiplicativeExpression() : {} { UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )* } void UnaryExpression() : {} { "(" Expression() ")" | Identifier() | Integer() } void Identifier() : {} { } void Integer() : {} { } javacc-maven-plugin-2.6/src/it/jjtree-reactor-build/module/pom.xml0000644000175000017500000000215710753143026025060 0ustar cavedoncavedon 4.0.0 module Module http://maven.apache.org org.codehaus.mojo.javacc reactor-build 1.0-SNAPSHOT org.codehaus.mojo javacc-maven-plugin jjtree src/jjtree target/jjtree target/jjtree-timestamps javacc-maven-plugin-2.6/src/it/jjtree-reactor-build/pom.xml0000644000175000017500000000166710753143026023600 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc reactor-build pom 1.0-SNAPSHOT Integration Test http://maven.apache.org Check handling of output directories during a reactor build. module org.codehaus.mojo javacc-maven-plugin @pom.version@ javacc-maven-plugin-2.6/src/it/jjtree-javacc-basic/0000755000175000017500000000000011411772446022031 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-javacc-basic/src/0000755000175000017500000000000011411772446022620 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-javacc-basic/src/main/0000755000175000017500000000000011411772446023544 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-javacc-basic/src/main/jjtree/0000755000175000017500000000000011411772446025027 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjtree-javacc-basic/src/main/jjtree/Simple.jjt0000644000175000017500000000303010753161035026757 0ustar cavedoncavedonPARSER_BEGIN(Simple) package org; class Simple { public static void main(String args[]) { System.out.println("Reading from standard input..."); Simple t = new Simple(System.in); try { SimpleNode n = t.Start(); n.dump(""); System.out.println("Thank you."); } catch (Exception e) { System.out.println("Oops."); System.out.println(e.getMessage()); e.printStackTrace(); } } } PARSER_END(Simple) SKIP : { " " | "\t" | "\n" | "\r" | <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")> | <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/"> } TOKEN : /* LITERALS */ { < INTEGER_LITERAL: (["l","L"])? | (["l","L"])? | (["l","L"])? > | < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* > | < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ > | < #OCTAL_LITERAL: "0" (["0"-"7"])* > } TOKEN : /* IDENTIFIERS */ { < IDENTIFIER: (|)* > | < #LETTER: ["_","a"-"z","A"-"Z"] > | < #DIGIT: ["0"-"9"] > } SimpleNode Start() : {} { Expression() ";" { return jjtThis; } } void Expression() : {} { AdditiveExpression() } void AdditiveExpression() : {} { MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )* } void MultiplicativeExpression() : {} { UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )* } void UnaryExpression() : {} { "(" Expression() ")" | Identifier() | Integer() } void Identifier() : {} { } void Integer() : {} { } javacc-maven-plugin-2.6/src/it/jjtree-javacc-basic/src/main/jjtree/Token.java0000644000175000017500000000155711105415044026746 0ustar cavedoncavedon/* CUSTOMIZED PARSER FILE - MUST NOT BE OVERWRITTEN BY JAVACC */ package org; public class Token { public int kind; public int beginLine, beginColumn, endLine, endColumn; public String image; public Token next; public Token specialToken; public Token() { } public Token( int kind ) { this( kind, null ); } public Token( int kind, String image ) { this.kind = kind; this.image = image; } public Object getValue() { return null; } public String toString() { return image; } public static Token newToken( int ofKind, String image ) { switch ( ofKind ) { default : return new Token( ofKind, image ); } } public static Token newToken( int ofKind ) { return newToken( ofKind, null ); } } javacc-maven-plugin-2.6/src/it/jjtree-javacc-basic/verify.bsh0000644000175000017500000000231111105412131024006 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { File javaccDir = new File( basedir, "target/generated-sources/javacc" ); File jjtreeDir = new File( basedir, "target/generated-sources/jjtree" ); File nodeFile = new File( jjtreeDir, "org/Node.java"); if ( nodeFile.length() <= 0 ) { System.err.println( "Could not find generated java file: " + nodeFile ); return false; } File parserFile = new File( javaccDir, "org/Simple.java"); if ( parserFile.length() <= 0 ) { System.err.println( "Could not find generated java file: " + parserFile ); return false; } File customFile = new File( javaccDir, "org/Token.java" ); if ( customFile.length() <= 0 ) { System.err.println( "Could not find generated java file: " + file ); return false; } String contents = FileUtils.fileRead( customFile, "UTF-8" ); if ( !contents.startsWith( "/* CUSTOMIZED PARSER FILE" ) ) { System.err.println( "Custom java file has been ignored or replaced with generated file" ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/jjtree-javacc-basic/invoker.properties0000644000175000017500000000003611020310351025576 0ustar cavedoncavedoninvoker.goals = clean compile javacc-maven-plugin-2.6/src/it/jjtree-javacc-basic/pom.xml0000644000175000017500000000207011250317142023332 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc it-test 1.0-SNAPSHOT Integration Test http://maven.apache.org Check combined execution of JJTree and JavaCC. org.codehaus.mojo javacc-maven-plugin @pom.version@ 1.4 jjtree-javacc jjtree-javacc javacc-maven-plugin-2.6/src/it/jjdoc-reactor-build/0000755000175000017500000000000011411772442022061 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjdoc-reactor-build/verify.bsh0000644000175000017500000000235410753143026024065 0ustar cavedoncavedonimport java.io.*; import java.util.*; import org.codehaus.plexus.util.*; try { { File target = new File( basedir, "target" ); if ( target.exists() ) { String[] files = target.list(); if ( files != null && ( files.length > 1 || !"site".equals( files[0] ) ) ) { System.err.println( "Parent project has unexpected output: " + Arrays.asList( files ) ); return false; } } File jjdoc = new File( target, "site/jjdoc" ); if ( jjdoc.exists() ) { System.err.println( "Parent project has unexpected JJDoc output: " + jjdoc ); return false; } } { File target = new File( basedir, "module/target" ); if ( !target.isDirectory() ) { System.err.println( "Sub module has no output folder: " + target ); return false; } File jjdoc = new File( target, "site/jjdoc/BasicParser.html" ); if ( !jjdoc.isFile() ) { System.err.println( "Sub module has no JJDoc output: " + jjdoc ); return false; } } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; javacc-maven-plugin-2.6/src/it/jjdoc-reactor-build/invoker.properties0000644000175000017500000000003311020310351025627 0ustar cavedoncavedoninvoker.goals = clean site javacc-maven-plugin-2.6/src/it/jjdoc-reactor-build/module/0000755000175000017500000000000011411772442023346 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjdoc-reactor-build/module/src/0000755000175000017500000000000011411772441024134 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjdoc-reactor-build/module/src/javacc/0000755000175000017500000000000011411772441025363 5ustar cavedoncavedonjavacc-maven-plugin-2.6/src/it/jjdoc-reactor-build/module/src/javacc/BasicParser.jj0000644000175000017500000000103510753143026030104 0ustar cavedoncavedon options { LOOKAHEAD = 1; CHOICE_AMBIGUITY_CHECK = 2; OTHER_AMBIGUITY_CHECK = 1; STATIC = true; DEBUG_PARSER = false; DEBUG_LOOKAHEAD = false; } PARSER_BEGIN(BasicParser) package org.codehaus.javacc.simple; public class BasicParser { public static void main(String args[]) throws ParseException { BasicParser parser = new BasicParser(System.in); parser.Input(); } } PARSER_END(BasicParser) void Input() : {} { MatchedBraces() ("\n"|"\r")* } void MatchedBraces() : {} { "{" [ MatchedBraces() ] "}" } javacc-maven-plugin-2.6/src/it/jjdoc-reactor-build/module/pom.xml0000644000175000017500000000214610753143026024664 0ustar cavedoncavedon 4.0.0 module Module http://maven.apache.org org.codehaus.mojo.javacc reactor-build 1.0-SNAPSHOT org.codehaus.mojo javacc-maven-plugin org.codehaus.mojo javacc-maven-plugin src/javacc target/jjdoc javacc-maven-plugin-2.6/src/it/jjdoc-reactor-build/pom.xml0000644000175000017500000000275211250047556023406 0ustar cavedoncavedon 4.0.0 org.codehaus.mojo.javacc reactor-build pom 1.0-SNAPSHOT Integration Test http://maven.apache.org Check handling of output directories during a reactor build. module org.codehaus.mojo javacc-maven-plugin @pom.version@ maven-site-plugin @sitePluginVersion@ org.codehaus.mojo javacc-maven-plugin @pom.version@ maven-project-info-reports-plugin 2.0.1 javacc-maven-plugin-2.6/pom.xml0000644000175000017500000001372211260504536016354 0ustar cavedoncavedon 4.0.0 mojo-parent org.codehaus.mojo 22 javacc-maven-plugin 2.6 maven-plugin JavaCC Maven Plugin Maven 2 Plugin for processing JavaCC grammar files. http://mojo.codehaus.org/javacc-maven-plugin/ 2005 The Apache Software License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.txt repo 2.0.6 scm:svn:http://svn.codehaus.org/mojo/tags/javacc-maven-plugin-2.6 scm:svn:https://svn.codehaus.org/mojo/tags/javacc-maven-plugin-2.6 http://fisheye.codehaus.org/browse/mojo/tags/javacc-maven-plugin-2.6 JIRA http://jira.codehaus.org/browse/MJAVACC org.apache.maven maven-plugin-api 2.0.4 org.apache.maven maven-project 2.0.4 org.apache.maven maven-model 2.0.4 net.java.dev.javacc javacc 5.0 org.codehaus.plexus plexus-utils 1.5.6 edu.ucla.cs.compilers jtb 1.3.2 runtime org.apache.maven.reporting maven-reporting-api 2.0.4 org.apache.maven.reporting maven-reporting-impl 2.0.4 org.apache.maven.doxia doxia-sink-api 1.0-alpha-9 org.apache.maven.doxia doxia-site-renderer 1.0-alpha-7 plexus plexus-utils junit junit 3.8.2 test run-its maven.test.skip !true 2.0.1 org.apache.maven.plugins maven-invoker-plugin 1.4 src/it ${project.build.directory}/it */pom.xml verify.bsh src/it/settings.xml ${project.build.directory}/local-repo true integration-test install run maven-3 ${basedir} 3.0-beta-1-SNAPSHOT