 |
Open Broadcaster Software
Free, open source software for live streaming and recording
|
Go to the documentation of this file.
33 #define PARSE_SUCCESS 0
34 #define PARSE_CONTINUE -1
35 #define PARSE_BREAK -2
36 #define PARSE_UNEXPECTED_CONTINUE -3
37 #define PARSE_UNEXPECTED_BREAK -4
48 static inline void cf_parser_init(
struct cf_parser *parser)
57 static inline void cf_parser_free(
struct cf_parser *parser)
66 static inline bool cf_parser_parse(
struct cf_parser *parser,
const char *
str,
75 parser->
cur_token = cf_preprocessor_get_tokens(&parser->
pp);
80 const char *val1,
const char *val2,
const char *val3);
82 static inline void cf_adderror_expecting(
struct cf_parser *p,
88 static inline void cf_adderror_unexpected_eof(
struct cf_parser *p)
93 static inline void cf_adderror_syntax_error(
struct cf_parser *p)
98 static inline bool cf_next_token(
struct cf_parser *p)
112 static inline bool cf_next_valid_token(
struct cf_parser *p)
114 if (!cf_next_token(p)) {
115 cf_adderror_unexpected_eof(p);
124 static inline bool cf_go_to_token(
struct cf_parser *p,
const char *str1,
127 while (cf_next_token(p)) {
141 static inline bool cf_go_to_valid_token(
struct cf_parser *p,
const char *str1,
144 if (!cf_go_to_token(p, str1, str2)) {
145 cf_adderror_unexpected_eof(p);
152 static inline bool cf_go_to_token_type(
struct cf_parser *p,
161 static inline int cf_token_should_be(
struct cf_parser *p,
const char *
str,
162 const char *goto1,
const char *goto2)
168 if (!cf_go_to_token(p, goto1, goto2))
172 cf_adderror_expecting(p,
str);
176 static inline int cf_next_token_should_be(
struct cf_parser *p,
const char *
str,
177 const char *goto1,
const char *goto2)
179 if (!cf_next_token(p)) {
180 cf_adderror_unexpected_eof(p);
187 if (!cf_go_to_token(p, goto1, goto2))
191 cf_adderror_expecting(p,
str);
198 bool success = cf_next_token(p);
206 static inline bool cf_peek_valid_token(
struct cf_parser *p,
209 bool success = cf_peek_token(p, peek);
211 cf_adderror_unexpected_eof(p);
215 static inline bool cf_token_is(
struct cf_parser *p,
const char *val)
221 const char *type_expected,
222 const char *goto_token)
225 cf_adderror_expecting(p, type_expected);
227 if (!cf_go_to_valid_token(p, goto_token, NULL))
236 static inline void cf_copy_token(
struct cf_parser *p,
char **dst)
241 static inline int cf_get_name(
struct cf_parser *p,
char **dst,
const char *name,
242 const char *goto_token)
246 errcode = cf_token_is_type(p,
CFTOKEN_NAME, name, goto_token);
254 static inline int cf_next_name(
struct cf_parser *p,
char **dst,
255 const char *name,
const char *goto_token)
257 if (!cf_next_valid_token(p))
260 return cf_get_name(p, dst, name, goto_token);
263 static inline int cf_next_token_copy(
struct cf_parser *p,
char **dst)
265 if (!cf_next_valid_token(p))
268 cf_copy_token(p, dst);
272 static inline int cf_get_name_ref(
struct cf_parser *p,
struct strref *dst,
273 const char *name,
const char *goto_token)
277 errcode = cf_token_is_type(p,
CFTOKEN_NAME, name, goto_token);
285 static inline int cf_next_name_ref(
struct cf_parser *p,
struct strref *dst,
286 const char *name,
const char *goto_token)
288 if (!cf_next_valid_token(p))
291 return cf_get_name_ref(p, dst, name, goto_token);
Definition: cf-lexer.h:85
Definition: cf-parser.h:40
@ CFTOKEN_SPACETAB
Definition: cf-lexer.h:41
EXPORT void cf_lexer_init(struct cf_lexer *lex)
EXPORT void cf_adderror(struct cf_parser *parser, const char *error, int level, const char *val1, const char *val2, const char *val3)
struct cf_lexer lex
Definition: cf-parser.h:41
struct cf_preprocessor pp
Definition: cf-parser.h:42
#define EXPORT
Definition: c99defs.h:37
EXPORT void cf_lexer_free(struct cf_lexer *lex)
EXPORT int strref_cmp(const struct strref *str1, const char *str2)
EXPORT void cf_preprocessor_init(struct cf_preprocessor *pp)
size_t len
Definition: lexer.h:32
@ CFTOKEN_NEWLINE
Definition: cf-lexer.h:42
EXPORT void cf_preprocessor_free(struct cf_preprocessor *pp)
enum cf_token_type type
Definition: cf-lexer.h:51
struct cf_token * cur_token
Definition: cf-parser.h:45
#define PARSE_CONTINUE
Definition: cf-parser.h:34
EXPORT bool cf_pass_pair(struct cf_parser *p, char in, char out)
struct strref str
Definition: cf-lexer.h:49
#define PARSE_SUCCESS
Definition: cf-parser.h:33
struct error_data error_list
Definition: cf-parser.h:43
#define PARSE_EOF
Definition: cf-parser.h:38
#define success(stat, call)
Definition: mac-helpers.h:13
EXPORT bool cf_preprocess(struct cf_preprocessor *pp, struct cf_lexer *lex, struct error_data *ed)
EXPORT bool cf_lexer_lex(struct cf_lexer *lex, const char *str, const char *file)
const char * array
Definition: lexer.h:31
#define LEX_ERROR
Definition: lexer.h:155
Definition: cf-lexer.h:47
@ CFTOKEN_NAME
Definition: cf-lexer.h:39
@ CFTOKEN_NONE
Definition: cf-lexer.h:38
cf_token_type
Definition: cf-lexer.h:37
Definition: cf-lexer.h:170