Beispiel #1
0
 private static Parser <Json> JsonLiteral(ParsersBase p)
 {
     return(p.Scope(
                "literal",
                p.Token(p.String("null")).As(new JNull() as Json) |
                (() => p.Double().Map(n => new JNumber(n) as Json)) |
                (() => p.Token(p.Quoted()).Map(s => new JString(s) as Json)) |
                (() => p.Token(p.String("true")).As(new JBool(true) as Json)) |
                (() => p.Token(p.String("false")).As(new JBool(false) as Json))) |
            (() => p.Fail <Json>("expected a literal")));
 }
Beispiel #2
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))));
        }
Beispiel #3
0
 private static Parser <Tuple <string, Json> > JsonKeyValue(ParsersBase p)
 {
     return(p.Quoted().Product(() => p.SkipL(p.Token(p.String(":")), () => JsonValue(p))));
 }