Beispiel #1
0
        public ParserAppendResult Append(int character)
        {
            if (this.state == State.Reset)
            {
                this.state   = State.None;
                this.Command = null;
                this.buffer.Clear();
            }

            switch (this.state)
            {
            case State.None:
                return(this.AppendNone(character));

            case State.Basic:
                return(this.AppendBasic(character));

            case State.ControlSequence:
                return(this.AppendControlSequence(character));

            case State.OSCommand:
                return(this.AppendOSCommand(character));

            case State.PrivacyMessage: // these are identical for now as we do not support them.
            case State.ApplicationProgramCommand:
                return(this.AppendUntilST(character));

            default:
                throw new InvalidOperationException("Invalid parser state.");
            }
        }
Beispiel #2
0
 private ParserAppendResult CompleteCommand(Commands.Base command, ParserAppendResult result = ParserAppendResult.Complete)
 {
     this.Command = command ?? throw new ArgumentNullException(nameof(command));
     this.state   = State.Reset;
     return(result);
 }