blob: 488b9fd16a56ee9c092e7910c873ee46b2651fce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
package com.jantuomi.interpreter.main;
import com.jantuomi.interpreter.main.core.CommandLineArgumentContainer;
import com.jantuomi.interpreter.main.core.parser.Parser;
import com.jantuomi.interpreter.main.core.tokenizer.Tokenizer;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
public class Main {
public static void main(String[] args) throws Exception {
boolean parseSuccess = parseArguments(args);
if (!parseSuccess) {
throw new Exception("Argument files could not be parsed successfully.");
}
String sourceFileContents = CommandLineArgumentContainer.getInstance().getSourceFileContents();
Tokenizer tokenizer = Tokenizer.getInstance();
tokenizer.tokenize(sourceFileContents);
Parser.getInstance().parse(tokenizer.getTokens());
}
public static boolean parseArguments(String[] args) {
CommandLineArgumentContainer container = CommandLineArgumentContainer.getInstance();
CmdLineParser parser = new CmdLineParser(container);
try {
parser.parseArgument(args);
} catch (CmdLineException e) {
System.err.println(e.getMessage());
parser.printUsage(System.err);
return false;
}
return true;
}
}
|