Index: app/src/tok.c/Makefile
===================================================================
--- app/src/tok.c/Makefile	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
+++ app/src/tok.c/Makefile	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
@@ -0,0 +1,37 @@
+PAR=-Wno-deprecated -O3
+PAR2=-c -Wno-deprecated -O3
+LIB_PATH=../lib
+CMDLINE_FILE='"../tok.c/cmdline.h"'
+
+
+tok: tok.o cmdline.c common_tok.o common.o
+	g++ $(PAR) tok.c cmdline.c common.o common_tok.o -o tok
+
+tok.o: tok.c cmdline.h 
+	g++ $(PAR2) tok.c
+
+common_tok.o: cmdline.h  common_tok.cc common_tok.h
+	g++ $(PAR2) common_tok.cc
+
+common.o: $(COMMON_PATH)/cmdline_common.ggo $(COMMON_PATH)/common.cc\
+	 $(COMMON_PATH)/common.h
+	g++ $(PAR2) -D _CMDLINE_FILE=$(CMDLINE_FILE) $(COMMON_PATH)/common.cc
+
+cmdline.ggo: cmdline_tok.ggo ../common/cmdline_common.ggo
+	cat cmdline_tok.ggo ../common/cmdline_common.ggo > cmdline.ggo
+
+cmdline.c cmdline.h: cmdline.ggo
+	gengetopt -i cmdline.ggo --conf-parser
+
+
+copy:
+ifdef UTT_BIN_DIR
+    cp tok ${UTT_BIN_DIR}/
+endif
+
+
+clean: clean.cmdline
+	rm *.o
+
+clean.cmdline:
+	rm cmdline.*
Index: app/src/tok.c/cmdline_tok.ggo
===================================================================
--- app/src/tok.c/cmdline_tok.ggo	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
+++ app/src/tok.c/cmdline_tok.ggo	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
@@ -0,0 +1,4 @@
+package "tok"
+version "0.1"
+
+
Index: app/src/tok.c/common_tok.cc
===================================================================
--- app/src/tok.c/common_tok.cc	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
+++ app/src/tok.c/common_tok.cc	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
@@ -0,0 +1,27 @@
+#include <stdlib.h>
+#include <string.h>
+#include "common_tok.h"
+
+char dictionary[255];
+
+void process_tok_options(gengetopt_args_info args)
+{
+  if(args.dictionary_given)
+    strcpy(dictionary, args.dictionary_arg);
+  else {
+    char path[256];
+    sprintf(path, "/etc/utt/%s", DICT_FILE);
+    if (file_accessible(path) == 0)
+      strcpy(dictionary, path);
+    else {
+      sprintf(path, "%s/.utt/%s", getenv("HOME"), DICT_FILE);
+      if (file_accessible(path) == 0)
+	strcpy(dictionary, path);
+      else {
+	fprintf(stderr, "Cannot find dictionary!\n");
+	exit(1);
+      }
+    }
+  }
+
+}
Index: app/src/tok.c/common_tok.h
===================================================================
--- app/src/tok.c/common_tok.h	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
+++ app/src/tok.c/common_tok.h	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
@@ -0,0 +1,16 @@
+#ifndef __COMMON_TOK__H
+#define __COMMON_TOK__H
+
+#include <stdio.h>
+#define _CMDLINE_FILE "../tok.c/cmdline.h"
+#include "../common/common.h"
+
+#include "cmdline.h"
+
+#define DICT_FILE "data/tok.bin"
+
+extern char dictionary[];
+
+extern void process_tok_options(gengetopt_args_info args);
+
+#endif
Index: app/src/tok.c/tok.c
===================================================================
--- app/src/tok.c/tok.c	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
+++ app/src/tok.c/tok.c	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
@@ -0,0 +1,83 @@
+
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+#include <locale.h>
+
+
+#include <stdlib.h>
+//#include "../lib/iotools.h"
+
+#include "cmdline.h"
+
+
+char buf[257];
+int filepos=0;
+char* tokstart;
+char* tokend;
+char tmp;
+char tag;
+
+
+gengetopt_args_info args;
+
+
+inline
+void printtoken(char tag)
+{
+  tmp=*tokend;
+  *tokend='\0';
+  printf("%04d %02d %c %s\n", filepos, tokend-tokstart, tag, tokstart);
+  *tokend=tmp;
+  filepos+=tokend-tokstart;
+  tokstart=tokend;
+  if(args.interactive_flag) fflush(stdout);
+}
+
+main(int argc, char** argv)
+{
+
+  if (cmdline_parser(argc, argv, &args) != 0)
+    exit(1);
+
+  printf("inter:%d\n",args.interactive_flag);
+
+  //  process_common_options(&args, argv[0]);
+  //  process_tok_options(args);
+
+  setlocale(LC_CTYPE,"");
+  setlocale(LC_COLLATE,"");
+
+  while(fgets(buf,256,stdin))
+  {
+
+    tokstart=tokend=buf;
+    while(*tokend)
+    {
+      char *prev=tokend;
+      ++tokend;
+      if(isalpha(*prev) && !isalpha(*tokend))
+         printtoken('W');
+      else if(isdigit(*prev) && !isdigit(*tokend))
+        printtoken('N');
+      else if(isspace(*prev))
+        {
+          switch(*prev)
+            {
+            case ' ': *prev='_'; break;
+            case '\t':*prev='t'; break;
+            case '\r':*prev='r'; break;
+            case '\f':*prev='f'; break;
+            case '\n':*prev='n';
+            }
+          if(!isspace(*tokend))
+            printtoken('S');
+        }
+      else if(ispunct(*prev))
+         printtoken('P');
+    }
+  }
+
+  cmdline_parser_free(&args);
+}
+
