diff --git a/include/pattern.h b/include/pattern.h index 1242430..bb214d4 100644 --- a/include/pattern.h +++ b/include/pattern.h @@ -149,23 +149,39 @@ struct pattern_chain_s { struct pattern_node_s* tail; }; +/** + * Represents a single compiled pattern. + */ +struct pattern_s { + /** + * The first NFA state of the pattern. + */ + struct pattern_node_s* head; + /** + * The number of NFA nodes in this pattern. + */ + int size; +}; + typedef enum pattern_node_type_e pattern_node_type; typedef struct pattern_node_s pattern_node; typedef struct pattern_chain_s pattern_chain; +typedef struct pattern_s pattern; /** * Compiles a string representation of a pattern into a pattern NFA, * and stores the first node of the new NFA in root. * @param root the node to store the resulting pattern into. * @param expression the pattern represented as a string. + * @param id the id of the pattern. * @return LIBLEX_SUCCESS if all goes well, otherwise some other liblex_result. */ -liblex_result pattern_compile(pattern_node** root, char* expression); +liblex_result pattern_compile(pattern* ptrn, char* expression, int id); /** * Frees a pattern NFA allocated by pattern_compile. * @param root the root node to start freeing from. * @return LIBLEX_SUCCESS if all goes well, otherwise some other liblex_result. */ -liblex_result pattern_free(pattern_node* root); +liblex_result pattern_free(pattern* ptrn); #endif