Ejemplo n.º 1
0
        public override Reply <TResult> Invoke(CharStream <TUserState> stream)
        {
            var tag    = stream.StateTag;
            var eReply = EndParser.Invoke(stream);

            if (eReply.Status == ReplyStatus.Error && tag == stream.StateTag)
            {
                var reply = CharParser1.Invoke(stream);
                if (reply.Status == ReplyStatus.Ok)
                {
                    return(ParseRestOfString(stream, reply.Result, reply.Error));
                }
                else
                {
                    var error = tag == stream.StateTag
                            ? ErrorMessageList.Merge(eReply.Error, reply.Error)
                            : reply.Error;
                    return(new Reply <TResult> {
                        Status = reply.Status, Error = error
                    });
                }
            }
            else if (eReply.Status == ReplyStatus.Ok)
            {
                var result = Mapping.Invoke("", eReply.Result);
                return(new Reply <TResult> {
                    Status = ReplyStatus.Ok, Result = result, Error = eReply.Error
                });
            }
            else
            {
                return(new Reply <TResult> {
                    Status = eReply.Status, Error = eReply.Error
                });
            }
        }
Ejemplo n.º 2
0
        public override Reply <string> Invoke(CharStream <TUserState> stream)
        {
            var tag   = stream.StateTag;
            var reply = CharParser1.Invoke(stream);

            if (reply.Status == ReplyStatus.Ok)
            {
                return(ParseRestOfString(stream, reply.Result, reply.Error));
            }
            else if (reply.Status == ReplyStatus.Error && tag == stream.StateTag)
            {
                return new Reply <string> {
                           Status = ReplyStatus.Ok, Result = "", Error = reply.Error
                }
            }
            ;
            else
            {
                return new Reply <string> {
                           Status = reply.Status, Error = reply.Error
                }
            };
        }
    }