/// <summary> /// A label for the parser /// </summary> /// <param name="expected">What was expected</param> public static Parser <T> label <T>(this Parser <T> p, string expected) => inp => { var res = p(inp); if (res.Tag == ResultTag.Consumed) { return(res); } if (res.Reply.Tag == ReplyTag.Error) { return(EmptyError <T>(ParserError.Expect(inp.Pos, res.Reply.Error.Msg, expected))); } if (res.Reply.Error == null || res.Reply.Error.Tag == ParserErrorTag.Unknown) { return(res); } else { return(EmptyOK(res.Reply.Result, res.Reply.State, ParserError.Expect(inp.Pos, res.Reply.Error.Msg, expected))); } };