#include "regex_internal_lib.h"
Go to the source code of this file.
Data Structures | |
struct | REGEX_INTERNAL_Transition |
Transition between two states. More... | |
struct | REGEX_INTERNAL_StateSet |
Set of states. More... | |
struct | REGEX_INTERNAL_State |
A state. More... | |
struct | REGEX_INTERNAL_Automaton |
Automaton representation. More... | |
struct | REGEX_INTERNAL_Context |
Context that contains an id counter for states and transitions as well as a DLL of automatons used as a stack for NFA construction. More... | |
Macros | |
#define | ALLOWED_LITERALS "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" |
char array of literals that are allowed inside a regex (apart from the operators) More... | |
Typedefs | |
typedef int(* | REGEX_INTERNAL_traverse_check) (void *cls, struct REGEX_INTERNAL_State *s, struct REGEX_INTERNAL_Transition *t) |
Function that gets passed to automaton traversal and is called before each next traversal from state 's' using transition 't' to check if traversal should proceed. More... | |
typedef void(* | REGEX_INTERNAL_traverse_action) (void *cls, const unsigned int count, struct REGEX_INTERNAL_State *s) |
Function that is called with each state, when traversing an automaton. More... | |
Enumerations | |
enum | REGEX_INTERNAL_AutomatonType { NFA , DFA } |
Type of an automaton. More... | |
Functions | |
struct REGEX_INTERNAL_Automaton * | REGEX_INTERNAL_construct_nfa (const char *regex, const size_t len) |
Construct an NFA by parsing the regex string of length 'len'. More... | |
void | REGEX_INTERNAL_automaton_traverse (const struct REGEX_INTERNAL_Automaton *a, struct REGEX_INTERNAL_State *start, REGEX_INTERNAL_traverse_check check, void *check_cls, REGEX_INTERNAL_traverse_action action, void *action_cls) |
Traverses the given automaton using depth-first-search (DFS) from it's start state, visiting all reachable states and calling 'action' on each one of them. More... | |
const char * | REGEX_INTERNAL_get_canonical_regex (struct REGEX_INTERNAL_Automaton *a) |
Get the canonical regex of the given automaton. More... | |
unsigned int | REGEX_INTERNAL_get_transition_count (struct REGEX_INTERNAL_Automaton *a) |
Get the number of transitions that are contained in the given automaton. More... | |
void | REGEX_INTERNAL_dfa_add_multi_strides (struct REGEX_INTERNAL_Context *regex_ctx, struct REGEX_INTERNAL_Automaton *dfa, const unsigned int stride_len) |
Adds multi-strided transitions to the given 'dfa'. More... | |
#define ALLOWED_LITERALS "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" |
char array of literals that are allowed inside a regex (apart from the operators)
Definition at line 42 of file regex_internal.h.
typedef int(* REGEX_INTERNAL_traverse_check) (void *cls, struct REGEX_INTERNAL_State *s, struct REGEX_INTERNAL_Transition *t) |
Function that gets passed to automaton traversal and is called before each next traversal from state 's' using transition 't' to check if traversal should proceed.
Return GNUNET_NO to stop traversal or GNUNET_YES to continue.
cls | closure for the check. |
s | current state in the traversal. |
t | current transition from state 's' that will be used for the next step. |
Definition at line 343 of file regex_internal.h.
typedef void(* REGEX_INTERNAL_traverse_action) (void *cls, const unsigned int count, struct REGEX_INTERNAL_State *s) |
Function that is called with each state, when traversing an automaton.
cls | closure. |
count | current count of the state, from 0 to a->state_count -1. |
s | state. |
Definition at line 356 of file regex_internal.h.
Type of an automaton.
Enumerator | |
---|---|
NFA | |
DFA |
Definition at line 249 of file regex_internal.h.
struct REGEX_INTERNAL_Automaton * REGEX_INTERNAL_construct_nfa | ( | const char * | regex, |
const size_t | len | ||
) |
Construct an NFA by parsing the regex string of length 'len'.
regex | regular expression string. |
len | length of the string. |
regex | regular expression string |
len | length of the string |
Definition at line 2795 of file regex_internal.c.
References ctx, GNUNET_array_grow, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_strdup, REGEX_INTERNAL_Automaton::is_multistrided, nfa_add_alternation(), nfa_add_concatenation(), nfa_add_label(), nfa_add_plus_op(), nfa_add_question_op(), nfa_add_star_op(), number_states(), p, REGEX_INTERNAL_Automaton::regex, REGEX_INTERNAL_automaton_destroy(), REGEX_INTERNAL_automaton_traverse(), and REGEX_INTERNAL_context_init().
Referenced by REGEX_INTERNAL_construct_dfa().
void REGEX_INTERNAL_automaton_traverse | ( | const struct REGEX_INTERNAL_Automaton * | a, |
struct REGEX_INTERNAL_State * | start, | ||
REGEX_INTERNAL_traverse_check | check, | ||
void * | check_cls, | ||
REGEX_INTERNAL_traverse_action | action, | ||
void * | action_cls | ||
) |
Traverses the given automaton using depth-first-search (DFS) from it's start state, visiting all reachable states and calling 'action' on each one of them.
a | automaton to be traversed. |
start | start state, pass a->start or NULL to traverse the whole automaton. |
check | function that is checked before advancing on each transition in the DFS. |
check_cls | closure for check. |
action | action to be performed on each state. |
action_cls | closure for action |
Definition at line 505 of file regex_internal.c.
References consensus-simulation::action, automaton_state_traverse(), GNUNET_NO, REGEX_INTERNAL_State::next, start, REGEX_INTERNAL_Automaton::start, REGEX_INTERNAL_Automaton::state_count, REGEX_INTERNAL_Automaton::states_head, and REGEX_INTERNAL_State::traversal_id.
Referenced by automaton_create_proofs(), dfa_remove_unreachable_states(), REGEX_INTERNAL_construct_nfa(), REGEX_INTERNAL_dfa_add_multi_strides(), and REGEX_TEST_automaton_save_graph().
const char * REGEX_INTERNAL_get_canonical_regex | ( | struct REGEX_INTERNAL_Automaton * | a | ) |
Get the canonical regex of the given automaton.
When constructing the automaton a proof is computed for each state, consisting of the regular expression leading to this state. A complete regex for the automaton can be computed by combining these proofs. As of now this function is only useful for testing.
a | automaton for which the canonical regex should be returned. |
Definition at line 3250 of file regex_internal.c.
References REGEX_INTERNAL_Automaton::canonical_regex.
unsigned int REGEX_INTERNAL_get_transition_count | ( | struct REGEX_INTERNAL_Automaton * | a | ) |
Get the number of transitions that are contained in the given automaton.
a | automaton for which the number of transitions should be returned. |
Definition at line 3267 of file regex_internal.c.
References REGEX_INTERNAL_State::next, REGEX_INTERNAL_Automaton::states_head, and REGEX_INTERNAL_State::transition_count.
void REGEX_INTERNAL_dfa_add_multi_strides | ( | struct REGEX_INTERNAL_Context * | regex_ctx, |
struct REGEX_INTERNAL_Automaton * | dfa, | ||
const unsigned int | stride_len | ||
) |
Adds multi-strided transitions to the given 'dfa'.
regex_ctx | regex context needed to add transitions to the automaton. |
dfa | DFA to which the multi strided transitions should be added. |
stride_len | length of the strides. |
Definition at line 2183 of file regex_internal.c.
References ctx, dfa_add_multi_strides(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_YES, REGEX_INTERNAL_Automaton::is_multistrided, GNUNET_SCHEDULER_Task::next, REGEX_INTERNAL_automaton_traverse(), REGEX_INTERNAL_Automaton::start, state_add_transition(), and t.