9
9
#include " commentDFA.h"
10
10
11
11
// State 0: Normal state, reading and printing code character by character
12
- void commentDFA ::state0 (std::ifstream& file, int & lineCount, std::ostringstream& buffer) {
12
+ void CommentDFA ::state0 (std::ifstream& file, int & lineCount, std::ostringstream& buffer) {
13
13
char ch;
14
14
file.get (ch); // Read a character from the file
15
15
if (file.eof ()) { // Check if the end of file is reached
@@ -41,7 +41,7 @@ void commentDFA::state0(std::ifstream& file, int& lineCount, std::ostringstream&
41
41
}
42
42
43
43
// State 1: After hitting a '/', figure out if it's a comment or a division operator
44
- void commentDFA ::state1 (std::ifstream& file, int & lineCount, std::ostringstream& buffer) {
44
+ void CommentDFA ::state1 (std::ifstream& file, int & lineCount, std::ostringstream& buffer) {
45
45
char ch;
46
46
file.get (ch); // Read the next character
47
47
if (file.eof ()) { // Check for end of file
@@ -68,7 +68,7 @@ void commentDFA::state1(std::ifstream& file, int& lineCount, std::ostringstream&
68
68
}
69
69
70
70
// State 2: Inside a C++-style line comment, skip characters until newline is reached
71
- void commentDFA ::state2 (std::ifstream& file, int & lineCount, std::ostringstream& buffer) {
71
+ void CommentDFA ::state2 (std::ifstream& file, int & lineCount, std::ostringstream& buffer) {
72
72
char ch;
73
73
file.get (ch); // Read the next character
74
74
if (ch == ' \n ' ) { // If it's a newline, return to state0 to process the next line
@@ -82,7 +82,7 @@ void commentDFA::state2(std::ifstream& file, int& lineCount, std::ostringstream&
82
82
}
83
83
84
84
// State 3: Inside a C-style block comment, look for the closing '*/'
85
- bool commentDFA ::state3 (std::ifstream& file, int & lineCount, int & commentLineCount, std::ostringstream& buffer) {
85
+ bool CommentDFA ::state3 (std::ifstream& file, int & lineCount, int & commentLineCount, std::ostringstream& buffer) {
86
86
char ch;
87
87
file.get (ch); // Read the next character
88
88
if (ch == ' *' ) { // If it's a '*', check if it's the start of '*/' (end of comment)
@@ -99,7 +99,7 @@ bool commentDFA::state3(std::ifstream& file, int& lineCount, int& commentLineCou
99
99
}
100
100
101
101
// State 4: Looking for '/' to close the C-style block comment
102
- bool commentDFA ::state4 (std::ifstream& file, int & lineCount, int & commentLineCount, std::ostringstream& buffer) {
102
+ bool CommentDFA ::state4 (std::ifstream& file, int & lineCount, int & commentLineCount, std::ostringstream& buffer) {
103
103
char ch;
104
104
file.get (ch); // Read the next character
105
105
if (ch == ' /' ) { // If it's '/', the block comment is closed, return to state0
@@ -121,7 +121,7 @@ bool commentDFA::state4(std::ifstream& file, int& lineCount, int& commentLineCou
121
121
122
122
// State 5: Inside a quoted string (either single or double quotes),
123
123
// ignore characters inside until the closing quote is found
124
- bool commentDFA ::state5 (std::ifstream& file, int & lineCount, int & quoteLineCount, std::ostringstream& buffer) {
124
+ bool CommentDFA ::state5 (std::ifstream& file, int & lineCount, int & quoteLineCount, std::ostringstream& buffer) {
125
125
char ch;
126
126
file.get (ch);
127
127
if (file.eof ()) { // If end of file is reached, return false
@@ -139,7 +139,7 @@ bool commentDFA::state5(std::ifstream& file, int& lineCount, int& quoteLineCount
139
139
140
140
// State 6: Detected an asterisk ('*'),
141
141
// check if it's an unterminated C-style block comment
142
- bool commentDFA ::state6 (std::ifstream& file, int & lineCount, std::ostringstream& buffer) {
142
+ bool CommentDFA ::state6 (std::ifstream& file, int & lineCount, std::ostringstream& buffer) {
143
143
char ch;
144
144
file.get (ch);
145
145
if (ch == ' /' ) { // If a slash is found, return false
0 commit comments