コード例 #1
0
 // TODO: extension method
 public static bool IsCompleteOrInvalid(SourceCodeProperties props, bool allowIncompleteStatement)
 {
     return
         props == SourceCodeProperties.IsInvalid ||
         props != SourceCodeProperties.IsIncompleteToken &&
         (allowIncompleteStatement || props != SourceCodeProperties.IsIncompleteStatement);
 }
コード例 #2
0
 // TODO: extension method
 public static bool IsCompleteOrInvalid(SourceCodeProperties props, bool allowIncompleteStatement)
 {
     return
         (props == SourceCodeProperties.IsInvalid ||
          props != SourceCodeProperties.IsIncompleteToken &&
          (allowIncompleteStatement || props != SourceCodeProperties.IsIncompleteStatement));
 }
コード例 #3
0
ファイル: CommandLine.cs プロジェクト: tylike/IronScheme
        /// <summary>
        /// Read a statement, which can potentially be a multiple-line statement suite (like a class declaration).
        /// </summary>
        /// <param name="continueInteraction">Should the console session continue, or did the user indicate
        /// that it should be terminated?</param>
        /// <returns>Expression to evaluate. null for empty input</returns>
        public string ReadStatement(out bool continueInteraction)
        {
            StringBuilder b = new StringBuilder();
            int           autoIndentSize = 0;

            if (!LanguageProvider.InputRedirected)
            {
                _console.Write(Prompt, Style.Prompt);
            }

            while (true)
            {
                string line = ReadLine(autoIndentSize);
                continueInteraction = true;

                if (line == null)
                {
                    continueInteraction = false;
                    return(null);
                }

                bool allowIncompleteStatement = TreatAsBlankLine(line, autoIndentSize);
                b.Append(line);
                b.Append("\n");

                string code = b.ToString();

                SourceCodeProperties props = _engine.GetCodeProperties(code, SourceCodeKind.InteractiveCode);

                if (SourceCodePropertiesUtils.IsCompleteOrInvalid(props, allowIncompleteStatement))
                {
                    return(props != SourceCodeProperties.IsEmpty ? code : null);
                }

                if (_options.AutoIndent && _options.AutoIndentSize != 0)
                {
                    autoIndentSize = GetNextAutoIndentSize(code);
                }

                if (!LanguageProvider.InputRedirected)
                {
                    // Keep on reading input
                    _console.Write(PromptContinuation, Style.Prompt);
                }
            }
        }