-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
31 lines (29 loc) · 1.09 KB
/
Main.java
File metadata and controls
31 lines (29 loc) · 1.09 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
import java.util.*;
import java.io.*;
import util.*;
public class Main {
public static void main(String[] args) {
Lexer lexer = new Lexer();
String filename = "test.alg";
StringBuilder algorithm = new StringBuilder();
try (BufferedReader br = new BufferedReader(new FileReader("algorithms/" + filename))) {
String line;
while ((line = br.readLine()) != null) {
algorithm.append(line);
}
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
}
List<Token> tokens;
try {
tokens = lexer.tokenize(algorithm.toString().trim());
System.out.println("Tokens: " + tokens);
String pythonCode = Translator.translateToPython(tokens);
System.out.println("Python Code: \n" + pythonCode);
String complexity = CompAnalysis.analyzeTimeComplexity(tokens);
System.out.println("Estimated Time Complexity: " + complexity);
} catch (Exception e) {
e.printStackTrace();
}
}
}