public void SetOptionValue(ReplOptions option, object value)
        {
            if (_restoreOptions == null)
            {
                _restoreOptions = new Dictionary <ReplOptions, object>();
            }

            try {
                _restoreOptions.Add(option, _window.GetOptionValue(option));
            } catch (ArgumentException) {
                // Don't overwrite existing 'restore' values
            }
            _window.SetOptionValue(option, value);
        }
Ejemplo n.º 2
0
 public object GetOptionValue(ReplOptions option)
 {
     return(null);
 }
Ejemplo n.º 3
0
 public void SetOptionValue(ReplOptions option, object value)
 {
 }
Ejemplo n.º 4
0
        private static void Main(string[] args)
        {
            var text = new StringBuilder();

            while (true)
            {
                if (text.Length == 0)
                {
                    Console.Write("> ");
                }
                else
                {
                    Console.Write("· ");
                }

                var line = Console.ReadLine();
                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }

                if (line.StartsWith('/'))
                {
                    switch (line.ToUpperInvariant())
                    {
                    case "/Q":
                    case "/EXIT":
                        return;

                    case "/CLS":
                        Console.Clear();
                        break;

                    case "/L":
                    case "/LEX":
                    case "/SHOWLEX":
                        _replOptions = SwitchFlag(ReplOptions.PrintLexedTokens);
                        var printLexString = _replOptions.HasFlag(ReplOptions.PrintLexedTokens)
                                ? $"#{ConsoleColor.Green}#enabled#RESET#"
                                : $"#{ConsoleColor.Red}#disabled#RESET#";
                        ColoredConsole.WriteLine($"Printing lexed tokens {printLexString}.");
                        break;

                    case "/S":
                    case "/SYNTAX":
                    case "/SHOWSYNTAX":
                        _replOptions = SwitchFlag(ReplOptions.PrintSyntaxTokens);
                        var printSyntaxString = _replOptions.HasFlag(ReplOptions.PrintSyntaxTokens)
                                ? $"#{ConsoleColor.Green}#enabled#RESET#"
                                : $"#{ConsoleColor.Red}#disabled#RESET#";
                        ColoredConsole.WriteLine($"Printing syntax tree {printSyntaxString}.");
                        break;

                    case "/R":
                    case "/RUN":
                        Process(text.ToString());
                        break;

                    case "/E":
                    case "/EMIT":
                        Emit(text.ToString());
                        break;

                    case "/RS":
                    case "/RESET":
                        text.Clear();
                        break;

                    default:
                        Console.Error.WriteLine($"Unknown command: {line}.");
                        break;
                    }
                }
                else
                {
                    text.AppendLine(line);
                }
            }
        }
Ejemplo n.º 5
0
 private static ReplOptions SwitchFlag(ReplOptions flag) => (_replOptions & flag) != 0 ? _replOptions & ~flag : _replOptions ^ flag;
 public object GetOptionValue(ReplOptions option)
 {
     return(_window.GetOptionValue(option));
 }
Ejemplo n.º 7
0
 public object GetOptionValue(ReplOptions option) {
     return null;
 }
Ejemplo n.º 8
0
 public void SetOptionValue(ReplOptions option, object value) {
 }
Ejemplo n.º 9
0
 public object GetOptionValue(ReplOptions option)
 {
     throw new NotImplementedException();
 }