-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdfa.h
51 lines (44 loc) · 998 Bytes
/
dfa.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
49
50
51
#ifndef DFA_H
#define DFA_H
#include <stdbool.h>
#include <stdlib.h>
// State Structure
typedef struct
{
int id;
bool isAccepting;
} State;
// Transition Structure
typedef struct
{
int from;
int to;
char symbol;
} Transition;
// DFA Structure
typedef struct
{
State *states;
Transition *transitions;
int numStates;
int numTransitions;
int startState;
} DFA;
#define MAX_ERRORS 10
typedef struct
{
const char *errors[MAX_ERRORS];
int numErrors;
} ErrorReport;
// Function declarations
ErrorReport *createErrorReport();
void addErrorToReport(ErrorReport *report, const char *error);
void freeErrorReport(ErrorReport *report);
DFA *readDfa(const char *filename); // The extern keyword is not needed in the header
void printDfa(DFA *dfa);
ErrorReport *validateDfa(DFA *dfa);
bool compareDfaWithFile(DFA *dfa, const char *filename, ErrorReport *report);
float testDeliverable1();
float testDeliverable2();
float testDeliverable3();
#endif // DFA_H