// In this file the constructor and String2Id and Id2String methods do not need to be modified // However you can always code them differently if you want to. import java.util.*; import java.*; import java.io.*; public class Scanner { private static final int EOF = 255; // This means the end of file public int sym; // The current token on the input, 0 = error token, 255 = end-of-file token public int val; // value of the last number encountered public int id; // id of the last identifier encountered private FileReader fileHandler; // You can use the data structure class called ArrayList to insert identifiers and later retrieve them using // String2Id and Id2String methods public ArrayList identifierList; public Scanner(String fileName) { identifierList = new ArrayList(); fileHandler = new FileReader(fileName); }//End of constructor ///////////////////////////////////////////////////// public void Next() { }//End of Scanner Next ///////////////////////////////////////////////////// public void Error(String errorMsg) { System.out.println(errorMsg); fileHandler.Error(errorMsg); return; } ///////////////////////////////////////////////////// /* IDENTIFIER TABLE METHODS */ /* This method is intended to provide the identifier * and as an input it accepts the index */ public String Id2String(int id) { return ((String)identifierList.get(id)); } ///////////////////////////////////////////////////// /* This method is intended to provide the index of the identifier * in the List. It recieves the identifier as an input and outputs the index */ public int String2Id(String name) { return (identifierList.indexOf(name)); } } // end of class Scanner