コード例 #1
0
        public void ReplConsoleBreakEvaluateAndContinue()
        {
            var input       = new StringReader(@"
; evaluate code with a `break`
(progn
    (setf one 1)
    (format t ""~&about to break"")
    (break ""~&one = ~S"" one)
    (format t ""~&let's go~%""))

; we're in the debugger here; evaluate something
(+ one 3)
continue
#quit
");
            var output      = new StringWriter();
            var error       = new StringWriter();
            var replConsole = new ReplConsole("*test*", input, output, error);

            replConsole.Run();
            var expectedOutput = NormalizeNewlines(@"
_> _> _> (_> (_> (_> (_> 
about to break
one = 1
Non-fatal break.  Type 'continue' to resume evaluation.
DEBUG:> DEBUG:> DEBUG:> 4
DEBUG:> 
let's go
_> 
".Trim('\r', '\n'));
            var actualOutput   = NormalizeNewlines(output.ToString());

            Assert.Empty(error.ToString());
            Assert.Equal(expectedOutput, actualOutput);
        }
コード例 #2
0
        public void NoBreakOnFatalError()
        {
            var input       = new StringReader(@"
; evaluate code with an error
(+ 1 asdf)
#quit
");
            var output      = new StringWriter();
            var error       = new StringWriter();
            var replConsole = new ReplConsole("*test*", input, output, error);

            replConsole.Run();
            var expectedOutput = NormalizeNewlines(@"
_> _> _> Symbol 'ASDF' not found:
  at (ROOT) in '*test*': (1, 6)

_> 
".Trim('\r', '\n'));
            var actualOutput   = NormalizeNewlines(output.ToString());

            Assert.Empty(error.ToString());
            Assert.Equal(expectedOutput, actualOutput);
        }
コード例 #3
0
        /// <summary>
        /// Main static method
        /// </summary>
        /// <author>ALVES Quentin</author>
        /// <note>Program main entry point</note>
        /// <param name="args" >Arguments pass to the program.</param>
        public static void Main(string[] args)
        {
            var console   = new ReplConsole( );
            var compiler  = new Compiler( );
            var evaluator = new Evaluator( );

            string f = @"function re() if 10 * ( 10 + 5 ) == 10 and ! ( 10 + 10 ) != 10 then end end";

            var result      = compiler.Compile(f);
            var evaluations = evaluator.Evaluate(compiler.Nodes);

            // Display all compilation error
            console.Display(compiler);

            // Display current compilation token list
            //console.Display( compiler.Tokens );

            // Display current compilation syntax node list
            console.Display(compiler.Nodes);

            // Display expression evaluation
            console.Display(evaluations);
        }