Методические указания (1114907), страница 24
Текст из файла (страница 24)
$instructionNumber = getInstructionNumber();
if ($expressionFirst.expressionClass.equals("id") ||
$expressionFirst.expressionClass.equals("const_string") ||
$expressionFirst.expressionClass.equals("const_int")) {
if ($expressionFirst.expressionClass.equals("const_string")) {
constants.add($expressionFirst.text);
resultString = "(" + $instructionNumber + ") " + $logical_link.text + " " + "D0" + constants.size() + " ";
}
else {
resultString = "(" + $instructionNumber + ") " + $logical_link.text + " " + $expressionFirst.text + " ";
}
}
else {
resultString = "(" + $instructionNumber + ") " + $logical_link.text + " (" + $expressionFirst.instructionNumber + ") ";
}
if ($expressionSecond.expressionClass.equals("id") ||
$expressionSecond.expressionClass.equals("const_string") ||
$expressionSecond.expressionClass.equals("const_int")) {
$instructionNumber = getInstructionNumber();
if ($expressionSecond.expressionClass.equals("const_string")) {
constants.add($expressionSecond.text);
resultString += "D0" + constants.size();
}
else {
resultString += $expressionSecond.text;
}
instructions.add(resultString);
}
else {
resultString += "(" + $expressionSecond.instructionNumber + ")";
instructions.add(resultString);
}
}
}
}
}
}
;
logical_link
: '==' | '!=' | '>' | '<' | '>=' | '<='
;
operator : variable_declaration | assign_operator | for_operator | function_call_operator
;
program : (operator)+
;