Skip to content

Commit

Permalink
Removed build dependency on Ant (now relies on name conventions inste…
Browse files Browse the repository at this point in the history
…ad).
  • Loading branch information
cederberg committed Feb 7, 2009
1 parent 54b4ac8 commit 4ee60eb
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 89 deletions.
Binary file removed lib/ant-1.7.1.jar
Binary file not shown.
15 changes: 7 additions & 8 deletions src/java/net/percederberg/grammatica/ant/CSharpElement.java
Expand Up @@ -24,8 +24,6 @@
import java.io.File;
import java.io.IOException;

import org.apache.tools.ant.BuildException;

import net.percederberg.grammatica.Grammar;
import net.percederberg.grammatica.output.CSharpParserGenerator;

Expand Down Expand Up @@ -63,6 +61,7 @@ public class CSharpElement implements ProcessingElement {
* Creates a new C# output element.
*/
public CSharpElement() {
// Nothing to do here
}

/**
Expand Down Expand Up @@ -107,12 +106,12 @@ public void setPublic(boolean publicAccess) {
/**
* Validates all attributes in the element.
*
* @throws BuildException if some attribute was missing or had an
* @throws RuntimeException if some attribute was missing or had an
* invalid value
*/
public void validate() throws BuildException {
public void validate() throws RuntimeException {
if (dir == null) {
throw new BuildException(
throw new RuntimeException(
"missing 'dir' attribute in <csharp> element");
}
}
Expand All @@ -122,10 +121,10 @@ public void validate() throws BuildException {
*
* @param grammar the grammar to process
*
* @throws BuildException if the grammar couldn't be processed
* @throws RuntimeException if the grammar couldn't be processed
* correctly
*/
public void process(Grammar grammar) throws BuildException {
public void process(Grammar grammar) throws RuntimeException {
CSharpParserGenerator gen = new CSharpParserGenerator(grammar);

gen.setBaseDir(dir);
Expand All @@ -141,7 +140,7 @@ public void process(Grammar grammar) throws BuildException {
gen.write();
System.out.println("Done.");
} catch (IOException e) {
throw new BuildException(e);
throw new RuntimeException(e);
}
}
}
28 changes: 13 additions & 15 deletions src/java/net/percederberg/grammatica/ant/GrammaticaTask.java
Expand Up @@ -25,9 +25,6 @@
import java.io.FileNotFoundException;
import java.util.Vector;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;

import net.percederberg.grammatica.Grammar;
import net.percederberg.grammatica.GrammarException;
import net.percederberg.grammatica.parser.ParserLogException;
Expand All @@ -39,7 +36,7 @@
* @version 1.5
* @since 1.4
*/
public class GrammaticaTask extends Task {
public class GrammaticaTask {

/**
* The grammar file to process.
Expand All @@ -60,6 +57,7 @@ public class GrammaticaTask extends Task {
* Creates a new Grammatica Ant task.
*/
public GrammaticaTask() {
// Nothing to do here
}

/**
Expand Down Expand Up @@ -119,18 +117,18 @@ public void addVisualBasic(VisualBasicElement elem) {
/**
* Executes the task.
*
* @throws BuildException if the task execution failed
* @throws RuntimeException if the task execution failed
*/
public void execute() throws BuildException {
public void execute() throws RuntimeException {
Grammar grammar;
int i;

// Validate all elements
if (file == null) {
throw new BuildException("missing 'grammar' attribute");
throw new RuntimeException("missing 'grammar' attribute");
}
if (processors.size() <= 0) {
throw new BuildException(
throw new RuntimeException(
"missing <validate>, <java>, <csharp> or <visualbasic> " +
"inner element");
}
Expand All @@ -142,7 +140,7 @@ public void execute() throws BuildException {
try {
grammar = new Grammar(file);
} catch (FileNotFoundException e) {
throw new BuildException(e);
throw new RuntimeException(e);
} catch (ParserLogException e) {
handleError(e);
return;
Expand All @@ -155,7 +153,7 @@ public void execute() throws BuildException {
for (i = 0; i < processors.size(); i++) {
try {
((ProcessingElement) processors.get(i)).process(grammar);
} catch (BuildException e) {
} catch (RuntimeException e) {
handleError(e);
}
}
Expand All @@ -167,14 +165,14 @@ public void execute() throws BuildException {
*
* @param e the error exception
*
* @throws BuildException if the build should fail on errors
* @throws RuntimeException if the build should fail on errors
*/
private void handleError(Exception e) throws BuildException {
private void handleError(Exception e) throws RuntimeException {
if (failOnError) {
if (e instanceof BuildException) {
throw (BuildException) e;
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else {
throw new BuildException(e);
throw new RuntimeException(e);
}
}
System.err.println("ERROR: " + e.getMessage());
Expand Down
15 changes: 7 additions & 8 deletions src/java/net/percederberg/grammatica/ant/JavaElement.java
Expand Up @@ -24,8 +24,6 @@
import java.io.File;
import java.io.IOException;

import org.apache.tools.ant.BuildException;

import net.percederberg.grammatica.Grammar;
import net.percederberg.grammatica.output.JavaParserGenerator;

Expand Down Expand Up @@ -63,6 +61,7 @@ public class JavaElement implements ProcessingElement {
* Creates a new Java output element.
*/
public JavaElement() {
// Nothing to do here
}

/**
Expand Down Expand Up @@ -107,12 +106,12 @@ public void setPublic(boolean publicAccess) {
/**
* Validates all attributes in the element.
*
* @throws BuildException if some attribute was missing or had an
* @throws RuntimeException if some attribute was missing or had an
* invalid value
*/
public void validate() throws BuildException {
public void validate() throws RuntimeException {
if (dir == null) {
throw new BuildException(
throw new RuntimeException(
"missing 'dir' attribute in <java> element");
}
}
Expand All @@ -122,10 +121,10 @@ public void validate() throws BuildException {
*
* @param grammar the grammar to process
*
* @throws BuildException if the grammar couldn't be processed
* @throws RuntimeException if the grammar couldn't be processed
* correctly
*/
public void process(Grammar grammar) throws BuildException {
public void process(Grammar grammar) throws RuntimeException {
JavaParserGenerator gen = new JavaParserGenerator(grammar);

gen.setBaseDir(dir);
Expand All @@ -141,7 +140,7 @@ public void process(Grammar grammar) throws BuildException {
gen.write();
System.out.println("Done.");
} catch (IOException e) {
throw new BuildException(e);
throw new RuntimeException(e);
}
}
}
10 changes: 4 additions & 6 deletions src/java/net/percederberg/grammatica/ant/ProcessingElement.java
Expand Up @@ -21,8 +21,6 @@

package net.percederberg.grammatica.ant;

import org.apache.tools.ant.BuildException;

import net.percederberg.grammatica.Grammar;

/**
Expand All @@ -39,18 +37,18 @@ public interface ProcessingElement {
/**
* Validates all attributes in the element.
*
* @throws BuildException if some attribute was missing or had an
* @throws RuntimeException if some attribute was missing or had an
* invalid value
*/
void validate() throws BuildException;
void validate() throws RuntimeException;

/**
* Proceses the specified grammar.
*
* @param grammar the grammar to process
*
* @throws BuildException if the grammar couldn't be processed
* @throws RuntimeException if the grammar couldn't be processed
* correctly
*/
void process(Grammar grammar) throws BuildException;
void process(Grammar grammar) throws RuntimeException;
}

0 comments on commit 4ee60eb

Please sign in to comment.