Exemple #1
0
 public NFA Evaluate()
 {
     if (Op == RegOperation.String)
     {
         return(NFA.GenerateFromString(Content, Alphabet));
     }
     if (Op == RegOperation.Set)
     {
         return(NFA.GenerateFromSet(Content, Alphabet));
     }
     else if (Op == RegOperation.Union)
     {
         return(NFA.Union(Left.Evaluate(), Right.Evaluate()));
     }
     else if (Op == RegOperation.Concat)
     {
         return(NFA.Concat(Left.Evaluate(), Right.Evaluate()));
     }
     else if (Op == RegOperation.Star)
     {
         return(NFA.KleeneStar(Left.Evaluate()));
     }
     else if (Op == RegOperation.Plus)
     {
         return(NFA.Plus(Left.Evaluate()));
     }
     else if (Op == RegOperation.Group || Op == RegOperation.NonGroup)
     {
         return(Left.Evaluate());
     }
     else
     {
         return(null);
     }
 }
Exemple #2
0
 public override NFA Visit()
 {
     return(NFA.Concat(Left.Visit(), Right.Visit()));
 }
Exemple #3
0
    public static NFA Plus(NFA m)
    {
        var ret = NFA.Concat(m, NFA.KleeneStar(m));

        return(ret);
    }