4 #define MAX_TOK_LEN 4096
11 struct tokenizer_getc_buf
{
17 MT_SINGLELINE_COMMENT_START
= 0,
18 MT_MULTILINE_COMMENT_START
= 1,
19 MT_MULTILINE_COMMENT_END
= 2,
20 MT_MAX
= MT_MULTILINE_COMMENT_END
23 #define MAX_CUSTOM_TOKENS 32
35 /* errors and similar */
41 TT_CUSTOM
= 1000 /* start user defined tokentype values */
44 const char* tokentype_to_str(enum tokentype tt
);
53 enum tokenizer_flags
{
54 TF_PARSE_STRINGS
= 1 << 0,
55 TF_PARSE_WIDE_STRINGS
= 1 << 1,
65 const char *custom_tokens
[MAX_CUSTOM_TOKENS
];
66 char buf
[MAX_TOK_LEN
];
68 struct tokenizer_getc_buf getc_buf
;
69 const char* marker
[MT_MAX
+1];
71 struct token peek_token
;
74 void tokenizer_init(struct tokenizer
*t
, FILE* in
, int flags
);
75 void tokenizer_set_filename(struct tokenizer
*t
, const char*);
76 void tokenizer_set_flags(struct tokenizer
*t
, int flags
);
77 int tokenizer_get_flags(struct tokenizer
*t
);
78 off_t
tokenizer_ftello(struct tokenizer
*t
);
79 void tokenizer_register_marker(struct tokenizer
*, enum markertype
, const char*);
80 void tokenizer_register_custom_token(struct tokenizer
*, int tokentype
, const char*);
81 int tokenizer_next(struct tokenizer
*t
, struct token
* out
);
82 int tokenizer_peek_token(struct tokenizer
*t
, struct token
* out
);
83 int tokenizer_peek(struct tokenizer
*t
);
84 void tokenizer_skip_until(struct tokenizer
*t
, const char *marker
);
85 int tokenizer_skip_chars(struct tokenizer
*t
, const char *chars
, int *count
);
86 int tokenizer_read_until(struct tokenizer
*t
, const char* marker
, int stop_at_nl
);
87 int tokenizer_rewind(struct tokenizer
*t
);
90 #pragma GCC diagnostic ignored "-Wunknown-pragmas"
92 #pragma RcB2 DEP "tokenizer.c"