import eprog.EprogIO;

/**
 * EProg Uebung #3171<br><br>
 *
 * This class implements <tt>main</tt>. Optionally you can call
 * Vektoren.java with the commandline argument --debug to perform some
 * selftests.<br><br>
 *
 * <tt>java Vektoren --debug</tt>
 * <br><br>
 * The main logic is implemented in Value, Scanner and Parser.
 *
 * @author Hannes Eder <e9521554@student.tuwien.ac.at>
 * @see Value
 * @see Scanner
 * @see Parser
 * @see TestVektoren#test_All
 */
public class Vektoren
{
  public static void main(String[] args) throws Exception
  {
    boolean debug = false;

    // eval command line arguments
    for( int i=0; i<args.length; i++ )
    {
      if ( args[i].equals("--debug"))
        debug = true;
    }

    // perform selftest, if in debug mode
    if ( debug )
    {
      if ( !TestVektoren.test_All( System.err ) )
      {
        System.err.println("POST (Power On Self Test) failed. " +
                           "starting the debugger is a good idea :)");
        System.exit( 0 );
      }
    }

    // allow the work is done below
    try
    {
      String expr = EprogIO.readWord();
      EprogIO.println(
        new Parser( true ).run( new Scanner( expr, true )).toString()
      );
    }
    catch( Exception e )
    {
      EprogIO.println("FALSCHE EINGABE");
    }

    System.exit( 0 );
  }
}