-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
34 lines (33 loc) · 1.1 KB
/
Main.java
File metadata and controls
34 lines (33 loc) · 1.1 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
package MathEngine;
import java.util.Scanner;
import MathEngine.Executor.Executor;
import MathEngine.Lexer.*;
import MathEngine.Parser.AstNode;
import MathEngine.Parser.Parser;
class Main{
public static void main(String args[]){
Style style = new Style();
style.printTitle();
Scanner inputScanner = new Scanner(System.in);
String input = "";
Lexer lexer = new Lexer();
Parser parser;
while(!input.equals("exit")){
System.out.print(">>> ");
input = inputScanner.nextLine();
if(input.equals("exit")) break;
try{
LexerNode lexer_output = lexer.line_lexer(input);
parser = new Parser(lexer_output);
AstNode ast = parser.parse();
Executor exec = new Executor();
exec.build_bytecode(ast);
double answer = exec.execute_instructions();
System.out.println(answer);
}catch(RuntimeException e){
System.out.println(e.getMessage());
}
}
inputScanner.close();
}
}