private Expr GenerateZ3ToExpr(Value expr, RankedAlphabetSort outputAlph) { switch (expr.sort.kind) { case (FastSortKind.Bool): { if (expr.token.Kind == Tokens.TRUE) return z3p.True; if (expr.token.Kind == Tokens.FALSE) return z3p.False; break; } case (FastSortKind.Int): { return z3p.MkInt(Convert.ToInt32(expr.token.text)); } case (FastSortKind.Real): { return z3p.Z3.MkReal(expr.token.text); } case (FastSortKind.String): { return z3p.MkListFromString(expr.token.text.Substring(1, expr.token.text.Length - 2), z3p.CharSort); } case (FastSortKind.Tree): { String[] lr = expr.token.text.Split('.'); return z3p.GetEnumElement(lr[0], lr[1]); } } throw new Exception("Unexpected Sort"); }
private Expr GenerateZ3WhereExpr(Value expr, FastTransducerInstance fti) { switch (expr.sort.kind) { case (FastSortKind.Char): { return z3p.MkNumeral(expr.token.ToInt(), z3p.CharSort); } case (FastSortKind.Bool): { if (expr.token.Kind == Tokens.TRUE) return z3p.True; if (expr.token.Kind == Tokens.FALSE) return z3p.False; break; } case (FastSortKind.Int): { return z3p.MkInt(expr.token.ToInt()); } case (FastSortKind.Real): { String[] parts = expr.token.text.Split('.'); if (parts.Length == 2 && Regex.IsMatch(parts[1],"[0]+")) { return z3p.Z3.MkReal(parts[0]); } return z3p.Z3.MkReal(expr.token.text); } case (FastSortKind.String): { return z3p.MkListFromString(expr.token.text.Substring(1, expr.token.text.Length - 2), z3p.CharSort); } case (FastSortKind.Tree): { String[] lr = expr.token.text.Split('.'); return z3p.GetEnumElement(lr[0], lr[1]); } } throw new Exception("Unexpected Sort"); }
//Generates the code for a Value expression private static bool PrintExpr(List<FastToken> children, Value ex, StringBuilder sb) { if (ex.token.text.Split('/').Length==2) sb.Append(" ((double)" + ex.token.text + ") "); else sb.Append(" " + ex.token.text + " "); return true; }