-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnfa.h
More file actions
executable file
·37 lines (28 loc) · 1014 Bytes
/
nfa.h
File metadata and controls
executable file
·37 lines (28 loc) · 1014 Bytes
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
#ifndef NFA_H
#define NFA_H
#include <stdio.h>
#include <stdlib.h>
#include "int_stack.h"
/* define structures */
typedef struct NFA {
int states_no; // number of states
int trans_no; // number of transitions
struct Edge **transitions; // array of transitions
int *states; // array of states
int initial_state, final_state; // initial/final state id
} NFA;
typedef struct Edge {
int src; // edge source
int dst; // edge destination
char val; // edge value
} Edge;
/* Constructors */
NFA *nfa();
Edge *edge(int initial_id, int final_id, char symbol);
/* Other functions */
void nfa_print(NFA *nfa);
void nfa_free(NFA *nfa);
/* Topsort implementation for ordered output */
void topsort(NFA *nfa, IntStack *s);
void topsort_rec(NFA *nfa, IntStack *s, int *visited, int i);
#endif