// Path: src/main/java/se/liu/imt/mi/snomedct/parser/SignatureVisitor.java
// public class SignatureVisitor extends SNOMEDCTExpressionBaseVisitor<Boolean> {
// 	
// 	private Set<String> sctidSet = new HashSet<String>();
// 
// 	public Set<String> getSctidSet() {
// 		return sctidSet;
// 	}
// 
// 	/* (non-Javadoc)
// 	 * @see se.liu.imt.mi.snomedct.expression.SNOMEDCTExpressionBaseVisitor#visitStatement(se.liu.imt.mi.snomedct.expression.SNOMEDCTExpressionParser.StatementContext)
// 	 */
// 	@Override
// 	public Boolean visitStatement(StatementContext ctx) {
// 		SubExpressionContext sec = ctx.getChild(SubExpressionContext.class, 1);
// 		if(sec != null)
// 			return visitSubExpression(sec);
// 		return true;
// 	}
// 
// 	@Override
// 	public Boolean visitConceptReference(ConceptReferenceContext ctx) {
// 		
// 		String sctid = ctx.getChild(0).getText();
// 		sctidSet.add(sctid);
// 		
// 		return true;
// 	}
// 
// }


import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import org.antlr.v4.runtime.misc.ParseCancellationException;
import org.antlr.v4.runtime.tree.ParseTree;
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.Options;
import org.apache.commons.cli.ParseException;
import org.apache.log4j.Logger;
import org.semanticweb.owlapi.model.OWLException;
import se.liu.imt.mi.snomedct.parser.SignatureVisitor;
			System.exit(1);
		}
		
		String format = cmd.getOptionValue("format", "url");

		List<?> argList = (List<?>) cmd.getArgList();
		if (argList.size() < 1) {
			HelpFormatter f = new HelpFormatter();
			f.printHelp("SNOMEDCTTranslator", options);
			System.exit(2);
		}

		// get input file name from argument list
		String inputFileName = (String) argList.get(0);
		// get output file name from argument list or create a new output file
		// name from the input file name
		String outputFileName;
		if (argList.size() < 2) {
			// separate out the extension (after last '.')
			String[] tokens = inputFileName.split("\\.(?=[^\\.]+$)");
			if (tokens.length >= 2)
				outputFileName = tokens[0] + "_signature.txt";
			else
				outputFileName = inputFileName + "_signature.txt";
		} else
			outputFileName = (String) argList.get(1);

		try {
			InputStream is = new FileInputStream(inputFileName);
			ParseTree tree = SNOMEDCTParserUtil.parseFile(is);
// Path: src/main/java/se/liu/imt/mi/snomedct/parser/SignatureVisitor.java
// public class SignatureVisitor extends SNOMEDCTExpressionBaseVisitor<Boolean> {
// 	
// 	private Set<String> sctidSet = new HashSet<String>();
// 
// 	public Set<String> getSctidSet() {
// 		return sctidSet;
// 	}
// 
// 	/* (non-Javadoc)
// 	 * @see se.liu.imt.mi.snomedct.expression.SNOMEDCTExpressionBaseVisitor#visitStatement(se.liu.imt.mi.snomedct.expression.SNOMEDCTExpressionParser.StatementContext)
// 	 */
// 	@Override
// 	public Boolean visitStatement(StatementContext ctx) {
// 		SubExpressionContext sec = ctx.getChild(SubExpressionContext.class, 1);
// 		if(sec != null)
// 			return visitSubExpression(sec);
// 		return true;
// 	}
// 
// 	@Override
// 	public Boolean visitConceptReference(ConceptReferenceContext ctx) {
// 		
// 		String sctid = ctx.getChild(0).getText();
// 		sctidSet.add(sctid);
// 		
// 		return true;
// 	}
// 
// }


// Path: src/main/java/se/liu/imt/mi/snomedct/expression/tools/SNOMEDCTSignatureGenerator.java
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import org.antlr.v4.runtime.misc.ParseCancellationException;
import org.antlr.v4.runtime.tree.ParseTree;
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.Options;
import org.apache.commons.cli.ParseException;
import org.apache.log4j.Logger;
import org.semanticweb.owlapi.model.OWLException;
import se.liu.imt.mi.snomedct.parser.SignatureVisitor;

			System.exit(1);
		}
		
		String format = cmd.getOptionValue("format", "url");

		List<?> argList = (List<?>) cmd.getArgList();
		if (argList.size() < 1) {
			HelpFormatter f = new HelpFormatter();
			f.printHelp("SNOMEDCTTranslator", options);
			System.exit(2);
		}

		// get input file name from argument list
		String inputFileName = (String) argList.get(0);
		// get output file name from argument list or create a new output file
		// name from the input file name
		String outputFileName;
		if (argList.size() < 2) {
			// separate out the extension (after last '.')
			String[] tokens = inputFileName.split("\\.(?=[^\\.]+$)");
			if (tokens.length >= 2)
				outputFileName = tokens[0] + "_signature.txt";
			else
				outputFileName = inputFileName + "_signature.txt";
		} else
			outputFileName = (String) argList.get(1);

		try {
			InputStream is = new FileInputStream(inputFileName);
			ParseTree tree = SNOMEDCTParserUtil.parseFile(is);
			SignatureVisitor visitor = new SignatureVisitor();