#include <stdio.h>
#include <curses.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "proto.h"
#include "phonemes.h"
#include "features.h"
#include "gen.h"

extern int yylex();
extern char *yytext;

static void
show_menu()
{
 /*TODO Generate this - use new Phoneme_name[] array and
    put examples in array too.
 */
  printf("VOWELS\n");
  printf("aa Bob   ae bat   ah but   ao bought    aw bout\n");
  printf("ax about axr bar  ay bite  eh bet       er bird\n");
  printf("exr bear ey bait  ih bit   ix impunity  ixr beer\n");
  printf("iy beet  ow boat  oxr boar oy boy       uh book\n");
  printf("uw boot  uxr poor yu beauty\n");
  printf("SONORANTS\n");
  printf("el\thh\thx\tll\tlx\trr\trx\tww\twh\tyy\n");
  printf("NASALS\n");
  printf("em\ten\tmm\tnn\tng\n");
  printf("FRICATIVES\n");
  printf("dh\tff\tss\tsh\tth\tvv\tzz\tzh\n");
  printf("PLOSIVES\n");
  printf("bb\tdd\tdx\tgg\tgp\tkk\tkp\tpp\ttt\ttq\n");
  printf("AFFRICATES\n");
  printf("ch\tjj\n");
  printf("PSUEDO_VOWELS\n");
  printf("axp\n");
  printf("Separate words with space end input with return\n");
  printf(": ");
}

int
read_phonemes(ph_list)
int *ph_list;
{int tty   = isatty(0);
 int count = 0;
 int token;
 if (tty)
  show_menu();
 while ((token = yylex()))
  {
   ph_list[count++] = token;
   if (token == lEND_LIST)
    return count;
  }
 if (tty)
  printf("\n");
 return count;
}

