blob: ea011852fac9d8f3d730f4015222633048188495 (
plain)
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
|
package ch.bfh;
import ch.bfh.lexer.LexerException;
import ch.bfh.parser.ParserException;
import ch.bfh.parser.StatementParser;
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
StatementParser sp = new StatementParser();
while (true) {
System.out.print("Type your expression: ");
String expression = scanner.nextLine();
try {
sp.parseStatement(expression);
System.out.println("Result: " + sp.getValue());
} catch (LexerException | ParserException e) {
System.out.println(e.getMessage());
}
}
}
}
|