Debian Codegraph @

3rdparty/flite_hts_engine/flite/include/cst_tokenstream.h

raw symbols SCIP
1 /*************************************************************************/
2 /* */
3 /* Language Technologies Institute */
4 /* Carnegie Mellon University */
5 /* Copyright (c) 1999 */
6 /* All Rights Reserved. */
7 /* */
8 /* Permission is hereby granted, free of charge, to use and distribute */
9 /* this software and its documentation without restriction, including */
10 /* without limitation the rights to use, copy, modify, merge, publish, */
11 /* distribute, sublicense, and/or sell copies of this work, and to */
12 /* permit persons to whom this work is furnished to do so, subject to */
13 /* the following conditions: */
14 /* 1. The code must retain the above copyright notice, this list of */
15 /* conditions and the following disclaimer. */
16 /* 2. Any modifications must be clearly marked as such. */
17 /* 3. Original authors' names are not deleted. */
18 /* 4. The authors' names are not used to endorse or promote products */
19 /* derived from this software without specific prior written */
20 /* permission. */
21 /* */
22 /* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
23 /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24 /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25 /* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
26 /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27 /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28 /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29 /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30 /* THIS SOFTWARE. */
31 /* */
32 /*************************************************************************/
33 /* Author: Alan W Black ([email protected]) */
34 /* Date: July 1999 */
35 /*************************************************************************/
36 /* */
37 /* Tokenizer for strings and files */
38 /* */
39 /*************************************************************************/
40 #ifndef _CST_TOKENSTREAM_H__
41 #define _CST_TOKENSTREAM_H__
42
43 #include "cst_alloc.h"
44 #include "cst_string.h"
45 #include "cst_file.h"
46
47 typedef struct cst_tokenstream_struct {
48 cst_file fd;
49 int file_pos;
50 int line_number;
51 cst_string *string_buffer;
52
53 int current_char;
54
55 int token_pos;
56 int ws_max;
57 cst_string *whitespace;
58 int prep_max;
59 cst_string *prepunctuation;
60 int token_max;
61 cst_string *token;
62 int postp_max;
63 cst_string *postpunctuation;
64
65 /* Should only be set through set_charclasses as charclass table needs */
66 /* to be updated when you reset these */
67 const cst_string *p_whitespacesymbols;
68 const cst_string *p_singlecharsymbols;
69 const cst_string *p_prepunctuationsymbols;
70 const cst_string *p_postpunctuationsymbols;
71
72 cst_string charclass[256];
73 } cst_tokenstream;
74
75 #define TS_CHARCLASS_NONE 0
76 #define TS_CHARCLASS_WHITESPACE 2
77 #define TS_CHARCLASS_SINGLECHAR 4
78 #define TS_CHARCLASS_PREPUNCT 8
79 #define TS_CHARCLASS_POSTPUNCT 16
80 #define TS_CHARCLASS_QUOTE 32
81
82 #define ts_charclass(C,CLASS,TS) ((TS)->charclass[(unsigned char)C] & CLASS)
83
84 extern const cst_string * const cst_ts_default_whitespacesymbols;
85 extern const cst_string * const cst_ts_default_prepunctuationsymbols;
86 extern const cst_string * const cst_ts_default_postpunctuationsymbols;
87 extern const cst_string * const cst_ts_default_singlecharsymbols;
88
89 /* Public functions for tokenstream manipulation */
90 cst_tokenstream *ts_open(const char *filename,
91 const cst_string *whitespacesymbols,
92 const cst_string *singlecharsymbols,
93 const cst_string *prepunctsymbols,
94 const cst_string *postpunctsymbols);
95 cst_tokenstream *ts_open_string(const cst_string *string,
96 const cst_string *whitespacesymbols,
97 const cst_string *singlecharsymbols,
98 const cst_string *prepunctsymbols,
99 const cst_string *postpunctsymbols);
100 void ts_close(cst_tokenstream *ts);
101
102 int ts_eof(cst_tokenstream *ts);
103 const cst_string *ts_get(cst_tokenstream *ts);
104
105 const cst_string *ts_get_quoted_token(cst_tokenstream *ts,
106 char quote,
107 char escape);
108
109 void set_charclasses(cst_tokenstream *ts,
110 const cst_string *whitespace,
111 const cst_string *singlecharsymbols,
112 const cst_string *prepunctuation,
113 const cst_string *postpunctuation);
114
115 int ts_read(void *buff, int size, int num, cst_tokenstream *ts);
116
117 int ts_set_stream_pos(cst_tokenstream *ts,int pos);
118 int ts_get_stream_pos(cst_tokenstream *ts);
119
120 #endif