-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInvalidBlockCommentAutomaton.cpp
More file actions
70 lines (65 loc) · 1.27 KB
/
InvalidBlockCommentAutomaton.cpp
File metadata and controls
70 lines (65 loc) · 1.27 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
//
// Created by 18bma on 9/10/2021.
//
#include "InvalidBlockCommentAutomaton.h"
int InvalidBlockCommentAutomaton::Read(const string& input) {
if(input.at(index) == '#') {
inputRead++;
index++;
S1(input);
return inputRead;
}
else {
Serr();
return 0;
}
}
void InvalidBlockCommentAutomaton::S1(const string& input) {
if(input.at(index) == '|') {
inputRead++;
index++;
S2(input);
}
else {
Serr();
inputRead = 0;
}
}
void InvalidBlockCommentAutomaton::S2(const string& input) {
if(input.at(index) == '|') {
inputRead++;
index++;
S3(input);
}
else if (index == input.size() - 1) {
newLines++;
inputRead++;
}
else if(input.at(index) == '\n') {
newLines++;
inputRead++;
index++;
S2(input);
}
else {
inputRead++;
index++;
S2(input);
}
}
void InvalidBlockCommentAutomaton::S3(const string& input) {
if(input.at(index) == '#') {
Serr();
}
else if(input.at(index) == '\n') {
newLines++;
inputRead++;
index++;
S2(input);
}
else {
inputRead++;
index++;
S2(input);
}
}