String diagPred(Expr expr)
  {
    if (expr instanceof Expr.And)
    {
      Expr arg = ((Expr.And)expr).expr;
      if (arg instanceof Expr.Ref)
      {
        Expr.Rule rule = ((Expr.Ref)arg).rule;
        return diagName(rule);
      }
      else
        return arg.asString();
    }

    else if (expr instanceof Expr.Not)
    {
      Expr arg = ((Expr.Not)expr).expr;
      if (arg instanceof Expr.Ref)
      {
        Expr.Rule rule = ((Expr.Ref)arg).rule;
        return "not " + diagName(rule);
      }
      else if (arg instanceof Expr.Any)
        return "end of text";
      else
        return "not " + arg.asString();
    }

    else throw new Error("SNOC");
  }