Made sequence and choice variadic, and added test suite helper functions

This commit is contained in:
Dan Hirsch 2012-05-12 00:40:54 +01:00
parent d13fbbf9c4
commit d5358a724b
5 changed files with 102 additions and 33 deletions

View file

@ -147,11 +147,11 @@ const parser_t* end_p();
/* This parser always fails. */
const parser_t* nothing_p();
/* Given an array of parsers, p_array, apply each parser in order. The parse succeeds only if all parsers succeed. */
const parser_t* sequence(const parser_t* p_array[]);
/* Given an null-terminated list of parsers, apply each parser in order. The parse succeeds only if all parsers succeed. */
const parser_t* sequence(const parser_t* p, ...) __attribute__((sentinel));
/* Given an array of parsers, p_array, apply each parser in order. The first parser to succeed is the result; if no parsers succeed, the parse fails. */
const parser_t* choice(const parser_t* p_array[]);
const parser_t* choice(const parser_t* p, ...) __attribute__((sentinel));
/* Given two parsers, p1 and p2, this parser succeeds in the following cases:
* - if p1 succeeds and p2 fails