<string>logical</string>
<action>prog=prog+"boolean";</action>
</rightPart>
</rule>
<rule for='Classes' leftPart='BasicEnd'>
<rightPart>
<action>if(!ct.AddMethod((postFix.get(postFix.size()-3).toString().compareTo("public")==0)?true:false,
postFix.get(postFix.size()-2).toString(),postFix.get(postFix.size()-1).toString())){ti.put(0,0,0,0,"method_redef");return false;}
tetrades.add(new Tetrade("DEFINE_METHOD", postFix.get(postFix.size()-2).toString(),postFix.get(postFix.size()-1).toString(),""));
tetrades.add(new Tetrade("SET_VISIBILITY", labels.peek().toString() ,"",""));postFix.push("define_method");MetCon=true;</action>
<symbol>FuncBody</symbol>
<action>postFix.push("define_method_end");
postFix.push(labels.pop());</action>
</rightPart>
</rule>
<rule for='Classes' leftPart='BasicEnd'>
<rightPart>
<action>prog=prog+"; "; if(!ct.AddField((postFix.get(postFix.size()-3).toString().compareTo("public")==0)?true:false, postFix.get(postFix.size()-2).toString(),postFix.get(postFix.size()-1).toString())){
ti.put(0,0,0,0,"Field redefinition");
return false;}
tetrades.add(new Tetrade("DEFINE_FIELD", postFix.get(postFix.size()-2).toString(),postFix.get(postFix.size()-1).toString(),""));
tetrades.add(new Tetrade("SET_VISIBILITY", labels.peek().toString() ,"",""));
postFix.push("define_field");
postFix.push(labels.pop());</action>
<string>;</string>
</rightPart>
</rule>
<rule for='Classes' leftPart='FuncBody'>
<rightPart>
<action>prog=prog+" "+currentLexem.textOfWord+" ";</action>
<string>(</string>
<symbol>params</symbol>
<action>prog=prog+" ){ ";</action>
<string>)</string>
<string>{</string>
<action>ClassTable.Class cl1=ct.classes.get(ct.classes.size()-1);
if(MetCon)
{ClassTable.Method m1=cl1.methods.get(cl1.methods.size()-1);
tetrades.add(new Tetrade("DEFINE_LABEL", cl1.name+m1.name,"",""));
tetrades.add(new Tetrade("POP", "" ,"","this"));
for(int i=m1.params.size()-1;i>=0;i--){
tetrades.add(new Tetrade("POP","","", m1.params.get(i).name));
}
}
else
{ClassTable.Constructor c1=cl1.constructors.get(cl1.constructors.size()-1);
tetrades.add(new Tetrade("DEFINE_LABEL", cl1.name+(cl1.constructors.size()-1),"",""));
for(int i=c1.params.size()-1;i>=0;i--){
tetrades.add(new Tetrade("POP","","", c1.params.get(i).name));
}
tetrades.add(new Tetrade("MALLOC", cl1.name ,"","this"));
}</action>
<symbol>GramaConstruction</symbol>
<action>prog=prog+" } ";</action>
<string>}</string>
<symbol>MethodEnd</symbol>
</rightPart>
</rule>
<rule for='Classes' leftPart='MethodOrConstrunctor'>
<rightPart>
<action>if(!ct.AddConstructor((postFix.get(postFix.size()-2).toString().compareTo("public")==0)?true:false,postFix.get(postFix.size()-1).toString())){
ti.put(0,0,0,0,"Signature constructor but name does not match");
return false;}
tetrades.add(new Tetrade("DEFINE_CONSTRUCTOR", "","",""));
tetrades.add(new Tetrade("SET_VISIBILITY", labels.peek().toString() ,"",""));
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.