summaryrefslogtreecommitdiff
path: root/lib/test_helper.h
blob: 47dacf5648ba70d54d47f47b4e7cbf892191f6cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#ifndef _RE2C_LIB_TEST_HELPER_
#define _RE2C_LIB_TEST_HELPER_

#include <vector>
#include "lib/regex.h"

// Parse test submatch result string.
//
// Expected format: comma-separated lists of offset pairs in parentheses, each
// list contains as many pairs as there are repetitions for the corresponding
// capturing group.
//
// Example for RE "(a(b)?)*" and string "aba": "(0,3),(0,2)(2,3),(1,2)(?,?)".
//
// String representation of result is used instead of vectors and initializer
// lists because C++ compilers take too long to process that many vectors, and
// the compilation gets very slow.
bool parse_submatch(const char *s, std::vector<std::vector<regoff_t> > &result);

#endif // _RE2C_LIB_TEST_HELPER_