-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFactsAutomaton.h
59 lines (56 loc) · 1.13 KB
/
FactsAutomaton.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
52
53
54
55
56
57
58
59
//
// Created by Matthew on 6/25/2022.
//
#ifndef CS236_FACTSAUTOMATON_H
#define CS236_FACTSAUTOMATON_H
#include "Automaton.h"
class FactsAutomaton : public Automaton {
public:
FactsAutomaton() {
type = TokenType::FACTS; // set the type
}
private:
void s0() {
if (match('F')) {
next();
s1();
}
else {
sError(); // this calls the error state
}
}
void s1() {
if (match('a')) {
next();
s2();
}
else {
sError(); // this calls the error state
}
}
void s2() {
if (match('c')) {
next();
s3();
} else {
sError(); // this calls the error state
}
}
void s3() {
if (match('t')) {
next();
s4();
} else {
sError(); // this calls the error state
}
}
void s4() {
if (match('s')) {
next();
return; // success
} else {
sError(); // this calls the error state
}
}
};
#endif //CS236_FACTSAUTOMATON_H