/* * @topic T10170 Desktop Calculator v3 * @brief main driver program */ package wk03_calc_v3; public class MainApp { public static void main( String[] args ) { for(;;) { StringBuilder input = new StringBuilder( Validator.getString( Validator.sc, "> " ) ); if ( "quit".equals( input.toString() ) ) { System.out.println( "Bye!" ); System.exit( 0 ); } Lexer lexer = new Lexer( input ); AstNode result = lexer.startRule(); if ( result.type == AstNode.ERROR ) { System.out.println( result.value ); } else { // if everything is okay, display content // of the AST (abstract syntax tree) result.print(0); System.out.println( "Success!" ); } }// forever }//main }//class MainApp