Skip to content

Commit 27d744f

Browse files
committed
Fixed inter
1 parent ca4afc3 commit 27d744f

12 files changed

Lines changed: 72 additions & 32 deletions

File tree

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
24.3 KB
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

.idea/workspace.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/ru/osipov/labs/exe/Exe.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,19 @@ private void SLRGrammarParse(Grammar G, ILexer lexer,String dir,String sc) throw
125125
semantic.reset();
126126
tree.visit(VisitorMode.PRE,semantic);
127127
System.out.println("Parameters of methods in bodies are renamed.");
128-
129-
semantic.setActionType(TranslatorActions.TYPE_CHECK);
128+
//
129+
// semantic.setActionType(TranslatorActions.TYPE_CHECK);
130+
// semantic.reset();
131+
// tree.visit(VisitorMode.PRE,semantic);
132+
// System.out.println("Types were checked.");
133+
//
134+
// IntermediateCodeGenerator generator = semantic.getCodeGenerator();
135+
// System.out.println("Has errors: "+semantic.hasErrors());
136+
// if(semantic.hasErrors())
137+
// semantic.showErrors();
138+
semantic.setActionType(TranslatorActions.SHOW_DEFINITIONS);
130139
semantic.reset();
131140
tree.visit(VisitorMode.PRE,semantic);
132-
System.out.println("Types were checked.");
133-
134-
IntermediateCodeGenerator generator = semantic.getCodeGenerator();
135-
136141
}
137142
else{
138143
System.out.println("Syntax errors detected!");

src/main/java/ru/osipov/labs/lab4/translators/IntermediateCodeGenerator.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ else if (arg.getParent().getValue().getName().equals("if") && arg.getParent().ge
9696
TokenAttrs a2 = (TokenAttrs) else_node;
9797
String l = a2.getCode();
9898
writer.write(a1.getCode());
99-
writer.write(l);
99+
writer.write(l);//label from ELS node.
100100
}
101101
}
102102
//while condition was read.
@@ -107,7 +107,8 @@ else if (arg.getParent().getValue().getName().equals("while") && arg.getParent()
107107
lcounter++;
108108
String loop = "L" + lcounter + ": ";
109109

110-
writer.write("IFTRUE "+a1.getCode()+" "+loop+" :z"+" \n");
110+
writer.write(a1.getCode());
111+
writer.write("IFTRUE "+a1.getLexem()+" "+loop+" :z"+" \n");
111112

112113
//begin while-loop body.
113114
writer.write(loop+"\n");
@@ -135,7 +136,8 @@ private void generateWhileLoop(Node<Token> n){
135136
TokenAttrs a1 = (TokenAttrs)t;
136137
String l = labels.top();
137138
labels.pop();
138-
writer.write("IFTRUE "+a1.getCode()+" "+l+" :z"+" \n");
139+
writer.write(a1.getCode());
140+
writer.write("IFTRUE "+a1.getLexem()+" "+l+" :z"+" \n");
139141
}
140142
}
141143
else if(arg.getValue() instanceof TokenAttrs){

0 commit comments

Comments
 (0)