Ejemplo n.º 1
0
 public CnfProduction(string lhs, string rhs1, string rhs2, int index)
     : base(lhs, rhs2 != null ? string.Concat(rhs1, ' ', rhs2) : rhs1)
 {
     Index = index;
     Rhs1  = rhs1;
     Rhs2  = rhs2;
     if (IsLexical)
     {
         if ((Rhs.Length > 3) && Rhs.StartsWith("@\"") && (Rhs[Rhs.Length - 1] == '"'))
         {
             Pattern = Rhs.Substring(2, Rhs.Length - 3);
         }
         else if ((Rhs.Length > 2) && (Rhs[0] == '"') && (Rhs[Rhs.Length - 1] == '"'))
         {
             Literal = Rhs.Substring(1, Rhs.Length - 2);
         }
         else
         {
             Literal = Rhs;
         }
         if (Pattern != null)
         {
             Acceptor = new Regex(string.Format("^({0})", Pattern), RegexOptions.Compiled);
         }
     }
 }