コード例 #1
0
ファイル: EditorView.cs プロジェクト: whitespeed/uPython
    /// <summary>
    /// Executes the interpreter.
    /// </summary>
    private void ExecuteInterpreter()
    {
        string line = Buffer.CurrentLine.TrimEnd();

        // Append and return if is a block code
        if (!String.IsNullOrEmpty(line) &&
            line.Substring(line.Length - 1, 1) == ":" && !Buffer.BlockInspector)
        {
            Buffer.InterpreterBlock = line;
            Buffer.AppendInterpreter("");
            Buffer.BlockInspector = true;
            return;
        }
        if (!Buffer.BlockInspector)
        {
            //Executes a single line
            string output = PythonMachine.Compile(Buffer.CurrentLine);
            Buffer.AppendInterpreter(output);
        }
        else
        {
            //Block Code (eg.: if 5 < 10:    )
            if (string.IsNullOrEmpty(line))
            {
                //Execute block when enter a blank line
                string output = PythonMachine.Compile(Buffer.InterpreterBlock);
                Buffer.AppendInterpreter(output);
                //Empties current block
                Buffer.InterpreterBlock = string.Empty;
                Buffer.BlockInspector   = false;
            }
            else
            {
                //stores current block code.
                Buffer.InterpreterBlock += "\n" + line;
                Buffer.AppendInterpreter("");
            }
        }
    }
コード例 #2
0
    /// <summary>
    /// Executes the interpreter.
    /// </summary>
    private void ExecuteInterpreter()
    {
        string output = PythonMachine.Compile(Buffer.CurrentLine);

        Buffer.AppendInterpreter(output);
    }