COP5555 Parser Program Help
1. Make sure your HW submission has "cop5555.jar" files in it.     It should be extracted into cop5555/Parser.java, cop5555/Scanner.java, cop5555/SyntaxException.java
    (In addition, all your other java files should be under cop5555 directory...)
2. Don't change cop5555_tokens and cop5555_ast package.
3. Don't submit your class files.(java files only)
4. Make sure the next() method in Scanner and parse() method in Parser are public.
5. This is the code for simple test. Following table shows expected output.
import java.io.*;
public class TestParser{
  public static void main(String args[]){
    cop5555.Parser p = null;
    Reader r = null;
    try { r = new BufferedReader(new FileReader(args[0])); }
    catch(FileNotFoundException e){ System.exit(-1); }
    try{ p = new cop5555.Parser(r); }
    catch(IOException e){ System.exit(-1); }
    try{
      cop5555_ast.AST tree = p.parse();
      cop5555_ast.ToStringVisitor v = new cop5555_ast.ToStringVisitor();
      tree.visit(v, "");
      System.out.println(v.getString());
    }
    catch(cop5555.SyntaxException e){System.out.println(e);}
    catch(Exception e){System.out.println(e);}
  }
}
|
Example Input |
Output |
|
program errorTest extends error {}
|
|
|
program test { } |
|
|
program t0 { read ABC [a][b][c]; }
|
|