-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPass1.java
More file actions
91 lines (68 loc) · 2 KB
/
Copy pathPass1.java
File metadata and controls
91 lines (68 loc) · 2 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
81
82
83
84
85
86
87
88
89
90
91
public class Pass1 extends MacroProcessor{
private String[] fileContent,lineContent;
private String currentLine;
private int mdtp = 0;
public void start() {
int i=1;
fileContent = getFileContent().split("\\r?\\n");
currentLine = fileContent[0];
while(!currentLine.equals("END")) {
lineContent = currentLine.split("\\s+");
if(lineContent[0].equals("MACRO")) {
currentLine = fileContent[i++];
lineContent = currentLine.split("\\s+");
if(inMnt(lineContent[0])) {
System.out.println(lineContent[0] + " already exists !!!!, Skipping this MACRO");
continue;
}
updateMnt(lineContent[0],mdtp);
prepareALA(lineContent);
updateMdt(this.currentLine);
mdtp++;
currentLine = fileContent[i++];
while(!currentLine.equals("MEND")) {
String substitutedLine = substitute_index_notation(currentLine);
updateMdt(substitutedLine);
mdtp++;
currentLine = fileContent[i++];
}
updateMdt("MEND");
mdtp++;
initAla();
continue;
}
currentLine = fileContent[i++];
}
}
private String substitute_index_notation(String currentLine2) {
lineContent = currentLine.split("\\s+");
String subsLine = "";
Boolean isFound = false;
int alaSize = getAlaSize();
for(String currentWord : lineContent) {
if(currentWord.matches(".+,.+")) {
String[] commaSepr = currentWord.split(",");
for(String comma : commaSepr) {
for(int i=0; i<alaSize; i++) {
if(comma.equals(getArgumentAtIndex(i))) {
subsLine = subsLine + i + " ";
isFound = true;
break;
}
}
}
}else {
for(int i=0; i<alaSize; i++) {
if(currentWord.equals(getArgumentAtIndex(i))) {
subsLine = subsLine + i + " ";
isFound = true;
break;
}
}
if(!isFound)
subsLine = subsLine + currentWord + " ";
}
}
return subsLine;
}
}