Exemple #1
0
 private static Parser <Json> JsonRoot(ParsersBase p)
 {
     return(p.Whitespace().SkipL(
                () => JsonObject(p) |
                (() => JsonArray(p)) |
                (() => p.Fail <Json>("expected an object or an array"))));
 }
Exemple #2
0
 public Parser <NamedTemplate> NamedTemplate()
 {
     return(Name().Bind(
                n => (Template(string.Empty) | (() => _p.Fail <Template>("template"))).Bind(
                    t => End().BindIgnoringLeft(
                        _p.Whitespace().BindIgnoringLeft(
                            Parser.Return(new NamedTemplate(n, t)))))));
 }
Exemple #3
0
        private static Parser <IEnumerable <string> > ColumnTitlesParser(ParsersBase p)
        {
            var beginLineCommentParser = p.Token(p.String("#"));
            var commaParser            = p.Token(p.String(","));
            var columnTitleParser      = p.Token(p.Quoted() | (() => p.R(@"(\w+)")));

            return(p.Whitespace()
                   .SkipL(
                       () => beginLineCommentParser.SkipL(
                           () => columnTitleParser.SepBy(commaParser))));
        }