public static void main(String[] args) throws IOException {
		BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));

		System.out.print("Enter a regexp: ");
		String regexp = keyboard.readLine();
		ConvertRegexpToNFA nfaBuilder = new ConvertRegexpToNFA(regexp);
		FiniteAutomaton a = nfaBuilder.convertToNFA();
		
		if (DEBUG) {
			System.out.println("NFA:");
			PrintAutomaton pa = new PrintAutomaton();
			pa.print(a);
		}
		
		System.out.println("Initial automaton is " +
				(FiniteAutomatonUtil.isDeterministic(a) ? "deterministic" : "nondeterministic"));
		
		System.out.print("Convert the automaton to a DFA (yes/no)? ");
		boolean convert = keyboard.readLine().toLowerCase(Locale.US).equals("yes");
		if (convert) {
			ConvertNFAToDFA dfaBuilder = new ConvertNFAToDFA();
			dfaBuilder.add(a);
			a = dfaBuilder.execute(FiniteAutomatonTransformerMode.NONDESTRUCTIVE);

			if (DEBUG) {
				System.out.println("DFA:");
				PrintAutomaton pa = new PrintAutomaton();
				pa.print(a);
			}

			System.out.println("Converted automaton is " +
					(FiniteAutomatonUtil.isDeterministic(a) ? "deterministic" : "nondeterministic"));
		}

		ExecuteFiniteAutomaton executor = convert ? new ExecuteDFA() : new ExecuteNFA();
		executor.setAutomaton(a);

		System.out.println("Enter strings:");
		for (;;) {
			String line = keyboard.readLine();
			if (line == null) {
				break;
			}
			
			System.out.println(executor.execute(line));
		}
	}