1 /*
2  *  Copyright (C) 2014  Christian Heckendorf <heckendorfc@gmail.com>
3  *
4  *  This program is free software: you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation, either version 3 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 
19 #ifndef LEX_H
20 #define LEX_H
21 
22 /* Maxumum word length */
23 #define NUM_CANDIDATE 5
24 
25 enum SplitPlace{
26 	SPLIT_BEFORE=1,
27 	SPLIT_AFTER=2,
28 };
29 
30 #include <stdlib.h>
31 #include <stdio.h>
32 #include <string.h>
33 #include <assert.h>
34 
35 #include "lex_dfa.h"
36 
37 
38 typedef struct Token{
39 	char *word;
40 	int type;
41 }Token;
42 
43 typedef struct TokenList{
44 	Token token;
45 	struct TokenList *next;
46 }TokenList;
47 
48 
49 #ifdef TEST_MODE
50 #define STATIC
51 int split_token(TokenList *token, const int start, const int word_i);
52 int identify(TokenList *token,State *q);
53 int identify_full(TokenList *token, State *q);
54 void strip_backslash(Token *token);
55 TokenList* create_tokens(char *str);
56 #else
57 #define STATIC static
58 #endif
59 
60 void free_tokens(TokenList *t);
61 TokenList* lex(const char *str);
62 
63 #endif
64