Move headers into include directories

This commit is contained in:
2024-10-26 23:42:24 +01:00
parent 2804638d84
commit 403d081e13
7 changed files with 10 additions and 10 deletions

14
lib/include/construct.h Normal file
View File

@@ -0,0 +1,14 @@
/*
* Copyright (c) Camden Dixie O'Brien
* SPDX-License-Identifier: AGPL-3.0-only
*/
#ifndef CONSTRUCT_H
#define CONSTRUCT_H
#include "fsa.h"
#include "regex.h"
void construct(const regex_t *regex, fsa_t *out);
#endif

13
lib/include/desugar.h Normal file
View File

@@ -0,0 +1,13 @@
/*
* Copyright (c) Camden Dixie O'Brien
* SPDX-License-Identifier: AGPL-3.0-only
*/
#ifndef DESUGAR_H
#define DESUGAR_H
#include "regex.h"
bool desugar_regex(regex_t *regex);
#endif

38
lib/include/fsa.h Normal file
View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) Camden Dixie O'Brien
* SPDX-License-Identifier: AGPL-3.0-only
*/
#ifndef FSA_H
#define FSA_H
#include <stdbool.h>
#define CHAR_COUNT 256
#define ALPHABET_SIZE (CHAR_COUNT + 1)
// Use one more than any valid char to represent empty string
#define EPSILON CHAR_COUNT
typedef struct {
int input, next;
} fsa_rule_t;
typedef struct {
bool final;
int count, capacity;
fsa_rule_t *rules;
} fsa_state_t;
typedef struct {
int count, capacity, initial;
fsa_state_t *states;
} fsa_t;
void fsa_init(fsa_t *fsa);
void fsa_free(const fsa_t *fsa);
int fsa_add_state(fsa_t *fsa);
void fsa_add_rule(fsa_t *fsa, int from, int to, int input);
#endif

13
lib/include/parse.h Normal file
View File

@@ -0,0 +1,13 @@
/*
* Copyright (c) Camden Dixie O'Brien
* SPDX-License-Identifier: AGPL-3.0-only
*/
#ifndef PARSE_H
#define PARSE_H
#include "regex.h"
int parse_expr(const char *input, int rem, regex_t *out);
#endif

56
lib/include/regex.h Normal file
View File

@@ -0,0 +1,56 @@
/*
* Copyright (c) Camden Dixie O'Brien
* SPDX-License-Identifier: AGPL-3.0-only
*/
#ifndef REGEX_H
#define REGEX_H
#include <stdbool.h>
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