public static Parser <T> Phrase <T>(Parser <T> p) { var phrase = WhiteSpaceParser.Opt().Drop(p.DropRight(WhiteSpaceParser.Opt())); return(new Parser <T>(reader => { return phrase.Parse(reader).SelectMany((v, reader2) => reader2.Eof ? new Success <T>(v, reader2) as IParseResult <T> : new Failure <T>("Input is longer than a phrase", reader2)); })); }
public static Parser <string> Regex(string pattern) { return(WhiteSpaceParser.Opt().Drop(BuildParserFromRegex(pattern))); }
public static Parser <string> String(string s) { return(WhiteSpaceParser.Opt().Drop(BuildParserFromString(s))); }