Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cobol compiling feature thru the GNU Cobol compiler #34

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 28 additions & 23 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
# Eclipse
.classpath
.project
.settings/

# Intellij
.idea/
*.iml
*.iws

# Mac
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db

# Maven
log/
target/
# Eclipse
.classpath
.project
.settings/
.metadata/
.recommenders/

# Intellij
.idea/
*.iml
*.iws

# Mac
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db

# Maven
log/
target/

# Vim
*~
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
*
* Copyright 2002-2004 The Ant-Contrib project
*
* Licensed 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.
*/
package org.codehaus.mojo.natives.parser;

import java.io.IOException;
import java.io.Reader;
import java.util.Vector;

/**
* A parser that extracts #include statements from a Reader.
*
* @author Adam Murdoch
* @author Curt Arnold
*/
public final class CobolParser
extends AbstractParser
implements Parser
{
private final Vector<String> includes = new Vector<>();

private AbstractParserState newLineState;

public CobolParser()
{
AbstractParserState quote = new FilenameState( this, new char[] { '"' } );
AbstractParserState bracket = new FilenameState( this, new char[] { '>' } );
AbstractParserState postE = new PostE( this, bracket, quote );
//
// opy
//
AbstractParserState y = new LetterState( this, 'y', postE, null );
AbstractParserState p = new LetterState( this, 'p', y, null );
AbstractParserState o = new LetterState( this, 'o', p, null );
newLineState = new LetterState( this, 'o', o, null );
}

@Override
public void addFilename( String include )
{
includes.addElement( include );
}

@Override
public String[] getIncludes()
{
String[] retval = new String[includes.size()];

includes.copyInto( retval );

return retval;
}

@Override
public AbstractParserState getNewLineState()
{
return newLineState;
}

@Override
public void parse( Reader reader )
throws IOException
{
includes.setSize( 0 );

super.parse( reader );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ public PostE( CParser parser, AbstractParserState bracket, AbstractParserState q
this.quote = quote;
}

public AbstractParserState consume( char ch )
public PostE(CobolParser parser, AbstractParserState bracket, AbstractParserState quote) {
super( parser );
this.bracket = bracket;
this.quote = quote;
}

public AbstractParserState consume( char ch )
{
switch ( ch )
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package org.codehaus.mojo.natives.c;

import static org.junit.Assert.assertArrayEquals;

import java.io.File;

import org.codehaus.mojo.natives.compiler.CompilerConfiguration;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.util.cli.Commandline;
import static org.junit.Assert.assertArrayEquals;

public class CCompilerClassicTest
extends PlexusTestCase
Expand All @@ -22,6 +23,7 @@ public void testSimpleCompilation()
CompilerConfiguration config = new CompilerConfiguration();
CCompilerClassic compiler = new CCompilerClassic();
Commandline cl = compiler.getCommandLine( new File( "source.c" ), new File( "object.o" ), config );
assertArrayEquals( new String[] { "gcc", "-oobject.o", "-c", "source.c" }, cl.getCommandline() );
String[] commandLine = cl.getRawCommandline();
assertArrayEquals( new String[] { "gcc", "-oobject.o", "-c", "source.c" }, commandLine );
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package org.codehaus.mojo.natives.c;

import static org.junit.Assert.assertArrayEquals;

import java.io.File;

import org.codehaus.mojo.natives.compiler.CompilerConfiguration;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.util.Os;
import org.codehaus.plexus.util.cli.Commandline;
import static org.junit.Assert.*;

public class CCompilerTest
extends PlexusTestCase
Expand Down Expand Up @@ -33,7 +36,7 @@ public void testSimpleCompilation()
{
Commandline cl = compiler.getCommandLine( sourceFile, objectFile, config );
assertArrayEquals( new String[] { "gcc", simpleArgv[0], simpleArgv[1], simpleArgv[2], simpleArgv[3] },
cl.getCommandline() );
cl.getRawCommandline() );
}

public void testNonDefaultExecutable()
Expand All @@ -42,7 +45,7 @@ public void testNonDefaultExecutable()
this.config.setExecutable( "cc" );
Commandline cl = compiler.getCommandLine( sourceFile, objectFile, config );
assertArrayEquals( new String[] { "cc", simpleArgv[0], simpleArgv[1], simpleArgv[2], simpleArgv[3] },
cl.getCommandline() );
cl.getRawCommandline() );
}

public void testStartOptions()
Expand All @@ -54,8 +57,8 @@ public void testStartOptions()
Commandline cl = compiler.getCommandLine( sourceFile, objectFile, config );

assertArrayEquals(
new String[] { "gcc", "-s1", "-s2", simpleArgv[0], simpleArgv[1], simpleArgv[2], simpleArgv[3] },
cl.getCommandline() );
new String[] { "gcc", "-s1", "-s2", simpleArgv[0], simpleArgv[1], simpleArgv[2], simpleArgv[3] },
cl.getRawCommandline() );
}

public void testIncludePaths()
Expand All @@ -69,7 +72,7 @@ public void testIncludePaths()

assertArrayEquals(
new String[] { "gcc", "-Ip1", "-Ip2", simpleArgv[0], simpleArgv[1], simpleArgv[2], simpleArgv[3] },
cl.getCommandline() );
cl.getRawCommandline() );
}

public void testSystemIncludePaths()
Expand All @@ -86,7 +89,7 @@ public void testSystemIncludePaths()
Commandline cl = compiler.getCommandLine( sourceFile, objectFile, config );

assertArrayEquals( new String[] { "gcc", "-Ip1", "-Ip2", "-Isp1", "-Isp2", simpleArgv[0], simpleArgv[1],
simpleArgv[2], simpleArgv[3] }, cl.getCommandline() );
simpleArgv[2], simpleArgv[3] }, cl.getRawCommandline() );
}

public void testMiddleOptions()
Expand All @@ -103,7 +106,7 @@ public void testMiddleOptions()
Commandline cl = compiler.getCommandLine( sourceFile, objectFile, config );

assertArrayEquals( new String[] { "gcc", "-s1", "-s2", "-Ip1", "-Ip2", "-m1", "-m2", simpleArgv[0],
simpleArgv[1], simpleArgv[2], simpleArgv[3] }, cl.getCommandline() );
simpleArgv[1], simpleArgv[2], simpleArgv[3] }, cl.getRawCommandline() );
}

public void testEndOptions()
Expand All @@ -122,6 +125,6 @@ public void testEndOptions()
Commandline cl = compiler.getCommandLine( sourceFile, objectFile, config );

assertArrayEquals( new String[] { "gcc", "-s1", "-s2", "-Ip1", "-Ip2", "-m1", "-m2", simpleArgv[0],
simpleArgv[1], simpleArgv[2], simpleArgv[3], "-e1", "-e2" }, cl.getCommandline() );
simpleArgv[1], simpleArgv[2], simpleArgv[3], "-e1", "-e2" }, cl.getRawCommandline() );
}
}
22 changes: 22 additions & 0 deletions maven-native-components/maven-native-gnucobol/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

The MIT License

Copyright (c) 2004, The Codehaus

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
27 changes: 27 additions & 0 deletions maven-native-components/maven-native-gnucobol/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.codehaus.mojo.natives</groupId>
<artifactId>maven-native-components</artifactId>
<version>1.0-alpha-12-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>maven-native-gnucobol</artifactId>
<name>Maven Native Cobol</name>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-annotations</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Loading