diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-06-20 08:55:56 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-06-20 08:55:56 +0000 |
commit | 5f7a6c8f6816a826a2dd93eadc5039733f7db606 (patch) | |
tree | 3c22c8ff3436cc3140dfb1b24813ed4362330879 /src/regex/regex_test_lib.h | |
parent | 21a2b4f95b4488645ba5a6254fcb8919c4915f73 (diff) |
moving functions for testing and evaluation and experiments to the test library, minimizing the internal library, renaming files according to which library they belong to
Diffstat (limited to 'src/regex/regex_test_lib.h')
-rw-r--r-- | src/regex/regex_test_lib.h | 79 |
1 files changed, 75 insertions, 4 deletions
diff --git a/src/regex/regex_test_lib.h b/src/regex/regex_test_lib.h index 418f47dbab..107c2ffceb 100644 --- a/src/regex/regex_test_lib.h +++ b/src/regex/regex_test_lib.h @@ -20,15 +20,15 @@ /** * @file src/regex/regex_test_lib.h * @brief library to read regexes representing IP networks from a file. - * and simplyfinying the into one big regex, in order to run - * tests (regex performance, mesh profiler). + * and simplifying the into one big regex, in order to run + * tests (regex performance, regex profiler). * @author Bertlomiej Polot - * */ #ifndef REGEX_ITERNAL_TEST_LIB_H #define REGEX_ITERNAL_TEST_LIB_H +#include "regex_internal_lib.h" #ifdef __cplusplus extern "C" @@ -48,6 +48,7 @@ extern "C" char * REGEX_ITERNAL_combine(char * const regexes[]); + /** * Read a set of regexes from a file, one per line and return them in an array * suitable for REGEX_ITERNAL_combine. @@ -69,6 +70,76 @@ REGEX_ITERNAL_read_from_file (const char *filename); void REGEX_ITERNAL_free_from_file (char **regexes); + +/** + * Generate a (pseudo) random regular expression of length 'rx_length', as well + * as a (optional) string that will be matched by the generated regex. The + * returned regex needs to be freed. + * + * @param rx_length length of the random regex. + * @param matching_str (optional) pointer to a string that will contain a string + * that will be matched by the generated regex, if + * 'matching_str' pointer was not NULL. + * + * @return NULL if 'rx_length' is 0, a random regex of length 'rx_length', which + * needs to be freed, otherwise. + */ +char * +REGEX_ITERNAL_generate_random_regex (size_t rx_length, char *matching_str); + + +/** + * Generate a random string of maximum length 'max_len' that only contains literals allowed + * in a regular expression. The string might be 0 chars long but is garantueed + * to be shorter or equal to 'max_len'. + * + * @param max_len maximum length of the string that should be generated. + * + * @return random string that needs to be freed. + */ +char * +REGEX_ITERNAL_generate_random_string (size_t max_len); + + +/** + * Options for graph creation function + * REGEX_ITERNAL_automaton_save_graph. + */ +enum REGEX_ITERNAL_GraphSavingOptions +{ + /** + * Default. Do nothing special. + */ + REGEX_ITERNAL_GRAPH_DEFAULT = 0, + + /** + * The generated graph will include extra information such as the NFA states + * that were used to generate the DFA state. + */ + REGEX_ITERNAL_GRAPH_VERBOSE = 1, + + /** + * Enable graph coloring. Will color each SCC in a different color. + */ + REGEX_ITERNAL_GRAPH_COLORING = 2 +}; + + +/** + * Save the given automaton as a GraphViz dot file. + * + * @param a the automaton to be saved. + * @param filename where to save the file. + * @param options options for graph generation that include coloring or verbose + * mode + */ +void +REGEX_ITERNAL_automaton_save_graph (struct REGEX_ITERNAL_Automaton *a, + const char *filename, + enum REGEX_ITERNAL_GraphSavingOptions options); + + + #if 0 /* keep Emacsens' auto-indent happy */ { #endif @@ -77,4 +148,4 @@ REGEX_ITERNAL_free_from_file (char **regexes); #endif /* end of regex_internal_lib.h */ -#endif
\ No newline at end of file +#endif |