private Expr GenerateZ3WhereExpr(Variable expr, FastTransducerInstance fti)
 {
     foreach (var c in fti.consts)
     {
         if (c.name == expr.token.text)
             return c.value;
     }
     return z3p.MkProj(alphabet.tupleKeys.IndexOf(expr.token.text), alphabet.alph.AttrVar);
 }
 private Expr GenerateZ3Expr(Variable expr, FastTransducerInstance fti)
 {
     foreach (var c in fti.consts)
     {
         if (c.name == expr.token.text)
             return c.value;
     }
     throw new Exception("The constant " + expr.token.text + " wasn't defined before");
 }
 private Expr GenerateZ3ToExpr(Variable expr, RankedAlphabetSort outputAlph, List<FastToken> children)
 {
     //Find the child number and return the transition
     int childPosition = 1;
     foreach (var child in children)
     {
         if (child.text == ((Variable)expr).token.text)
         {
             break;
         }
         childPosition++;
     }
     return alphabet.alph.ChildVar(childPosition);
 }
Example #4
0
        internal static FExp MkId(FastToken token)
        {
            string[] parts = token.text.Split('.');

            //This is the case X.Y
            if (parts.Length == 2)
            {
                var succ = Regex.Match(parts[0], @"^[A-Z]");
                if (succ.Success)
                {
                    //X starts with a capital letter, then this is an enum
                    return new EnumValue(token);
                }
                else
                {
                    //Otherwise we are accessing the attribute of the current node
                    return new AttributeVariable(token);
                }
            }
            else
            {
                var res = new Variable(token);
                return res;
            }
        }
 //Generates the code for an output of a transduction when the expression is a Variable
 private static bool PrintOutputTree(List<FastToken> children, Variable ex, String range, StringBuilder sb, bool isapplied)
 {
     if (isapplied)
     {
         //this case is used when a child appear in the output applied to a transduction
         sb.Append(ex.token.text);
         return true;
     }
     //the child is not applied to any transduction
     int i = 0;
     foreach (var c in children)
     {
         if (c.text == ex.token.text)
         {
             sb.Append(" children[" + i + "] ");
             return true;
         }
         i++;
     }
     return true;
 }
 //Generates the code for a Variable expression
 private static bool PrintExpr(List<FastToken> children, Variable ex, StringBuilder sb)
 {
     int i = 0;
     foreach (var c in children)
     {
         if (c.text == ex.token.text)
         {
             sb.Append(" children[" + i + "] ");
             return true;
         }
         i++;
     }
     sb.Append(ex.token.text);
     return true;
 }
 //Compute all the iterators necessary to generate a particular output of a transduction when expr is Variable
 private static bool ComputeIterators(Variable ex, String range, StringBuilder sb, bool isApplied)
 {
     if (isApplied)
         iterCases[0].Insert(0, ex.token.text);
     return true;
 }