This question is a continuation of Assignment 5. The requirement is the same except that your code should run faster.

computer science

Description

3 Instruction 

This question is a continuation of Assignment 5. The requirement is the same except that your code should run faster. You will use the same scanner and symbol file, i.e., 

A5Scanner.java and A5Sym.java. The parser will be called E2.java. You need to refactor your A5.java into E2.java. The main method is the same as in A5.java: public static void main ( String [] args ) throws Exception { BufferedWriter bw =new BufferedWriter (new FileWriter ("a5. output ") ) ; A5Scanner scanner = new A5Scanner (new FileInputStream (new File ("A5. tiny ") ) ) ; Symbol token ; while (( token = scanner . yylex () ) . sym != A5Sym . EOF ) { tokens . add ( token ) ; } tokens . add ( token ) ; // add EOF as the last token in the array boolean legal = program () && nextToken () . sym == A5Sym . EOF ; bw . write (( legal ) ?" legal ":" illegal ") ; bw . close () ; } The commands to test your program are: javac E2 . java A5Scanner . java A5Sym . java Symbol . java java E2 4 Marking scheme Your marks depends on your program speed according to the following table: Seconds Your Mark < 2 5 <2.5 4 < 3 3 < 4 2 < 5 1 < 10 0.5 ≥ 10 0 Your code should pass all the test cases. If any of your parsing result is wrong, you won’t get any mark


Related Questions in computer science category