public String writeCodeForRoot( ProgramNode root, SymbolTable idTable) {
String a = null;
String result = "";
table = idTable;
StringBuilder code = new StringBuilder();
IdInformation element;
result += String.format("%-20s%s", "newLine"+":", ".asciiz \"\\n\"\n");
Enumeration e = idTable.getTable().elements();
//Writes global variables to .data section (all variables are global)
while (e.hasMoreElements()) {
element = (IdInformation)e.nextElement();
if (element.getKind() == PascalToken.VAR) {
result += String.format("%-20s%s", element.getName()+":", ".word 0\n");
}
}
code.append("#Program Name: " + root.getName() + "\n");
code.append(".data \n");
code.append(result);