<commit_before>/* main.c -- main entry point for execution.
 *
 * Command-line arguments are processed by hand.  Eventually switch to
 * getopt, once sophistication of usage demands.
 *
 *
 * SCL; 2012-2014.
 */


#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

#include "common.h"
#include "logging.h"
#include "ptree.h"
#include "solve.h"
#include "automaton.h"
#include "gr1c_util.h"
extern int yyparse( void );
extern void yyrestart( FILE *new_file );


/**************************
 **** Global variables ****/

ptree_t *nonbool_var_list = NULL;

extern ptree_t *evar_list;
extern ptree_t *svar_list;
extern ptree_t *env_init;
extern ptree_t *sys_init;
ptree_t *env_trans = NULL;  /* Built from components in env_trans_array. */
ptree_t *sys_trans = NULL;
extern ptree_t **env_goals;
extern ptree_t **sys_goals;
extern int num_egoals;
extern int num_sgoals;

extern ptree_t **env_trans_array;
extern ptree_t **sys_trans_array;
extern int et_array_len;
extern int st_array_len;

/**************************/


/* Output formats */
#define OUTPUT_FORMAT_TEXT 0
#define OUTPUT_FORMAT_TULIP 1
#define OUTPUT_FORMAT_DOT 2
#define OUTPUT_FORMAT_AUT 3
#define OUTPUT_FORMAT_JSON 5

/* Verification model targets */
#define VERMODEL_TARGET_SPIN 1

/* Runtime modes */
#define GR1C_MODE_SYNTAX 0
#define GR1C_MODE_REALIZABLE 1
#define GR1C_MODE_SYNTHESIS 2
#define GR1C_MODE_INTERACTIVE 3


int main( int argc, char **argv )
{
	FILE *fp;
	byte run_option = GR1C_MODE_SYNTHESIS;
	bool help_flag = False;
	bool ptdump_flag = False;
	bool logging_flag = False;
	unsigned char init_flags = ALL_ENV_EXIST_SYS_INIT;
	byte format_option = OUTPUT_FORMAT_JSON;
	unsigned char verbose = 0;
	bool reading_options = True;  /* For disabling option parsing using "--" */
	int input_index = -1;
	int output_file_index = -1;  /* For command-line flag "-o". */
	char dumpfilename[64];
	char **command_argv = NULL;

	byte verification_model = 0;  /* For command-line flag "-P". */
	ptree_t *original_env_init;
	ptree_t *original_sys_init;
	ptree_t **original_env_goals;
	ptree_t **original_sys_goals;
	int original_num_egoals;
	int original_num_sgoals;
	ptree_t **original_env_trans_array;
	ptree_t **original_sys_trans_array;
	int original_et_array_len;
	int original_st_array_len;

	int i, j, var_index;
	ptree_t *tmppt;  /* General purpose temporary ptree pointer */

	DdManager *manager;
	DdNode *T = NULL;
	anode_t *strategy = NULL;
	int num_env, num_sys;

	/* Try to handle sub-commands first */
	if (argc >= 2) {
		if (!strncmp( argv[1], "rg", strlen( "rg" ) )) {

			/* Pass arguments after rg */
			command_argv = malloc( sizeof(char *)*argc );
			command_argv[0] = strdup( "gr1c-rg" );
			command_argv[argc] = NULL;
			for (i = 1; i < argc-1; i++)
				command_argv[i] = argv[i+1];

			if (execv( "gr1c-rg", command_argv ) < 0) {
				perror( "gr1c, execv" );
				return -1;
			}

		}
	}

	/* Look for flags in command-line arguments. */
	for (i = 1; i < argc; i++) {<commit_msg>BUGFIX: Search for gr1c-rg on system path, not just in CWD<commit_after>/* main.c -- main entry point for execution.
 *
 * Command-line arguments are processed by hand.  Eventually switch to
 * getopt, once sophistication of usage demands.
 *
 *
 * SCL; 2012-2014.
 */


#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

#include "common.h"
#include "logging.h"
#include "ptree.h"
#include "solve.h"
#include "automaton.h"
#include "gr1c_util.h"
extern int yyparse( void );
extern void yyrestart( FILE *new_file );


/**************************
 **** Global variables ****/

ptree_t *nonbool_var_list = NULL;

extern ptree_t *evar_list;
extern ptree_t *svar_list;
extern ptree_t *env_init;
extern ptree_t *sys_init;
ptree_t *env_trans = NULL;  /* Built from components in env_trans_array. */
ptree_t *sys_trans = NULL;
extern ptree_t **env_goals;
extern ptree_t **sys_goals;
extern int num_egoals;
extern int num_sgoals;

extern ptree_t **env_trans_array;
extern ptree_t **sys_trans_array;
extern int et_array_len;
extern int st_array_len;

/**************************/


/* Output formats */
#define OUTPUT_FORMAT_TEXT 0
#define OUTPUT_FORMAT_TULIP 1
#define OUTPUT_FORMAT_DOT 2
#define OUTPUT_FORMAT_AUT 3
#define OUTPUT_FORMAT_JSON 5

/* Verification model targets */
#define VERMODEL_TARGET_SPIN 1

/* Runtime modes */
#define GR1C_MODE_SYNTAX 0
#define GR1C_MODE_REALIZABLE 1
#define GR1C_MODE_SYNTHESIS 2
#define GR1C_MODE_INTERACTIVE 3


int main( int argc, char **argv )
{
	FILE *fp;
	byte run_option = GR1C_MODE_SYNTHESIS;
	bool help_flag = False;
	bool ptdump_flag = False;
	bool logging_flag = False;
	unsigned char init_flags = ALL_ENV_EXIST_SYS_INIT;
	byte format_option = OUTPUT_FORMAT_JSON;
	unsigned char verbose = 0;
	bool reading_options = True;  /* For disabling option parsing using "--" */
	int input_index = -1;
	int output_file_index = -1;  /* For command-line flag "-o". */
	char dumpfilename[64];
	char **command_argv = NULL;

	byte verification_model = 0;  /* For command-line flag "-P". */
	ptree_t *original_env_init;
	ptree_t *original_sys_init;
	ptree_t **original_env_goals;
	ptree_t **original_sys_goals;
	int original_num_egoals;
	int original_num_sgoals;
	ptree_t **original_env_trans_array;
	ptree_t **original_sys_trans_array;
	int original_et_array_len;
	int original_st_array_len;

	int i, j, var_index;
	ptree_t *tmppt;  /* General purpose temporary ptree pointer */

	DdManager *manager;
	DdNode *T = NULL;
	anode_t *strategy = NULL;
	int num_env, num_sys;

	/* Try to handle sub-commands first */
	if (argc >= 2) {
		if (!strncmp( argv[1], "rg", strlen( "rg" ) )) {

			/* Pass arguments after rg */
			command_argv = malloc( sizeof(char *)*argc );
			command_argv[0] = strdup( "gr1c-rg" );
			command_argv[argc] = NULL;
			for (i = 1; i < argc-1; i++)
				command_argv[i] = argv[i+1];

			if (execvp( "gr1c-rg", command_argv ) < 0) {
				perror( "gr1c, execv" );
				return -1;
			}

		}
	}

	/* Look for flags in command-line arguments. */
	for (i = 1; i < argc; i++) {
{'fraction_non_alphanumeric': 0.13413429888084266, 'fraction_numerical': 0.013989466754443713, 'mean_word_length': 4.396980461811723, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1937708', 'n_tokens_mistral': 2449, 'n_tokens_neox': 2291, 'n_words': 618}