import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
-import jp.sourceforge.mikutoga.parser.MmdSource;
-import jp.sourceforge.mikutoga.parser.pmd.PmdParser;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
+import jp.sfjp.mikutoga.pmd.parser.PmdParser;
/**
* パーサ利用のサンプルプログラム。
+ * これはユニットテストではない。
*/
public class DummyMain {
private static final DummyHandler handler = new DummyHandler();
static{
- PMDFILE = "D:\\Test\\test.pmd";
+ PMDFILE =
+ "D:\\Test\\test.pmd";
+ }
+
+ /**
+ * アプリを終了する。
+ * 制御は戻らない。
+ * @param code 終了コード。
+ */
+ private static void exit(int code){
+ System.exit(code);
+ assert false;
+ return;
+ }
+
+ /**
+ * 標準エラー出力にエラー情報を出し改行する。
+ * @param text エラー情報文字列
+ */
+ private static void errprintln(Object text){
+ System.err.println(text);
+ return;
}
/**
* @param fname ファイル名
* @return 入力ソース
*/
- private static MmdSource buildSource(String fname){
+ private static InputStream buildSource(String fname){
File file = new File(fname);
InputStream is;
try{
is = new FileInputStream(file);
}catch(FileNotFoundException e){
- System.err.println(e);
- System.exit(1);
+ errprintln(e);
+ exit(1);
return null;
}
- is = new BufferedInputStream(is, BUF_SZ);
- MmdSource source = new MmdSource(is);
+ is = new BufferedInputStream(is, BUF_SZ);
- return source;
+ return is;
}
/**
if(args.length == 1) fname = args[0];
else fname = PMDFILE;
- MmdSource source = buildSource(fname);
+ InputStream source = buildSource(fname);
PmdParser parser = new PmdParser(source);
try{
parser.parsePmd();
}catch(IOException e){
- System.err.println(e);
- System.exit(1);
+ errprintln(e);
+ exit(1);
}catch(MmdFormatException e){
- System.err.println(e);
- System.exit(1);
+ errprintln(e);
+ exit(1);
}
- System.exit(0);
+ exit(0);
return;
}