package ch.bfh; import ch.bfh.lexer.LexerException; import ch.bfh.parser.ParserException; import ch.bfh.parser.StatementParser; import java.util.NoSuchElementException; 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: "); try { String expression = scanner.nextLine(); sp.parseStatement(expression); System.out.println("Result: " + sp.getValue()); } catch (LexerException | ParserException e) { System.out.println(e.getMessage()); } catch (NoSuchElementException e){ System.out.println("\nBuffer was closed. Exiting."); System.exit(0); } } } }