Exemple #1
0
 public SimpleSpace()
     :
     base(
         inp => Prim.Many(Prim.Character(' '))
         .Parse(inp)
         )
 {
 }
Exemple #2
0
 public StringParse(IEnumerable <char> str)
     :
     base(
         inp => str.Count() == 0
                   ? Prim.Return(ImmutableList.Empty <ParserChar>()).Parse(inp)
                   : (from x in Prim.Character(str.First())
                      from xs in Prim.String(str.Skip(1))
                      select x.Cons(xs))
         .Parse(inp)
         )
 {
 }
Exemple #3
0
 public WhiteSpace()
     :
     base(
         inp => Prim.SkipMany(
             Prim.Character(' ')
             | Prim.Character('\t')
             | Prim.Character('\n')
             | Prim.Character('\r')
             )
         .Parse(inp)
         )
 {
 }
Exemple #4
0
 public Integer()
     :
     base(inp =>
          (from minus in Prim.Try(Prim.Character('-') | Prim.Return(new ParserChar('+')))
           from digits in Prim.Many1(Prim.Digit())
           let v = DigitsToInt(digits)
                   select minus.Value == '+'
             ? v
             : -v)
          .Parse(inp)
          )
 {
 }