/** Parser for Assignment 2 */ import java.io.*; import java.util.*; /** Each parser object in this class contains an embedded lexer which contains an embedded input stream. The * class include a parse() method that will translate the program text in the input stream to the corresponding * AST assuming that the program text forms a syntactically valid Jam program. */ class Parser { private Lexer in; . . . Parser(Lexer i) { in = i; initParser(); } Parser(Reader inputStream) { this(new Lexer(inputStream)); } Parser(String fileName) throws IOException { this(new FileReader(fileName)); } Lexer lexer() { return in; } private void initParser() { . . . } /** Parses the program text in the lexer bound to 'in' and returns the corresponding AST. * @throws ParseException if a syntax error is encountered (including lexical errors). */ public AST parse() throws ParseException { . . . } /** Parses: * :: = if then else * | let in * | map to * | { } * * @return the corresponding AST. */ private AST parseExp() { . . . } . . . }