4#ifndef OHCOUNT_PARSER_MACROS_H
5#define OHCOUNT_PARSER_MACROS_H
72 if (!item) printf(
"Failed to allocate memory for enqueued callback.\n");
109 line_start = last_line_start; \
110 line_contains_code = last_line_contains_code; \
111 whole_line_comment = last_whole_line_comment; \
120 if (inqueue) { dequeue; } \
121 if (!line_start) line_start = ts; \
131 if (inqueue) { dequeue; } \
132 if (!line_contains_code && !line_start) line_start = ts; \
133 line_contains_code = 1; \
142 if (inqueue) { dequeue; } \
143 if (!line_contains_code) { \
144 whole_line_comment = 1; \
145 if (!line_start) line_start = ts; \
159 whole_line_comment = 0; \
160 line_contains_code = 0; \
169#define std_internal_newline(lang) { \
170 if (callback && p > line_start) { \
171 if (line_contains_code) { \
173 enqueue(lang, "lcode", cint(line_start), cint(p), userdata); \
175 callback(lang, "lcode", cint(line_start), cint(p), userdata); \
176 } else if (whole_line_comment) { \
178 enqueue(lang, "lcomment", cint(line_start), cint(p), userdata); \
180 callback(lang, "lcomment", cint(line_start), cint(p), userdata); \
183 enqueue(lang, "lblank", cint(line_start), cint(p), userdata); \
185 callback(lang, "lblank", cint(line_start), cint(p), userdata); \
188 whole_line_comment = 0; \
189 line_contains_code = 0; \
201#define emb_internal_newline(lang) { \
202 if (seen && seen != lang) \
203 std_internal_newline(seen) \
205 std_internal_newline(lang) \
215#define std_newline(lang) {\
216 if (inqueue) { dequeue; } \
217 if (callback && te > line_start) { \
218 if (line_contains_code) \
219 callback(lang, "lcode", cint(line_start), cint(te), userdata); \
220 else if (whole_line_comment) \
221 callback(lang, "lcomment", cint(line_start), cint(te), userdata); \
223 callback(lang, "lblank", cint(ts), cint(te), userdata); \
225 whole_line_comment = 0; \
226 line_contains_code = 0; \
238#define emb_newline(lang) { \
239 if (seen && seen != lang) \
253#define process_last_line(lang) {\
254 if ((whole_line_comment || line_contains_code) && callback) { \
255 if (line_contains_code) \
256 callback(lang, "lcode", cint(line_start), cint(pe), userdata); \
257 else if (whole_line_comment) \
258 callback(lang, "lcomment", cint(line_start), cint(pe), userdata); \
272 while (*pos !=
'\n' && *pos !=
'\r' && *pos !=
'\f') {
273 if (*pos !=
'\t' && *pos !=
' ')
return 0;
276 if (*pos ==
'\r' && *(pos+1) ==
'\n') pos++;
291#define check_blank_entry(lang) { \
292 if (is_blank_entry(&p)) { \
312#define INTERNAL_NL -2
321#define CHECK_BLANK_ENTRY -3
359#define cint(c) ((int) (c - buffer_start))
419 pe = buffer + length; \
422 buffer_start = buffer; \
423 whole_line_comment = 0; \
424 line_contains_code = 0; \
int last_whole_line_comment
Definition: parser_macros.h:411
char * eof
Definition: parser_macros.h:336
int stack[5]
Definition: parser_macros.h:345
char * last_line_start
Definition: parser_macros.h:399
const char * seen
Definition: parser_macros.h:386
int is_blank_entry(char **p)
Definition: parser_macros.h:270
char * ts
Definition: parser_macros.h:339
char * pe
Definition: parser_macros.h:333
char * te
Definition: parser_macros.h:342
int act
Definition: parser_macros.h:327
Callback * callback_list_head
Definition: parser_macros.h:44
struct CallbackItem Callback
int whole_line_comment
Definition: parser_macros.h:365
void free_queue()
Definition: parser_macros.h:91
int line_contains_code
Definition: parser_macros.h:371
char * line_start
Definition: parser_macros.h:377
Callback * callback_list_tail
Definition: parser_macros.h:47
int inqueue
Definition: parser_macros.h:393
char * p
Definition: parser_macros.h:330
int last_line_contains_code
Definition: parser_macros.h:405
void enqueue(const char *lang, const char *entity, int s, int e, void *udata)
Definition: parser_macros.h:70
int cs
Definition: parser_macros.h:324
int entity
Definition: parser_macros.h:380
char * buffer_start
Definition: parser_macros.h:351
int top
Definition: parser_macros.h:348
Holds a series of callbacks for in a queue (linked list).
Definition: parser_macros.h:16
const char * entity
Definition: parser_macros.h:27
const char * lang
Definition: parser_macros.h:21
int s
Definition: parser_macros.h:30
void * udata
Definition: parser_macros.h:36
int e
Definition: parser_macros.h:33
struct CallbackItem * next
Definition: parser_macros.h:39