-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWriter.java
74 lines (66 loc) · 1.74 KB
/
Writer.java
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
/* Writer class:
* This class defines the writing on a file.
* State: COMPLETED FOR LEXIC ANALIZER
*/
import java.io.FileWriter;
public class Writer {
private static FileWriter fToken;
private static FileWriter fTS;
private static FileWriter fError;
private static FileWriter fParse;
private static boolean desc;
public Writer(String tokenFile, String tsFile, String errorFile, String parseFile){
try {
fToken = new FileWriter(tokenFile);
fTS = new FileWriter(tsFile);
fError = new FileWriter(errorFile);
fParse = new FileWriter(parseFile);
desc = false;
} catch (Exception e) {
e.printStackTrace();
}
}
public void writeToken(String token){
try {
fToken.write(token);
} catch (Exception e) {
e.printStackTrace();
}
}
public void writeTS(String ts){
try {
fTS.write(ts);
} catch (Exception e) {
e.printStackTrace();
}
}
public void writeParse(String trace){
try {
if (!desc){
fParse.write("Descendente ");
desc = true;
}
fParse.write(trace);
fParse.write(" ");
} catch (Exception e) {
e.printStackTrace();
}
}
public void writeError(String error){
try {
fError.write(error);
} catch (Exception e) {
e.printStackTrace();
}
}
public void close(){
try {
fToken.close();
fTS.close();
fError.close();
fParse.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}