public Message Parse(string input)
        {
            var msg = new Message();
            var scanner = new Strscan(input);

            var m = scanner.Match(reSender);
            if (m != null)
            {
                msg.Sender = m.Groups[1].Value;
            }

            m = scanner.Match(reWord);
            msg.Command = m.Groups[1].Value.ToUpperInvariant();

            while(!scanner.AtEnd)
            {
                m = scanner.Match(reArgv);
                if (m.Groups["trailing"].Success)
                {
                    msg.Argv.Add(m.Groups["trailing"].Value);
                    break;
                }
                else
                {
                    msg.Argv.Add(m.Groups["middle"].Value);
                }
            }

            return msg;
        }
Exemple #2
0
        public Message Parse(string input)
        {
            var msg     = new Message();
            var scanner = new Strscan(input);

            var m = scanner.Match(reSender);

            if (m != null)
            {
                msg.Sender = m.Groups[1].Value;
            }

            m           = scanner.Match(reWord);
            msg.Command = m.Groups[1].Value.ToUpperInvariant();

            while (!scanner.AtEnd)
            {
                m = scanner.Match(reArgv);
                if (m.Groups["trailing"].Success)
                {
                    msg.Argv.Add(m.Groups["trailing"].Value);
                    break;
                }
                else
                {
                    msg.Argv.Add(m.Groups["middle"].Value);
                }
            }

            return(msg);
        }