示例#1
0
static void run_template_parser(void) {
	/* Initialize room info */
	event_signal_message(EVENT_INITSTATUS, 0, "Initializing arrays... (dungeon profiles)");
	if (run_parser(&profile_parser))
		quit("Cannot initialize dungeon profiles");

	/* Initialize room info */
	event_signal_message(EVENT_INITSTATUS, 0, "Initializing arrays... (room templates)");
	if (run_parser(&room_parser))
		quit("Cannot initialize room templates");

	/* Initialize vault info */
	event_signal_message(EVENT_INITSTATUS, 0, "Initializing arrays... (vaults)");
	if (run_parser(&v_parser))
		quit("Cannot initialize vaults");
}
示例#2
0
// append opens the given file or stream and parses it as a .dc file.  The distributed
//     classes defined in the file are added to the list of classes associated with the File.
//     When appending from a stream, a filename is optional only used to report errors.
bool append(File* f, istream &in, const string &filename)
{
    init_file_parser(in, filename, *f);
    run_parser();
    cleanup_parser();
    return (parser_error_count() == 0);
}
示例#3
0
void __fastcall TForm3::Button1Click(TObject *Sender)
{
	char file_name[1024];
	char gramm[1024];
	strncpy( file_name , (OpenDialog1->FileName).c_str() , (OpenDialog1->FileName).Length()+1 );
	scanner( file_name );
    strncpy( gramm , (OpenDialog2->FileName).c_str() , (OpenDialog2->FileName).Length()+1 );

	run_parser( TreeView1 , gramm );
	TreeView1->FullExpand();
}
示例#4
0
文件: test_let.c 项目: dkdream/Water
int main(int    argc,
         char **argv)
{
    FILE *input = 0;

    stable_Init(1024, &my_symbols);

    setup_parser();
    setup_walker();

    if (argc > 1) {
        printf("input = %s\n", argv[1]);
        input = fopen(argv[1], "r");
    }

    if (input) {
        run_parser(input);
    } else {
        push_tree("Value", 0);
        push_tree("Symbol", 0);
        push_tree("ParameterName", 1);
        push_tree("LetAssign", 2);
        stack_Dup(&the_trees);
        push_tree("Statement", 0);
        push_tree("Let", 3);
        stack_Dup(&the_trees);
        push_tree("Block", 2);
    }

    if (!the_trees.top) return 0;

    Node_test value = the_trees.top->value;

    node_Print(0, value);

    if (!run_walker(value)) return 1;

    return 0;
}
示例#5
0
文件: parse.cpp 项目: Echocage/Astron
string parse_value(const DistributedType* dtype, istream &in, bool &err)
{
	string value;
	try
	{
		init_value_parser(in, "parse_value()", dtype, value);
		run_parser();
		cleanup_parser();
	}
	catch(const exception& e)
	{
		err = true;
		return string("parse_value() error: ") + e.what();
	}

	if(parser_error_count() > 0)
	{
		err = true;
		return string("parse value(): unknown error");
	}

	err = false;
	return value;
}
示例#6
0
文件: store.c 项目: batogz/angband
void store_init(void)
{
	event_signal_message(EVENT_INITSTATUS, 0, "Initializing stores...");
	if (run_parser(&store_parser)) quit("Can't initialize stores");
	stores = flatten_stores(stores);
}
示例#7
0
int main(int argc, char ** argv) {
    int ret, exit_status = NETLOC_SUCCESS;
    int i;
    netloc_network_t *network = NULL;
    netloc_data_collection_handle_t *dc_handle = NULL;

    /*
     * Parse Args
     */
    if( 0 != parse_args(argc, argv) ) {
        printf("Usage: %s %s|%s <controller> [%s|%s <subnet id>] [%s|%s <output directory>] [%s|%s <URL Address:Port>] [%s|%s <username>] [%s|%s <password>] [%s|%s]\n",
               argv[0],
               ARG_CONTROLLER, ARG_SHORT_CONTROLLER,
               ARG_SUBNET, ARG_SHORT_SUBNET,
               ARG_OUTDIR, ARG_SHORT_OUTDIR,
               ARG_ADDRESS, ARG_SHORT_ADDRESS,
               ARG_AUTH_USER, ARG_SHORT_AUTH_USER,
               ARG_AUTH_PASS, ARG_SHORT_AUTH_PASS,
               ARG_HELP, ARG_SHORT_HELP);
        printf("       Default %-10s = \"unknown\"\n", ARG_SUBNET);
        printf("       Default %-10s = \"127.0.0.1:8080\"\n", ARG_ADDRESS);
        printf("       Default %-10s = current working directory\n", ARG_OUTDIR);
        printf("       Valid Options for %s:\n", ARG_CONTROLLER );
        // Note: Hide 'noop' since it is only meant for debugging, and not for normal use
        for(i = 1; i < num_valid_controllers; ++i) {
            printf("\t\t%s\n", valid_controllers[i] );
        }

        return NETLOC_ERROR;
    }


    /*
     * Run the parser requested
     */
    if( 0 != (ret = run_parser() ) ) {
        return ret;
    }

    /*
     * Setup network information
     */
    network = netloc_dt_network_t_construct();
    ret = extract_network_info_from_json_file(network, out_file_nodes);
    if( NETLOC_SUCCESS != ret ) {
        fprintf(stderr, "Error: Failed to extract network information from the file: %s\n", out_file_nodes);
        return ret;
    }

    dc_handle = netloc_dc_create(network, outdir);
    if( NULL == dc_handle ) {
        fprintf(stderr, "Error: Failed to create a new data file\n");
        return ret;
    }
    netloc_dt_network_t_destruct(network);
    network = NULL;

    /*
     * Convert the temporary node file to the proper format
     */
    if( 0 != (ret = convert_nodes_file(dc_handle)) ) {
        exit_status = ret;
        goto cleanup;
    }

    /*
     * Find all physical paths
     */
    if( 0 != (ret = compute_physical_paths(dc_handle)) ) {
        exit_status = ret;
        goto cleanup;
    }

 cleanup:
    /*
     * Close the handle
     */
    ret = netloc_dc_close(dc_handle);
    if( NETLOC_SUCCESS != ret ) {
        fprintf(stderr, "Error: Failed to close the data connection!\n");
        return ret;
    }

    netloc_dt_data_collection_handle_t_destruct(dc_handle);
    dc_handle = NULL;

    /*
     * Validate the resulting .dat files
     */
    if( 0 == exit_status ) {
        if( 0 != (ret = check_dat_files() ) ) {
            return ret;
        }
    }

    free(outdir);
    free(out_file_nodes);
    free(subnet);
    free(uri_address);
    free(auth_username);
    free(auth_password);
    return exit_status;
}