/* * Copyright (c) Camden Dixie O'Brien * SPDX-License-Identifier: AGPL-3.0-only */ #ifndef REGEX_H #define REGEX_H #include typedef struct { bool negated; int count, capacity; char *contents; } regex_class_t; typedef enum { REGEX_QUANTIFIER_NONE, REGEX_QUANTIFIER_STAR, REGEX_QUANTIFIER_PLUS, REGEX_QUANTIFIER_QMARK, } regex_quantifier_t; typedef enum { REGEX_TERM_WILDCARD, REGEX_TERM_CLASS, REGEX_TERM_LITERAL, REGEX_TERM_SUBEXPR, REGEX_TERM_EMPTY, } regex_term_type_t; struct _regex_term; typedef struct { int count, capacity; struct _regex_term *contents; } regex_sequence_t; typedef struct { int count, capacity; regex_sequence_t *contents; } regex_t; typedef struct _regex_term { regex_quantifier_t quantifier; regex_term_type_t type; union { regex_class_t class; char literal; regex_t subexpr; }; } regex_term_t; void regex_free(const regex_t *t); void regex_class_free(const regex_class_t *c); #endif