-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdfa.h
More file actions
80 lines (65 loc) · 1.96 KB
/
Copy pathdfa.h
File metadata and controls
80 lines (65 loc) · 1.96 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
70
71
72
73
74
75
76
77
78
79
80
//
// Created by Ethan Sawyer on 7/10/20.
//
#ifndef PROJECT1_DFA_H
#define PROJECT1_DFA_H
#include <stdbool.h>
/**
* The data structure used to represent a deterministic finite automaton.
* @see FOCS Section 10.2
* Note that YOU must specify this data structure, although you can hide
* (encapsulate) its implementation behind the declared API functions and
* only provide a partial declaration in the header file.
*/
typedef struct DFA *DFA;
/**
* Allocate and return a new DFA containing the given number of states.
*/
extern DFA new_DFA(int nstates);
/**
* Free the given DFA.
*/
extern void DFA_free(DFA dfa);
/**
* Return the number of states in the given DFA.
*/
extern int DFA_get_size(DFA dfa);
/**
* Return the state specified by the given DFA's transition function from
* state src on input symbol sym.
*/
extern int DFA_get_transition(DFA dfa, int src, char sym);
/**
* For the given DFA, set the transition from state src on input symbol
* sym to be the state dst.
*/
extern void DFA_set_transition(DFA dfa, int src, char sym, int dst);
/**
* Set the transitions of the given DFA for each symbol in the given str.
* This is a nice shortcut when you have multiple labels on an edge between
* two states.
*/
extern void DFA_set_transition_str(DFA dfa, int src, char *str, int dst);
/**
* Set the transitions of the given DFA for all input symbols.
* Another shortcut method.
*/
extern void DFA_set_transition_all(DFA dfa, int src, int dst);
/**
* Set whether the given DFA's state is accepting or not.
*/
extern void DFA_set_accepting(DFA dfa, int state, bool value);
/**
* Return true if the given DFA's state is an accepting state.
*/
extern bool DFA_get_accepting(DFA dfa, int state);
/**
* Run the given DFA on the given input string, and return true if it accepts
* the input, otherwise false.
*/
extern bool DFA_execute(DFA dfa, char *input);
/**
* Print the given DFA to System.out.
*/
extern void DFA_print(DFA dfa);
#endif //PROJECT1_DFA_H