-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautomaton.h
More file actions
69 lines (55 loc) · 1.68 KB
/
automaton.h
File metadata and controls
69 lines (55 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#pragma once
#include <stdio.h>
#include "common.h"
#define EPSILON_EDGE 256
#define MAX_EDGES 257
typedef struct edge {
bool_t transitions[MAX_EDGES];
} edge_t;
typedef struct node {
int end_tag;
} node_t;
typedef struct automaton {
edge_t *adjacency_matrix;
node_t *nodes;
int max_node_count;
int next_node_index;
int start_index;
} automaton_t;
/**
* Prints the given {@code automaton}.
*/
void print_automaton(automaton_t *automaton, FILE *fout);
/**
* Creates an automaton which can hold up to {@code node_count} nodes.
*/
automaton_t create_automaton(int node_count);
/**
* Creates a new node in the given {@code automaton}.
*/
int create_node(automaton_t *automaton);
/**
* Creates a new connection between two nodes specified by their indices ({@code
* node0} and {@code node1}). The connection is either an epsilon connection (if
* {@code is_epsilon != 0}) or a normal connection with the {@code terminal}.
*/
void connect_nodes(automaton_t *automaton, int node0, int node1,
unsigned char terminal, bool_t is_epsilon);
/**
* Creates a new automaton, which is equivalent to the given {@code automaton},
* but is deterministic.
*/
automaton_t determinize(automaton_t *automaton);
/**
* Creates a new automaton, which is equivalent to the given {@code automaton},
* but is minimal. The given {@code automaton} must be deterministic.
*/
automaton_t minimize(automaton_t *automaton);
/**
* Deletes a given {@code automaton} and frees all its related memory.
*/
void delete_automaton(automaton_t automaton);
/**
* Creates a state transition matrix for the given {@code automaton}.
*/
bool_t *create_state_transition_matrix(automaton_t *automaton);