Exemplo n.º 1
0
// If the names of all children have the form (PREFIX)(INDEX)(SUFFIX),
// return the common PREFIX and SUFFIX.
void DispValue::get_index_surroundings(string& prefix, string& suffix) const
{
    assert (nchildren() > 0);

    prefix = child(0)->full_name();
    suffix = child(0)->full_name();

    for (int i = 1; i < nchildren(); i++)
    {
	prefix = common_prefix(prefix, child(i)->full_name());
	suffix = common_suffix(suffix, child(i)->full_name());
    }
}
Exemplo n.º 2
0
int
main (int argc, char **argv)
{
  int i, pid, status, res;
  int time_out, max_decisions;
  char *name;

  pretty_print = 0;
  multiple_files = 0;
  time_out = 3600;
  max_decisions = -1;		/* no bound is default */
#ifdef SAT2002FMT
  verbose = 1;
#else
  verbose = 0;
#endif
  limmat = 0;
  sparse = 0;
  name = 0;

  for (i = 1; i < argc; i++)
    {
      if (!strcmp (argv[i], "-h") || !strcmp (argv[i], "--help"))
	{
	  usage ();
	  exit (0);
	}
      else if (!strcmp (argv[i], "--clauses"))
	{
	  assignment_as_clauses = 1;
	}
      else if (!strcmp (argv[i], "--version"))
	{
	  printf ("%s\n", version_Limmat ());
	  exit (0);
	}
      else if (!strcmp (argv[i], "--options"))
	{
	  printf ("%s\n", options_Limmat ());
	  exit (0);
	}
      else if (!strcmp (argv[i], "--copyright"))
	{
	  printf ("%s\n", copyright_Limmat ());
	  exit (0);
	}
      else if (!strcmp (argv[i], "-v") || !strcmp (argv[i], "--verbose"))
	{
	  verbose++;
	}
      else if (!strcmp (argv[i], "-s") || !strcmp (argv[i], "--sparse"))
	{
	  sparse++;
	}
      else if (!strcmp (argv[i], "-p") || !strcmp (argv[i], "--pretty-print"))
	{
	  pretty_print = 1;
	}
      else if (argv[i][0] == '-' && argv[i][1] == 'm')
	{
	  if (argv[i][2])
	    {
	      if (isdigit ((int) argv[i][2]))
		{
		  max_decisions = atoi (argv[i] + 2);
		}
	      else
		goto EXPECTED_DIGIT_FOR_MAX_DECISIONS_ARGUMENT;
	    }
	  else if (++i < argc && isdigit ((int) argv[i][0]))
	    {
	      max_decisions = atoi (argv[i]);
	    }
	  else
	    goto EXPECTED_DIGIT_FOR_MAX_DECISIONS_ARGUMENT;
	}
      else
	if (argv[i][0] == '-' &&
	    argv[i][1] == '-' &&
	    argv[i][2] == 't' &&
	    argv[i][3] == 'i' &&
	    argv[i][4] == 'm' &&
	    argv[i][5] == 'e' &&
	    argv[i][6] == '-' &&
	    argv[i][7] == 'o' &&
	    argv[i][8] == 'u' && argv[i][9] == 't' && argv[i][10] == '=')
	{
	  if (isdigit ((int) argv[i][11]))
	    {
	      max_decisions = atoi (argv[i] + 11);
	    }
	  else
	    {
	    EXPECTED_DIGIT_FOR_MAX_DECISIONS_ARGUMENT:
	      fprintf (stderr,
		       "*** limmat: expected digit for max decisions argument\n");
	      exit (1);
	    }
	}
      else if (argv[i][0] == '-' && argv[i][1] == 't')
	{
	  if (argv[i][2])
	    {
	      if (isdigit ((int) argv[i][2]))
		{
		  time_out = atoi (argv[i] + 2);
		}
	      else
		goto EXPECTED_DIGIT_FOR_TIME_OUT_ARGUMENT;
	    }
	  else if (++i < argc && isdigit ((int) argv[i][0]))
	    {
	      time_out = atoi (argv[i]);
	    }
	  else
	    goto EXPECTED_DIGIT_FOR_TIME_OUT_ARGUMENT;
	}
      else
	if (argv[i][0] == '-' &&
	    argv[i][1] == '-' &&
	    argv[i][2] == 't' &&
	    argv[i][3] == 'i' &&
	    argv[i][4] == 'm' &&
	    argv[i][5] == 'e' &&
	    argv[i][6] == '-' &&
	    argv[i][7] == 'o' &&
	    argv[i][8] == 'u' && argv[i][9] == 't' && argv[i][10] == '=')
	{
	  if (isdigit ((int) argv[i][11]))
	    {
	      time_out = atoi (argv[i] + 11);
	    }
	  else
	    {
	    EXPECTED_DIGIT_FOR_TIME_OUT_ARGUMENT:
	      fprintf (stderr,
		       "*** limmat: expected digit for time out argument\n");
	      exit (1);
	    }
	}
      else if (argv[i][0] == '-')
	{
	  fprintf (stderr,
		   "*** limmat: unknown command line option '%s' (try '-h')\n",
		   argv[i]);
	  exit (1);
	}
      else if (name)
	{
	  multiple_files = 1;
	}
      else
	name = argv[i];
    }

  if (multiple_files)
    {
      prefix = common_prefix (argv, argc);
      suffix = common_suffix (argv, argc);
      len_prefix = strlen (prefix);
      len_suffix = strlen (suffix);
      sparse = 1;
    }

  if (verbose)
    sparse = 0;

  if (pretty_print)
    {
      if (multiple_files)
	{
	  fprintf (stderr,
		   "*** limmat: can not pretty print multiple files\n");
	  exit (1);
	}

      limmat = new_Limmat (0);
      parse (name);
      print_Limmat (limmat, stdout);
      delete_Limmat (limmat);
      res = ABNORMAL_EXIT_VALUE;
    }
  else
    {
      res = 0;

      if (multiple_files)
	{
	  for (i = 1; !res && i < argc; i++)
	    {
	      if (!skip_arg (argv, &i))
		{
		  if ((pid = fork ()))
		    {
		      wait (&status);
		      if (WIFSIGNALED (status) ||
			  WEXITSTATUS (status) == ABNORMAL_EXIT_VALUE)
			{
			  res = ABNORMAL_EXIT_VALUE;
			}
		    }
		  else
		    child (argv[i], time_out, max_decisions);
		}
	    }
	}
      else
	child (name, time_out, max_decisions);
    }

  if (prefix)
    free (prefix);

  if (suffix)
    free (suffix);

  exit (res);
  return res;
}