-
Notifications
You must be signed in to change notification settings - Fork 145
Expand file tree
/
Copy pathCompiler.java
More file actions
29 lines (25 loc) · 896 Bytes
/
Compiler.java
File metadata and controls
29 lines (25 loc) · 896 Bytes
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
import java.io.File;
/**
*
* @author wangjs
*/
//This is main class used to call other parts of the compiler
public class Compiler {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//Read the files stored in the directory provided
File files = new File(args[0]);
File[] allFile = files.listFiles();
/*Traverse the files in the directory.
Use lexer to produce the tokens and use parser to check the programming language grammar.
Then check whether there are lots of sementic mistakes and produce the vm codes*/
for (File f : allFile) {
if (f.isFile() && f.getName().contains(".jack")) {
Lexer lexer = new Lexer(args[0], f.getName());
Parser parser = new Parser(lexer);
}
}
}
}