// compile with:
// g++ -Wall -O3 -I.. -I../.. -fno-exceptions save.cpp

// Write to standard output an ASCII representation of a tree-like DFA builded 
// from an ASCII dictionary containing one word per line (/usr/dict/word)
// Usage: a.out dictionary

#include <astl.h>
#include <dfa_map.h>
#include <astl_tree.h>
#include <cursor.h>
#include <ccopy.h>
#include <stream.h>
#include <iostream>
#include <fstream>
#include <iterator>
#include <string>

typedef DFA_map<Type_alphabet<char> > DFA;

int main(int argc, char **argv)
{
  DFA dfa;
  if (argc > 1) {
    ifstream f1;
    f1.open(argv[1], ios::in);
    if (!f1) exit(2);
    tree_build(dfa, istream_iterator<string>(f1), istream_iterator<string>());
    f1.close();
  }
  DFA_stream output(cout);
  ccopy(output, dfirstc(forwardc(dfa)));
}



