Exemple #1
0
    public (String Filename, NeuOperation?Result) Evaluate(
        IEnumerable <IArgument> arguments)
    {
        var interpreter = new NeuInterpreter();

        ///

        this.Interpreter = interpreter;

        ///

        var droppedArgs = arguments.DropArguments(number: 1);

        ///

        var filename = droppedArgs.GetFirstArgumentSource();

        if (IsNullOrWhiteSpace(filename))
        {
            throw new Exception();
        }

        ///

        var silent = arguments.Get("--silent") == null
            ? false
            : true;

        ///

        var dumpAST = arguments.Get("--dump-ast") is String;

        ///

        if (silent)
        {
            dumpAST = false;
        }

        ///

        if (!silent)
        {
            Write($"  Running test {filename}{(dumpAST ? "\n" : "")}");
            // WriteLine($"  Running test {filename}{(dumpAST ? "\n" : "")}");
        }

        var result = interpreter.Evaluate(filename, droppedArgs, dumpAST: dumpAST, indent: 2);

        ///

        // if (!silent) { // --diagnostic?

        //     WriteLine($"  Result: {result.Dump()}");
        // }

        ///

        return(filename, result);
    }