-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompile.java
More file actions
65 lines (53 loc) · 1.39 KB
/
Copy pathCompile.java
File metadata and controls
65 lines (53 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
*
* Main Driver program for 312 exercise.
*
* This class has been provided to students
*
* @Author: Roger Garside, John Mariani, John Vidler, Paul Rayson
*
*
**/
import java.io.* ;
public class Compile {
public static String fileName;
/**
*
* main
*
**/
private void go() throws IOException {
String prefix = "Programs Folder" + File.separator + "program";
int fileNumber = -1;
int exitFlag = 0;
System.out.println( "312START" );
PrintStream out = null;
String outputFile = new String( "res.txt" );
boolean goon = true;
try {
out = new PrintStream( new FileOutputStream(outputFile) );
} catch( Exception e ) {
System.out.println("unable to open output file "+e);
System.exit(0);
}
while( goon ) {
fileNumber++ ;
fileName = prefix + fileNumber;
goon = ((new File(fileName)).exists());
if( goon ) {
System.out.println();
System.out.println( "312FILE " + fileName );
SyntaxAnalyser syn = new SyntaxAnalyser(fileName) ;
syn.parse( out ) ;
} else System.out.println(fileName+" does not exist");
}
System.out.println() ;
System.out.println("312FINISH") ;
out.flush();out.close();
System.exit(exitFlag) ;
} // end of main method
public static void main(String args[]) throws IOException {
Compile c = new Compile();
c.go();
};
} // end of class Compile