include/libtu/tokenizer.h

changeset 35
5a71d53d0228
parent 21
6d4282804e73
child 36
63cd573ffbcf
equal deleted inserted replaced
34:828f3afd5c76 35:5a71d53d0228
121 121
122 enum{ 122 enum{
123 TOKZ_IGNORE_NEXTLINE=0x1, 123 TOKZ_IGNORE_NEXTLINE=0x1,
124 TOKZ_READ_COMMENTS=0x2, 124 TOKZ_READ_COMMENTS=0x2,
125 TOKZ_PARSER_INDENT_MODE=0x04, 125 TOKZ_PARSER_INDENT_MODE=0x04,
126 TOKZ_ERROR_TOLERANT=0x8 126 TOKZ_ERROR_TOLERANT=0x8,
127 TOKZ_READ_FROM_BUFFER=0x10,
128 TOKZ_DEFAULT_OPTION=0x20
127 }; 129 };
128 130
129 131
130 enum{ 132 enum{
131 E_TOKZ_UNEXPECTED_EOF=1, 133 E_TOKZ_UNEXPECTED_EOF=1,
161 int line; 163 int line;
162 int ungetc; 164 int ungetc;
163 Token ungettok; 165 Token ungettok;
164 } Tokenizer_FInfo; 166 } Tokenizer_FInfo;
165 167
168 typedef struct _Tokenizer_Buffer{
169 char *data;
170 int len;
171 int pos;
172 } Tokenizer_Buffer;
173
166 typedef struct _Tokenizer{ 174 typedef struct _Tokenizer{
167 FILE *file; 175 FILE *file;
168 char *name; 176 char *name;
169 int line; 177 int line;
170 int ungetc; 178 int ungetc;
171 Token ungettok; 179 Token ungettok;
172 180
181 Tokenizer_Buffer buffer;
182
173 int flags; 183 int flags;
174 const struct _ConfOpt **optstack; 184 const struct _ConfOpt **optstack;
175 int nest_lvl; 185 int nest_lvl;
176 void *user_data; 186 void *user_data;
177 187
182 } Tokenizer; 192 } Tokenizer;
183 193
184 194
185 extern Tokenizer *tokz_open(const char *fname); 195 extern Tokenizer *tokz_open(const char *fname);
186 extern Tokenizer *tokz_open_file(FILE *file, const char *fname); 196 extern Tokenizer *tokz_open_file(FILE *file, const char *fname);
197 extern Tokenizer *tokz_prepare_buffer(char *buffer, int len);
187 extern void tokz_close(Tokenizer *tokz); 198 extern void tokz_close(Tokenizer *tokz);
188 extern bool tokz_get_token(Tokenizer *tokz, Token *tok); 199 extern bool tokz_get_token(Tokenizer *tokz, Token *tok);
189 extern void tokz_unget_token(Tokenizer *tokz, Token *tok); 200 extern void tokz_unget_token(Tokenizer *tokz, Token *tok);
190 extern void tokz_warn_error(const Tokenizer *tokz, int line, int e); 201 extern void tokz_warn_error(const Tokenizer *tokz, int line, int e);
191 extern void tokz_warn(const Tokenizer *tokz, int line, const char *fmt, ...); 202 extern void tokz_warn(const Tokenizer *tokz, int line, const char *fmt, ...);

mercurial