treeh.h 1.43 KB
#ifndef TREEH_H
#define TREEH_H

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <ctype.h>

#define NBCHAR 26 //A-Z

#define NOT_AN_END 0x00

#define COMMON_END 0x03
#define PROPER_END 0x0C
#define ACRONYME_END 0x30

#define STRAIGHT_END 0x15
#define APOSTROPHE_END 0x2A

typedef char *string,byte;
typedef struct _node node, *tree;
struct _node{
  char letter;
  byte isEnd;
  //0 no,1 yes,+2 if ends with 's
  //*4 if proper, *16 if allUpper 
  node* next[NBCHAR];
};

tree make_empty_tree();//create a null node*
node* make_empty_node();//malloc a node and initialize it
node* make_node(char,byte);//id
void delete_tree(tree*);//free(tree) and delete tree on all t->next

bool is_empty(const tree);//==NULL
bool is_followed(const tree);//if true tree has following letters


//endKind functions
bool is_end(const tree);//true when  at least 1 of the following functions is true
bool is_straight_end(const tree);//if true word can end here
bool ends_with_apostrophe(const tree);//if true word can end here with apostrophe
bool is_common_end(const tree);//if true all letters are lower
bool is_proper_end(const tree);//if true 1st letter is upper  
bool is_acronyme_end(const tree);//if true all letters are upper


//other
int hash(char);//need to check if isalpha
bool ischar_of_word(char);//tells if char can be in a word
bool is_word(byte endKind);//pass end_kind() as parameter
byte end_kind(string);


#endif //TREEH_H