Exemplo n.º 1
0
 /// <summary>
 /// Returns the mapper type for an item, or null if it is not a mapper type
 /// </summary>
 /// <param name="item">The item to investigate</param>
 /// <returns>The mapper type or null</returns>
 public static Type MapperType(BNFItem item)
 {
     return
         (item.GetType().IsConstructedGenericType&& item.GetType().GetGenericTypeDefinition() == typeof(Mapper <>)
             ? item.GetType().GetGenericArguments().First()
             : null);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Constructs a new match
 /// </summary>
 /// <param name="token">The token that matched</param>
 /// <param name="item">The item that matched</param>
 /// <param name="subMatches">Submatches</param>
 public Match(BNFItem token, ParseToken item, Match[] subMatches, bool matched)
 {
     Token      = token;
     Item       = item;
     SubMatches = subMatches;
     Matched    = matched;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Constructs a new mapper item
 /// </summary>
 /// <param name="token">The token being matched</param>
 /// <param name="matcher">The matcher function</param>
 public static Mapper <T> Mapper <T>(BNFItem token, Func <Match, T> matcher)
 {
     return(new BNF.Mapper <T>(token, matcher));
 }
Exemplo n.º 4
0
 /// <summary>
 /// The token in the sequence
 /// </summary>
 /// <param name="sequence">The token to repeat</param>
 public static Sequence Sequence(BNFItem sequence)
 {
     return(new BNF.Sequence(sequence));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Constructs a new optional item
 /// </summary>
 /// <param name="item">The item to parse</param>
 public static Optional Optional(BNFItem token)
 {
     return(new BNF.Optional(token));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Constructs a new mapper item
 /// </summary>
 /// <param name="token">The token being matched</param>
 /// <param name="matcher">The matcher function</param>
 public Mapper(BNFItem token, Func <Match, T> matcher)
 {
     Matcher = matcher;
     Token   = token;
 }