Beispiel #1
0
        private static void RunFile(string path)
        {
            string          source = File.ReadAllText(path, Encoding.UTF8);
            InterpretResult result = vm.Interpret(source);

            Environment.Exit((int)result);
        }
Beispiel #2
0
 public InterpretException(InterpretResult result, uint exceptionLine, uint exceptionParameter, string exceptionCommand)
 {
     this.result 				= result;
     this.exceptionCommand 		= exceptionCommand;
     this.exceptionLine 			= exceptionLine;
     this.exceptionParameter 	= exceptionParameter;
 }
Beispiel #3
0
        public void RunFile(string file)
        {
            string          code   = File.ReadAllText(file);
            InterpretResult result = Interpret(code);

            Console.Write("Press Any Key To Continue.");
            Console.Read();
        }
Beispiel #4
0
        private static void runFile(string path)
        {
            char[] source = readFile(path).ToCharArray();

            InterpretResult result = run(source);

            clox.Memory.FREE <char>(ref source);

            if (result != InterpretResult.INTERPRET_OK)
            {
                System.Environment.Exit((int)result);
            }
        }
Beispiel #5
0
        private static void runFile(string path)
        {
            char[]          source = readFile(path).ToCharArray();
            InterpretResult result = VM.interpret(source);

            Memory.FREE <char>(ref source);

            if (result == InterpretResult.INTERPRET_COMPILE_ERROR)
            {
                System.Environment.Exit(65);
            }
            if (result == InterpretResult.INTERPRET_RUNTIME_ERROR)
            {
                System.Environment.Exit(70);
            }
        }
Beispiel #6
0
    public InterpretResult Interpret(string source)
    {
        Chunk chunk = new Chunk();

        if (!compiler.Compile(source, ref chunk))
        {
            return(InterpretResult.COMPILE_ERROR);
        }

        currentChunk = chunk;
        ip           = 0;

        InterpretResult result = Run();

        return(result);
    }
Beispiel #7
0
        public static string Interpret(string term)
        {
            var interpretResult = new InterpretResult();

            try
            {
                var expr   = new Parser(new Scanner(term).ScanTokens()).Parse();
                var result = new DiceEngine().Interpret(expr).ToString();

                interpretResult.Error  = null;
                interpretResult.Ast    = new AstPrinter().Print(expr, null);
                interpretResult.Pretty = new PrettyPrinter().PrettyPrint(expr, null);
                interpretResult.Result = result;
            }
            catch (Exception e)
            {
                interpretResult.Error = e.Message;
            }

            return(JsonConvert.SerializeObject(interpretResult, Settings));
        }
Beispiel #8
0
 public InterpretException(InterpretResult result, uint exceptionLine)
 {
     this.result 				= result;
     this.exceptionCommand 		= "";
     this.exceptionLine 			= exceptionLine;
     this.exceptionParameter 	= 0;
 }