-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNFA_Constructor.h
executable file
·48 lines (39 loc) · 1.11 KB
/
NFA_Constructor.h
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
//
// Created by Moro on 23/05/16.
//
#ifndef C_INTERPRETER_MAIN_H
#define C_INTERPRETER_MAIN_H
#include "lists.h"
int state_count;
typedef char* Expression;
enum bool {true = 1, false = 0};
struct NFA* evaluate(Expression);
typedef struct EdgeNode {
struct Node* next;
struct Node* prev;
struct Edge* value;
};
typedef struct EdgeList {
struct EdgeNode* first;
struct EdgeNode* last;
int count;
};
typedef struct State {
struct EdgeList* edges; // List with all edges connecting to other states
int number; // Unique state ID.
int is_final; // Bool that checks whether the state is a final state
} State;
typedef struct Edge {
State* state; // State we connect to.
char c; // Character for this transition.
} Edge;
typedef struct NFA {
State* start; // State that the NFA starts with.
State* end; // State that the NFA ends with.
} NFA;
NFA* Concatenate_NFA(struct NFA* NFA_1, struct NFA* NFA_2);
NFA* Create_Union_NFA(NFA* NFA_1, NFA* NFA_2);
NFA* Create_Kleenstar_NFA(NFA* nfa);
NFA* Create_Plus_NFA(NFA* nfa);
NFA* Create_Primitive_NFA(char c);
#endif //C_INTERPRETER_MAIN_H