Commit 5326d433 authored by Fred Eisele's avatar Fred Eisele
Browse files

selection of parser to run is command line option "-p antlr4" or "-p combinator"

parent 00744e3c
......@@ -19,4 +19,4 @@ buildSrc/build/
*.iws
*.dvi
.gradle/
bin/
......@@ -132,6 +132,7 @@ repositories {
dependencies {
compile group: 'net.sourceforge.collections', name: 'collections-generic', version:'4.01'
compile group: 'commons-cli', name: 'commons-cli', version:'1.4'
compile group: 'org.apache.commons', name: 'commons-csv', version:'1.5'
compile group: 'org.apache.commons', name: 'commons-exec', version:'1.3'
compile group: 'org.apache.commons', name: 'commons-lang3', version:'3.7'
......
......@@ -3,13 +3,13 @@ package catdata.aql.exp;
public abstract class AqlParserFactory {
enum Mode {
public enum Mode {
COMBINATOR,
ANTLR4
}
public static Mode mode =
Mode.ANTLR4;
// Mode.COMBINATOR ;
// Mode.ANTLR4;
Mode.COMBINATOR ;
protected AqlParserFactory() { }
......
......@@ -6,6 +6,14 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
......@@ -15,6 +23,7 @@ import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.WindowConstants;
import catdata.Pair;
import catdata.aql.exp.AqlParserFactory;
import catdata.ide.IdeOptions.IdeOption;
/**
......@@ -47,6 +56,51 @@ public class IDE {
} */
public static void main(String... args) {
final Options options = new Options();
options.addOption(Option.builder("p")
.longOpt("aqlparser")
.required(false)
.desc("aql parser engine")
.hasArg()
.build());
options.addOption(Option.builder("i")
.longOpt("input")
.required(false)
.desc("input file")
.hasArgs()
.build());
final CommandLineParser cmdlineParser = new DefaultParser();
final HelpFormatter formatter = new HelpFormatter();
CommandLine tempCmdLine = null;
try {
tempCmdLine = cmdlineParser.parse(options, args);
} catch (ParseException e) {
System.out.println(e.getMessage());
formatter.printHelp("utility-name", options);
System.exit(1);
}
final CommandLine cmdLine = tempCmdLine;
String aqlParser = cmdLine.getOptionValue("aqlparser","combinator");
switch (aqlParser.toLowerCase()) {
case "combinator":
System.out.println("combinator parser used");
AqlParserFactory.mode = AqlParserFactory.Mode.COMBINATOR;
break;
case "antlr4":
System.out.println("antlr4 parser used");
AqlParserFactory.mode = AqlParserFactory.Mode.ANTLR4;
break;
default:
System.out.println("default combinator parser used");
AqlParserFactory.mode = AqlParserFactory.Mode.COMBINATOR;
break;
}
System.setProperty("apple.eawt.quitStrategy", "CLOSE_ALL_WINDOWS");
//apple.awt.application.name
......@@ -79,12 +133,16 @@ public class IDE {
}
});
if (args.length == 0) {
String[] inputFilePath = cmdLine.getOptionValues("input");
if (inputFilePath == null) {
GUI.newAction(null, "", Language.getDefault());
}
else if (inputFilePath.length == 0) {
GUI.newAction(null, "", Language.getDefault());
} else {
File[] fs = new File[args.length];
File[] fs = new File[inputFilePath.length];
int i = 0;
for (String s : args) {
for (String s : inputFilePath) {
fs[i++] = new File(s);
}
GUI.openAction(fs);
......@@ -99,4 +157,4 @@ public class IDE {
});
}
}
\ No newline at end of file
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment